babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  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. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /** Associative array from JSON sprite data file */
  11559. private _cellData;
  11560. /** Array of sprite names from JSON sprite data file */
  11561. private _spriteMap;
  11562. /** True when packed cell data from JSON file is ready*/
  11563. private _packedAndReady;
  11564. /**
  11565. * An event triggered when the manager is disposed.
  11566. */
  11567. onDisposeObservable: Observable<SpriteManager>;
  11568. private _onDisposeObserver;
  11569. /**
  11570. * Callback called when the manager is disposed
  11571. */
  11572. onDispose: () => void;
  11573. private _capacity;
  11574. private _fromPacked;
  11575. private _spriteTexture;
  11576. private _epsilon;
  11577. private _scene;
  11578. private _vertexData;
  11579. private _buffer;
  11580. private _vertexBuffers;
  11581. private _indexBuffer;
  11582. private _effectBase;
  11583. private _effectFog;
  11584. /**
  11585. * Gets or sets the spritesheet texture
  11586. */
  11587. texture: Texture;
  11588. /**
  11589. * Creates a new sprite manager
  11590. * @param name defines the manager's name
  11591. * @param imgUrl defines the sprite sheet url
  11592. * @param capacity defines the maximum allowed number of sprites
  11593. * @param cellSize defines the size of a sprite cell
  11594. * @param scene defines the hosting scene
  11595. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11596. * @param samplingMode defines the smapling mode to use with spritesheet
  11597. * @param fromPacked set to false; do not alter
  11598. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11599. */
  11600. constructor(
  11601. /** defines the manager's name */
  11602. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11603. private _makePacked;
  11604. private _appendSpriteVertex;
  11605. /**
  11606. * Intersects the sprites with a ray
  11607. * @param ray defines the ray to intersect with
  11608. * @param camera defines the current active camera
  11609. * @param predicate defines a predicate used to select candidate sprites
  11610. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11611. * @returns null if no hit or a PickingInfo
  11612. */
  11613. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11614. /**
  11615. * Render all child sprites
  11616. */
  11617. render(): void;
  11618. /**
  11619. * Release associated resources
  11620. */
  11621. dispose(): void;
  11622. }
  11623. }
  11624. declare module "babylonjs/Sprites/sprite" {
  11625. import { Vector3 } from "babylonjs/Maths/math.vector";
  11626. import { Nullable } from "babylonjs/types";
  11627. import { ActionManager } from "babylonjs/Actions/actionManager";
  11628. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11629. import { Color4 } from "babylonjs/Maths/math.color";
  11630. /**
  11631. * Class used to represent a sprite
  11632. * @see http://doc.babylonjs.com/babylon101/sprites
  11633. */
  11634. export class Sprite {
  11635. /** defines the name */
  11636. name: string;
  11637. /** Gets or sets the current world position */
  11638. position: Vector3;
  11639. /** Gets or sets the main color */
  11640. color: Color4;
  11641. /** Gets or sets the width */
  11642. width: number;
  11643. /** Gets or sets the height */
  11644. height: number;
  11645. /** Gets or sets rotation angle */
  11646. angle: number;
  11647. /** Gets or sets the cell index in the sprite sheet */
  11648. cellIndex: number;
  11649. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11650. cellRef: string;
  11651. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11652. invertU: number;
  11653. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11654. invertV: number;
  11655. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11656. disposeWhenFinishedAnimating: boolean;
  11657. /** Gets the list of attached animations */
  11658. animations: Animation[];
  11659. /** Gets or sets a boolean indicating if the sprite can be picked */
  11660. isPickable: boolean;
  11661. /**
  11662. * Gets or sets the associated action manager
  11663. */
  11664. actionManager: Nullable<ActionManager>;
  11665. private _animationStarted;
  11666. private _loopAnimation;
  11667. private _fromIndex;
  11668. private _toIndex;
  11669. private _delay;
  11670. private _direction;
  11671. private _manager;
  11672. private _time;
  11673. private _onAnimationEnd;
  11674. /**
  11675. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11676. */
  11677. isVisible: boolean;
  11678. /**
  11679. * Gets or sets the sprite size
  11680. */
  11681. size: number;
  11682. /**
  11683. * Creates a new Sprite
  11684. * @param name defines the name
  11685. * @param manager defines the manager
  11686. */
  11687. constructor(
  11688. /** defines the name */
  11689. name: string, manager: ISpriteManager);
  11690. /**
  11691. * Starts an animation
  11692. * @param from defines the initial key
  11693. * @param to defines the end key
  11694. * @param loop defines if the animation must loop
  11695. * @param delay defines the start delay (in ms)
  11696. * @param onAnimationEnd defines a callback to call when animation ends
  11697. */
  11698. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11699. /** Stops current animation (if any) */
  11700. stopAnimation(): void;
  11701. /** @hidden */
  11702. _animate(deltaTime: number): void;
  11703. /** Release associated resources */
  11704. dispose(): void;
  11705. }
  11706. }
  11707. declare module "babylonjs/Collisions/pickingInfo" {
  11708. import { Nullable } from "babylonjs/types";
  11709. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11711. import { Sprite } from "babylonjs/Sprites/sprite";
  11712. import { Ray } from "babylonjs/Culling/ray";
  11713. /**
  11714. * Information about the result of picking within a scene
  11715. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11716. */
  11717. export class PickingInfo {
  11718. /** @hidden */
  11719. _pickingUnavailable: boolean;
  11720. /**
  11721. * If the pick collided with an object
  11722. */
  11723. hit: boolean;
  11724. /**
  11725. * Distance away where the pick collided
  11726. */
  11727. distance: number;
  11728. /**
  11729. * The location of pick collision
  11730. */
  11731. pickedPoint: Nullable<Vector3>;
  11732. /**
  11733. * The mesh corresponding the the pick collision
  11734. */
  11735. pickedMesh: Nullable<AbstractMesh>;
  11736. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11737. bu: number;
  11738. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11739. bv: number;
  11740. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11741. faceId: number;
  11742. /** Id of the the submesh that was picked */
  11743. subMeshId: number;
  11744. /** If a sprite was picked, this will be the sprite the pick collided with */
  11745. pickedSprite: Nullable<Sprite>;
  11746. /**
  11747. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11748. */
  11749. originMesh: Nullable<AbstractMesh>;
  11750. /**
  11751. * The ray that was used to perform the picking.
  11752. */
  11753. ray: Nullable<Ray>;
  11754. /**
  11755. * Gets the normal correspodning to the face the pick collided with
  11756. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11757. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11758. * @returns The normal correspodning to the face the pick collided with
  11759. */
  11760. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11761. /**
  11762. * Gets the texture coordinates of where the pick occured
  11763. * @returns the vector containing the coordnates of the texture
  11764. */
  11765. getTextureCoordinates(): Nullable<Vector2>;
  11766. }
  11767. }
  11768. declare module "babylonjs/Events/pointerEvents" {
  11769. import { Nullable } from "babylonjs/types";
  11770. import { Vector2 } from "babylonjs/Maths/math.vector";
  11771. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11772. import { Ray } from "babylonjs/Culling/ray";
  11773. /**
  11774. * Gather the list of pointer event types as constants.
  11775. */
  11776. export class PointerEventTypes {
  11777. /**
  11778. * 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.
  11779. */
  11780. static readonly POINTERDOWN: number;
  11781. /**
  11782. * The pointerup event is fired when a pointer is no longer active.
  11783. */
  11784. static readonly POINTERUP: number;
  11785. /**
  11786. * The pointermove event is fired when a pointer changes coordinates.
  11787. */
  11788. static readonly POINTERMOVE: number;
  11789. /**
  11790. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11791. */
  11792. static readonly POINTERWHEEL: number;
  11793. /**
  11794. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11795. */
  11796. static readonly POINTERPICK: number;
  11797. /**
  11798. * The pointertap event is fired when a the object has been touched and released without drag.
  11799. */
  11800. static readonly POINTERTAP: number;
  11801. /**
  11802. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11803. */
  11804. static readonly POINTERDOUBLETAP: number;
  11805. }
  11806. /**
  11807. * Base class of pointer info types.
  11808. */
  11809. export class PointerInfoBase {
  11810. /**
  11811. * Defines the type of event (PointerEventTypes)
  11812. */
  11813. type: number;
  11814. /**
  11815. * Defines the related dom event
  11816. */
  11817. event: PointerEvent | MouseWheelEvent;
  11818. /**
  11819. * Instantiates the base class of pointers info.
  11820. * @param type Defines the type of event (PointerEventTypes)
  11821. * @param event Defines the related dom event
  11822. */
  11823. constructor(
  11824. /**
  11825. * Defines the type of event (PointerEventTypes)
  11826. */
  11827. type: number,
  11828. /**
  11829. * Defines the related dom event
  11830. */
  11831. event: PointerEvent | MouseWheelEvent);
  11832. }
  11833. /**
  11834. * This class is used to store pointer related info for the onPrePointerObservable event.
  11835. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11836. */
  11837. export class PointerInfoPre extends PointerInfoBase {
  11838. /**
  11839. * Ray from a pointer if availible (eg. 6dof controller)
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Defines the local position of the pointer on the canvas.
  11844. */
  11845. localPosition: Vector2;
  11846. /**
  11847. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11848. */
  11849. skipOnPointerObservable: boolean;
  11850. /**
  11851. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11852. * @param type Defines the type of event (PointerEventTypes)
  11853. * @param event Defines the related dom event
  11854. * @param localX Defines the local x coordinates of the pointer when the event occured
  11855. * @param localY Defines the local y coordinates of the pointer when the event occured
  11856. */
  11857. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11858. }
  11859. /**
  11860. * This type contains all the data related to a pointer event in Babylon.js.
  11861. * 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.
  11862. */
  11863. export class PointerInfo extends PointerInfoBase {
  11864. /**
  11865. * Defines the picking info associated to the info (if any)\
  11866. */
  11867. pickInfo: Nullable<PickingInfo>;
  11868. /**
  11869. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. * @param pickInfo Defines the picking info associated to the info (if any)\
  11873. */
  11874. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11875. /**
  11876. * Defines the picking info associated to the info (if any)\
  11877. */
  11878. pickInfo: Nullable<PickingInfo>);
  11879. }
  11880. /**
  11881. * Data relating to a touch event on the screen.
  11882. */
  11883. export interface PointerTouch {
  11884. /**
  11885. * X coordinate of touch.
  11886. */
  11887. x: number;
  11888. /**
  11889. * Y coordinate of touch.
  11890. */
  11891. y: number;
  11892. /**
  11893. * Id of touch. Unique for each finger.
  11894. */
  11895. pointerId: number;
  11896. /**
  11897. * Event type passed from DOM.
  11898. */
  11899. type: any;
  11900. }
  11901. }
  11902. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11903. import { Observable } from "babylonjs/Misc/observable";
  11904. import { Nullable } from "babylonjs/types";
  11905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11907. /**
  11908. * Manage the mouse inputs to control the movement of a free camera.
  11909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11910. */
  11911. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11912. /**
  11913. * Define if touch is enabled in the mouse input
  11914. */
  11915. touchEnabled: boolean;
  11916. /**
  11917. * Defines the camera the input is attached to.
  11918. */
  11919. camera: FreeCamera;
  11920. /**
  11921. * Defines the buttons associated with the input to handle camera move.
  11922. */
  11923. buttons: number[];
  11924. /**
  11925. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11926. */
  11927. angularSensibility: number;
  11928. private _pointerInput;
  11929. private _onMouseMove;
  11930. private _observer;
  11931. private previousPosition;
  11932. /**
  11933. * Observable for when a pointer move event occurs containing the move offset
  11934. */
  11935. onPointerMovedObservable: Observable<{
  11936. offsetX: number;
  11937. offsetY: number;
  11938. }>;
  11939. /**
  11940. * @hidden
  11941. * If the camera should be rotated automatically based on pointer movement
  11942. */
  11943. _allowCameraRotation: boolean;
  11944. /**
  11945. * Manage the mouse inputs to control the movement of a free camera.
  11946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11947. * @param touchEnabled Defines if touch is enabled or not
  11948. */
  11949. constructor(
  11950. /**
  11951. * Define if touch is enabled in the mouse input
  11952. */
  11953. touchEnabled?: boolean);
  11954. /**
  11955. * Attach the input controls to a specific dom element to get the input from.
  11956. * @param element Defines the element the controls should be listened from
  11957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11958. */
  11959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11960. /**
  11961. * Called on JS contextmenu event.
  11962. * Override this method to provide functionality.
  11963. */
  11964. protected onContextMenu(evt: PointerEvent): void;
  11965. /**
  11966. * Detach the current controls from the specified dom element.
  11967. * @param element Defines the element to stop listening the inputs from
  11968. */
  11969. detachControl(element: Nullable<HTMLElement>): void;
  11970. /**
  11971. * Gets the class name of the current intput.
  11972. * @returns the class name
  11973. */
  11974. getClassName(): string;
  11975. /**
  11976. * Get the friendly name associated with the input class.
  11977. * @returns the input friendly name
  11978. */
  11979. getSimpleName(): string;
  11980. }
  11981. }
  11982. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11983. import { Nullable } from "babylonjs/types";
  11984. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11985. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11986. /**
  11987. * Manage the touch inputs to control the movement of a free camera.
  11988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11989. */
  11990. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11991. /**
  11992. * Defines the camera the input is attached to.
  11993. */
  11994. camera: FreeCamera;
  11995. /**
  11996. * Defines the touch sensibility for rotation.
  11997. * The higher the faster.
  11998. */
  11999. touchAngularSensibility: number;
  12000. /**
  12001. * Defines the touch sensibility for move.
  12002. * The higher the faster.
  12003. */
  12004. touchMoveSensibility: number;
  12005. private _offsetX;
  12006. private _offsetY;
  12007. private _pointerPressed;
  12008. private _pointerInput;
  12009. private _observer;
  12010. private _onLostFocus;
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Detach the current controls from the specified dom element.
  12019. * @param element Defines the element to stop listening the inputs from
  12020. */
  12021. detachControl(element: Nullable<HTMLElement>): void;
  12022. /**
  12023. * Update the current camera state depending on the inputs that have been used this frame.
  12024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12025. */
  12026. checkInputs(): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12041. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12043. import { Nullable } from "babylonjs/types";
  12044. /**
  12045. * Default Inputs manager for the FreeCamera.
  12046. * It groups all the default supported inputs for ease of use.
  12047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12048. */
  12049. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12050. /**
  12051. * @hidden
  12052. */
  12053. _mouseInput: Nullable<FreeCameraMouseInput>;
  12054. /**
  12055. * Instantiates a new FreeCameraInputsManager.
  12056. * @param camera Defines the camera the inputs belong to
  12057. */
  12058. constructor(camera: FreeCamera);
  12059. /**
  12060. * Add keyboard input support to the input manager.
  12061. * @returns the current input manager
  12062. */
  12063. addKeyboard(): FreeCameraInputsManager;
  12064. /**
  12065. * Add mouse input support to the input manager.
  12066. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12067. * @returns the current input manager
  12068. */
  12069. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12070. /**
  12071. * Removes the mouse input support from the manager
  12072. * @returns the current input manager
  12073. */
  12074. removeMouse(): FreeCameraInputsManager;
  12075. /**
  12076. * Add touch input support to the input manager.
  12077. * @returns the current input manager
  12078. */
  12079. addTouch(): FreeCameraInputsManager;
  12080. /**
  12081. * Remove all attached input methods from a camera
  12082. */
  12083. clear(): void;
  12084. }
  12085. }
  12086. declare module "babylonjs/Cameras/freeCamera" {
  12087. import { Vector3 } from "babylonjs/Maths/math.vector";
  12088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12089. import { Scene } from "babylonjs/scene";
  12090. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12091. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12092. /**
  12093. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12094. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12096. */
  12097. export class FreeCamera extends TargetCamera {
  12098. /**
  12099. * Define the collision ellipsoid of the camera.
  12100. * This is helpful to simulate a camera body like the player body around the camera
  12101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12102. */
  12103. ellipsoid: Vector3;
  12104. /**
  12105. * Define an offset for the position of the ellipsoid around the camera.
  12106. * This can be helpful to determine the center of the body near the gravity center of the body
  12107. * instead of its head.
  12108. */
  12109. ellipsoidOffset: Vector3;
  12110. /**
  12111. * Enable or disable collisions of the camera with the rest of the scene objects.
  12112. */
  12113. checkCollisions: boolean;
  12114. /**
  12115. * Enable or disable gravity on the camera.
  12116. */
  12117. applyGravity: boolean;
  12118. /**
  12119. * Define the input manager associated to the camera.
  12120. */
  12121. inputs: FreeCameraInputsManager;
  12122. /**
  12123. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12124. * Higher values reduce sensitivity.
  12125. */
  12126. /**
  12127. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12128. * Higher values reduce sensitivity.
  12129. */
  12130. angularSensibility: number;
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12133. */
  12134. keysUp: number[];
  12135. /**
  12136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12137. */
  12138. keysDown: number[];
  12139. /**
  12140. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12141. */
  12142. keysLeft: number[];
  12143. /**
  12144. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12145. */
  12146. keysRight: number[];
  12147. /**
  12148. * Event raised when the camera collide with a mesh in the scene.
  12149. */
  12150. onCollide: (collidedMesh: AbstractMesh) => void;
  12151. private _collider;
  12152. private _needMoveForGravity;
  12153. private _oldPosition;
  12154. private _diffPosition;
  12155. private _newPosition;
  12156. /** @hidden */
  12157. _localDirection: Vector3;
  12158. /** @hidden */
  12159. _transformedDirection: Vector3;
  12160. /**
  12161. * Instantiates a Free Camera.
  12162. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12163. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12165. * @param name Define the name of the camera in the scene
  12166. * @param position Define the start position of the camera in the scene
  12167. * @param scene Define the scene the camera belongs to
  12168. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12169. */
  12170. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12171. /**
  12172. * Attached controls to the current camera.
  12173. * @param element Defines the element the controls should be listened from
  12174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12175. */
  12176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12177. /**
  12178. * Detach the current controls from the camera.
  12179. * The camera will stop reacting to inputs.
  12180. * @param element Defines the element to stop listening the inputs from
  12181. */
  12182. detachControl(element: HTMLElement): void;
  12183. private _collisionMask;
  12184. /**
  12185. * Define a collision mask to limit the list of object the camera can collide with
  12186. */
  12187. collisionMask: number;
  12188. /** @hidden */
  12189. _collideWithWorld(displacement: Vector3): void;
  12190. private _onCollisionPositionChange;
  12191. /** @hidden */
  12192. _checkInputs(): void;
  12193. /** @hidden */
  12194. _decideIfNeedsToMove(): boolean;
  12195. /** @hidden */
  12196. _updatePosition(): void;
  12197. /**
  12198. * Destroy the camera and release the current resources hold by it.
  12199. */
  12200. dispose(): void;
  12201. /**
  12202. * Gets the current object class name.
  12203. * @return the class name
  12204. */
  12205. getClassName(): string;
  12206. }
  12207. }
  12208. declare module "babylonjs/Gamepads/gamepad" {
  12209. import { Observable } from "babylonjs/Misc/observable";
  12210. /**
  12211. * Represents a gamepad control stick position
  12212. */
  12213. export class StickValues {
  12214. /**
  12215. * The x component of the control stick
  12216. */
  12217. x: number;
  12218. /**
  12219. * The y component of the control stick
  12220. */
  12221. y: number;
  12222. /**
  12223. * Initializes the gamepad x and y control stick values
  12224. * @param x The x component of the gamepad control stick value
  12225. * @param y The y component of the gamepad control stick value
  12226. */
  12227. constructor(
  12228. /**
  12229. * The x component of the control stick
  12230. */
  12231. x: number,
  12232. /**
  12233. * The y component of the control stick
  12234. */
  12235. y: number);
  12236. }
  12237. /**
  12238. * An interface which manages callbacks for gamepad button changes
  12239. */
  12240. export interface GamepadButtonChanges {
  12241. /**
  12242. * Called when a gamepad has been changed
  12243. */
  12244. changed: boolean;
  12245. /**
  12246. * Called when a gamepad press event has been triggered
  12247. */
  12248. pressChanged: boolean;
  12249. /**
  12250. * Called when a touch event has been triggered
  12251. */
  12252. touchChanged: boolean;
  12253. /**
  12254. * Called when a value has changed
  12255. */
  12256. valueChanged: boolean;
  12257. }
  12258. /**
  12259. * Represents a gamepad
  12260. */
  12261. export class Gamepad {
  12262. /**
  12263. * The id of the gamepad
  12264. */
  12265. id: string;
  12266. /**
  12267. * The index of the gamepad
  12268. */
  12269. index: number;
  12270. /**
  12271. * The browser gamepad
  12272. */
  12273. browserGamepad: any;
  12274. /**
  12275. * Specifies what type of gamepad this represents
  12276. */
  12277. type: number;
  12278. private _leftStick;
  12279. private _rightStick;
  12280. /** @hidden */
  12281. _isConnected: boolean;
  12282. private _leftStickAxisX;
  12283. private _leftStickAxisY;
  12284. private _rightStickAxisX;
  12285. private _rightStickAxisY;
  12286. /**
  12287. * Triggered when the left control stick has been changed
  12288. */
  12289. private _onleftstickchanged;
  12290. /**
  12291. * Triggered when the right control stick has been changed
  12292. */
  12293. private _onrightstickchanged;
  12294. /**
  12295. * Represents a gamepad controller
  12296. */
  12297. static GAMEPAD: number;
  12298. /**
  12299. * Represents a generic controller
  12300. */
  12301. static GENERIC: number;
  12302. /**
  12303. * Represents an XBox controller
  12304. */
  12305. static XBOX: number;
  12306. /**
  12307. * Represents a pose-enabled controller
  12308. */
  12309. static POSE_ENABLED: number;
  12310. /**
  12311. * Represents an Dual Shock controller
  12312. */
  12313. static DUALSHOCK: number;
  12314. /**
  12315. * Specifies whether the left control stick should be Y-inverted
  12316. */
  12317. protected _invertLeftStickY: boolean;
  12318. /**
  12319. * Specifies if the gamepad has been connected
  12320. */
  12321. readonly isConnected: boolean;
  12322. /**
  12323. * Initializes the gamepad
  12324. * @param id The id of the gamepad
  12325. * @param index The index of the gamepad
  12326. * @param browserGamepad The browser gamepad
  12327. * @param leftStickX The x component of the left joystick
  12328. * @param leftStickY The y component of the left joystick
  12329. * @param rightStickX The x component of the right joystick
  12330. * @param rightStickY The y component of the right joystick
  12331. */
  12332. constructor(
  12333. /**
  12334. * The id of the gamepad
  12335. */
  12336. id: string,
  12337. /**
  12338. * The index of the gamepad
  12339. */
  12340. index: number,
  12341. /**
  12342. * The browser gamepad
  12343. */
  12344. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12345. /**
  12346. * Callback triggered when the left joystick has changed
  12347. * @param callback
  12348. */
  12349. onleftstickchanged(callback: (values: StickValues) => void): void;
  12350. /**
  12351. * Callback triggered when the right joystick has changed
  12352. * @param callback
  12353. */
  12354. onrightstickchanged(callback: (values: StickValues) => void): void;
  12355. /**
  12356. * Gets the left joystick
  12357. */
  12358. /**
  12359. * Sets the left joystick values
  12360. */
  12361. leftStick: StickValues;
  12362. /**
  12363. * Gets the right joystick
  12364. */
  12365. /**
  12366. * Sets the right joystick value
  12367. */
  12368. rightStick: StickValues;
  12369. /**
  12370. * Updates the gamepad joystick positions
  12371. */
  12372. update(): void;
  12373. /**
  12374. * Disposes the gamepad
  12375. */
  12376. dispose(): void;
  12377. }
  12378. /**
  12379. * Represents a generic gamepad
  12380. */
  12381. export class GenericPad extends Gamepad {
  12382. private _buttons;
  12383. private _onbuttondown;
  12384. private _onbuttonup;
  12385. /**
  12386. * Observable triggered when a button has been pressed
  12387. */
  12388. onButtonDownObservable: Observable<number>;
  12389. /**
  12390. * Observable triggered when a button has been released
  12391. */
  12392. onButtonUpObservable: Observable<number>;
  12393. /**
  12394. * Callback triggered when a button has been pressed
  12395. * @param callback Called when a button has been pressed
  12396. */
  12397. onbuttondown(callback: (buttonPressed: number) => void): void;
  12398. /**
  12399. * Callback triggered when a button has been released
  12400. * @param callback Called when a button has been released
  12401. */
  12402. onbuttonup(callback: (buttonReleased: number) => void): void;
  12403. /**
  12404. * Initializes the generic gamepad
  12405. * @param id The id of the generic gamepad
  12406. * @param index The index of the generic gamepad
  12407. * @param browserGamepad The browser gamepad
  12408. */
  12409. constructor(id: string, index: number, browserGamepad: any);
  12410. private _setButtonValue;
  12411. /**
  12412. * Updates the generic gamepad
  12413. */
  12414. update(): void;
  12415. /**
  12416. * Disposes the generic gamepad
  12417. */
  12418. dispose(): void;
  12419. }
  12420. }
  12421. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12422. import { Nullable } from "babylonjs/types";
  12423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12424. import { Scene } from "babylonjs/scene";
  12425. module "babylonjs/Engines/engine" {
  12426. interface Engine {
  12427. /**
  12428. * Creates a raw texture
  12429. * @param data defines the data to store in the texture
  12430. * @param width defines the width of the texture
  12431. * @param height defines the height of the texture
  12432. * @param format defines the format of the data
  12433. * @param generateMipMaps defines if the engine should generate the mip levels
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12436. * @param compression defines the compression used (null by default)
  12437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12438. * @returns the raw texture inside an InternalTexture
  12439. */
  12440. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12441. /**
  12442. * Update a raw texture
  12443. * @param texture defines the texture to update
  12444. * @param data defines the data to store in the texture
  12445. * @param format defines the format of the data
  12446. * @param invertY defines if data must be stored with Y axis inverted
  12447. */
  12448. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12449. /**
  12450. * Update a raw texture
  12451. * @param texture defines the texture to update
  12452. * @param data defines the data to store in the texture
  12453. * @param format defines the format of the data
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param compression defines the compression used (null by default)
  12456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12457. */
  12458. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12459. /**
  12460. * Creates a new raw cube texture
  12461. * @param data defines the array of data to use to create each face
  12462. * @param size defines the size of the textures
  12463. * @param format defines the format of the data
  12464. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12465. * @param generateMipMaps defines if the engine should generate the mip levels
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12468. * @param compression defines the compression used (null by default)
  12469. * @returns the cube texture as an InternalTexture
  12470. */
  12471. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12472. /**
  12473. * Update a raw cube texture
  12474. * @param texture defines the texture to udpdate
  12475. * @param data defines the data to store
  12476. * @param format defines the data format
  12477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12478. * @param invertY defines if data must be stored with Y axis inverted
  12479. */
  12480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12481. /**
  12482. * Update a raw cube texture
  12483. * @param texture defines the texture to udpdate
  12484. * @param data defines the data to store
  12485. * @param format defines the data format
  12486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12487. * @param invertY defines if data must be stored with Y axis inverted
  12488. * @param compression defines the compression used (null by default)
  12489. */
  12490. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12491. /**
  12492. * Update a raw cube texture
  12493. * @param texture defines the texture to udpdate
  12494. * @param data defines the data to store
  12495. * @param format defines the data format
  12496. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12497. * @param invertY defines if data must be stored with Y axis inverted
  12498. * @param compression defines the compression used (null by default)
  12499. * @param level defines which level of the texture to update
  12500. */
  12501. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12502. /**
  12503. * Creates a new raw cube texture from a specified url
  12504. * @param url defines the url where the data is located
  12505. * @param scene defines the current scene
  12506. * @param size defines the size of the textures
  12507. * @param format defines the format of the data
  12508. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12509. * @param noMipmap defines if the engine should avoid generating the mip levels
  12510. * @param callback defines a callback used to extract texture data from loaded data
  12511. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12512. * @param onLoad defines a callback called when texture is loaded
  12513. * @param onError defines a callback called if there is an error
  12514. * @returns the cube texture as an InternalTexture
  12515. */
  12516. 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;
  12517. /**
  12518. * Creates a new raw cube texture from a specified url
  12519. * @param url defines the url where the data is located
  12520. * @param scene defines the current scene
  12521. * @param size defines the size of the textures
  12522. * @param format defines the format of the data
  12523. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12524. * @param noMipmap defines if the engine should avoid generating the mip levels
  12525. * @param callback defines a callback used to extract texture data from loaded data
  12526. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12527. * @param onLoad defines a callback called when texture is loaded
  12528. * @param onError defines a callback called if there is an error
  12529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @returns the cube texture as an InternalTexture
  12532. */
  12533. 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;
  12534. /**
  12535. * Creates a new raw 3D texture
  12536. * @param data defines the data used to create the texture
  12537. * @param width defines the width of the texture
  12538. * @param height defines the height of the texture
  12539. * @param depth defines the depth of the texture
  12540. * @param format defines the format of the texture
  12541. * @param generateMipMaps defines if the engine must generate mip levels
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12544. * @param compression defines the compressed used (can be null)
  12545. * @param textureType defines the compressed used (can be null)
  12546. * @returns a new raw 3D texture (stored in an InternalTexture)
  12547. */
  12548. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12549. /**
  12550. * Update a raw 3D texture
  12551. * @param texture defines the texture to update
  12552. * @param data defines the data to store
  12553. * @param format defines the data format
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. */
  12556. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12557. /**
  12558. * Update a raw 3D texture
  12559. * @param texture defines the texture to update
  12560. * @param data defines the data to store
  12561. * @param format defines the data format
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param compression defines the used compression (can be null)
  12564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12565. */
  12566. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12567. }
  12568. }
  12569. }
  12570. declare module "babylonjs/Materials/Textures/rawTexture" {
  12571. import { Scene } from "babylonjs/scene";
  12572. import { Texture } from "babylonjs/Materials/Textures/texture";
  12573. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12574. /**
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. */
  12579. export class RawTexture extends Texture {
  12580. /**
  12581. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. */
  12583. format: number;
  12584. private _engine;
  12585. /**
  12586. * Instantiates a new RawTexture.
  12587. * Raw texture can help creating a texture directly from an array of data.
  12588. * This can be super useful if you either get the data from an uncompressed source or
  12589. * if you wish to create your texture pixel by pixel.
  12590. * @param data define the array of data to use to create the texture
  12591. * @param width define the width of the texture
  12592. * @param height define the height of the texture
  12593. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12594. * @param scene define the scene the texture belongs to
  12595. * @param generateMipMaps define whether mip maps should be generated or not
  12596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12599. */
  12600. constructor(data: ArrayBufferView, width: number, height: number,
  12601. /**
  12602. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12603. */
  12604. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12605. /**
  12606. * Updates the texture underlying data.
  12607. * @param data Define the new data of the texture
  12608. */
  12609. update(data: ArrayBufferView): void;
  12610. /**
  12611. * Creates a luminance texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance texture
  12620. */
  12621. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates a luminance alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the luminance alpha texture
  12632. */
  12633. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates an alpha texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @returns the alpha texture
  12644. */
  12645. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12646. /**
  12647. * Creates a RGB texture from some data.
  12648. * @param data Define the texture data
  12649. * @param width Define the width of the texture
  12650. * @param height Define the height of the texture
  12651. * @param scene Define the scene the texture belongs to
  12652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. * @returns the RGB alpha texture
  12657. */
  12658. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12659. /**
  12660. * Creates a RGBA texture from some data.
  12661. * @param data Define the texture data
  12662. * @param width Define the width of the texture
  12663. * @param height Define the height of the texture
  12664. * @param scene Define the scene the texture belongs to
  12665. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12668. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12669. * @returns the RGBA texture
  12670. */
  12671. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12672. /**
  12673. * Creates a R texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12682. * @returns the R texture
  12683. */
  12684. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12685. }
  12686. }
  12687. declare module "babylonjs/Maths/math.size" {
  12688. /**
  12689. * Interface for the size containing width and height
  12690. */
  12691. export interface ISize {
  12692. /**
  12693. * Width
  12694. */
  12695. width: number;
  12696. /**
  12697. * Heighht
  12698. */
  12699. height: number;
  12700. }
  12701. /**
  12702. * Size containing widht and height
  12703. */
  12704. export class Size implements ISize {
  12705. /**
  12706. * Width
  12707. */
  12708. width: number;
  12709. /**
  12710. * Height
  12711. */
  12712. height: number;
  12713. /**
  12714. * Creates a Size object from the given width and height (floats).
  12715. * @param width width of the new size
  12716. * @param height height of the new size
  12717. */
  12718. constructor(width: number, height: number);
  12719. /**
  12720. * Returns a string with the Size width and height
  12721. * @returns a string with the Size width and height
  12722. */
  12723. toString(): string;
  12724. /**
  12725. * "Size"
  12726. * @returns the string "Size"
  12727. */
  12728. getClassName(): string;
  12729. /**
  12730. * Returns the Size hash code.
  12731. * @returns a hash code for a unique width and height
  12732. */
  12733. getHashCode(): number;
  12734. /**
  12735. * Updates the current size from the given one.
  12736. * @param src the given size
  12737. */
  12738. copyFrom(src: Size): void;
  12739. /**
  12740. * Updates in place the current Size from the given floats.
  12741. * @param width width of the new size
  12742. * @param height height of the new size
  12743. * @returns the updated Size.
  12744. */
  12745. copyFromFloats(width: number, height: number): Size;
  12746. /**
  12747. * Updates in place the current Size from the given floats.
  12748. * @param width width to set
  12749. * @param height height to set
  12750. * @returns the updated Size.
  12751. */
  12752. set(width: number, height: number): Size;
  12753. /**
  12754. * Multiplies the width and height by numbers
  12755. * @param w factor to multiple the width by
  12756. * @param h factor to multiple the height by
  12757. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12758. */
  12759. multiplyByFloats(w: number, h: number): Size;
  12760. /**
  12761. * Clones the size
  12762. * @returns a new Size copied from the given one.
  12763. */
  12764. clone(): Size;
  12765. /**
  12766. * True if the current Size and the given one width and height are strictly equal.
  12767. * @param other the other size to compare against
  12768. * @returns True if the current Size and the given one width and height are strictly equal.
  12769. */
  12770. equals(other: Size): boolean;
  12771. /**
  12772. * The surface of the Size : width * height (float).
  12773. */
  12774. readonly surface: number;
  12775. /**
  12776. * Create a new size of zero
  12777. * @returns a new Size set to (0.0, 0.0)
  12778. */
  12779. static Zero(): Size;
  12780. /**
  12781. * Sums the width and height of two sizes
  12782. * @param otherSize size to add to this size
  12783. * @returns a new Size set as the addition result of the current Size and the given one.
  12784. */
  12785. add(otherSize: Size): Size;
  12786. /**
  12787. * Subtracts the width and height of two
  12788. * @param otherSize size to subtract to this size
  12789. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12790. */
  12791. subtract(otherSize: Size): Size;
  12792. /**
  12793. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12794. * @param start starting size to lerp between
  12795. * @param end end size to lerp between
  12796. * @param amount amount to lerp between the start and end values
  12797. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12798. */
  12799. static Lerp(start: Size, end: Size, amount: number): Size;
  12800. }
  12801. }
  12802. declare module "babylonjs/Animations/runtimeAnimation" {
  12803. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12804. import { Animatable } from "babylonjs/Animations/animatable";
  12805. import { Scene } from "babylonjs/scene";
  12806. /**
  12807. * Defines a runtime animation
  12808. */
  12809. export class RuntimeAnimation {
  12810. private _events;
  12811. /**
  12812. * The current frame of the runtime animation
  12813. */
  12814. private _currentFrame;
  12815. /**
  12816. * The animation used by the runtime animation
  12817. */
  12818. private _animation;
  12819. /**
  12820. * The target of the runtime animation
  12821. */
  12822. private _target;
  12823. /**
  12824. * The initiating animatable
  12825. */
  12826. private _host;
  12827. /**
  12828. * The original value of the runtime animation
  12829. */
  12830. private _originalValue;
  12831. /**
  12832. * The original blend value of the runtime animation
  12833. */
  12834. private _originalBlendValue;
  12835. /**
  12836. * The offsets cache of the runtime animation
  12837. */
  12838. private _offsetsCache;
  12839. /**
  12840. * The high limits cache of the runtime animation
  12841. */
  12842. private _highLimitsCache;
  12843. /**
  12844. * Specifies if the runtime animation has been stopped
  12845. */
  12846. private _stopped;
  12847. /**
  12848. * The blending factor of the runtime animation
  12849. */
  12850. private _blendingFactor;
  12851. /**
  12852. * The BabylonJS scene
  12853. */
  12854. private _scene;
  12855. /**
  12856. * The current value of the runtime animation
  12857. */
  12858. private _currentValue;
  12859. /** @hidden */
  12860. _animationState: _IAnimationState;
  12861. /**
  12862. * The active target of the runtime animation
  12863. */
  12864. private _activeTargets;
  12865. private _currentActiveTarget;
  12866. private _directTarget;
  12867. /**
  12868. * The target path of the runtime animation
  12869. */
  12870. private _targetPath;
  12871. /**
  12872. * The weight of the runtime animation
  12873. */
  12874. private _weight;
  12875. /**
  12876. * The ratio offset of the runtime animation
  12877. */
  12878. private _ratioOffset;
  12879. /**
  12880. * The previous delay of the runtime animation
  12881. */
  12882. private _previousDelay;
  12883. /**
  12884. * The previous ratio of the runtime animation
  12885. */
  12886. private _previousRatio;
  12887. private _enableBlending;
  12888. private _keys;
  12889. private _minFrame;
  12890. private _maxFrame;
  12891. private _minValue;
  12892. private _maxValue;
  12893. private _targetIsArray;
  12894. /**
  12895. * Gets the current frame of the runtime animation
  12896. */
  12897. readonly currentFrame: number;
  12898. /**
  12899. * Gets the weight of the runtime animation
  12900. */
  12901. readonly weight: number;
  12902. /**
  12903. * Gets the current value of the runtime animation
  12904. */
  12905. readonly currentValue: any;
  12906. /**
  12907. * Gets the target path of the runtime animation
  12908. */
  12909. readonly targetPath: string;
  12910. /**
  12911. * Gets the actual target of the runtime animation
  12912. */
  12913. readonly target: any;
  12914. /** @hidden */
  12915. _onLoop: () => void;
  12916. /**
  12917. * Create a new RuntimeAnimation object
  12918. * @param target defines the target of the animation
  12919. * @param animation defines the source animation object
  12920. * @param scene defines the hosting scene
  12921. * @param host defines the initiating Animatable
  12922. */
  12923. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12924. private _preparePath;
  12925. /**
  12926. * Gets the animation from the runtime animation
  12927. */
  12928. readonly animation: Animation;
  12929. /**
  12930. * Resets the runtime animation to the beginning
  12931. * @param restoreOriginal defines whether to restore the target property to the original value
  12932. */
  12933. reset(restoreOriginal?: boolean): void;
  12934. /**
  12935. * Specifies if the runtime animation is stopped
  12936. * @returns Boolean specifying if the runtime animation is stopped
  12937. */
  12938. isStopped(): boolean;
  12939. /**
  12940. * Disposes of the runtime animation
  12941. */
  12942. dispose(): void;
  12943. /**
  12944. * Apply the interpolated value to the target
  12945. * @param currentValue defines the value computed by the animation
  12946. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12947. */
  12948. setValue(currentValue: any, weight: number): void;
  12949. private _getOriginalValues;
  12950. private _setValue;
  12951. /**
  12952. * Gets the loop pmode of the runtime animation
  12953. * @returns Loop Mode
  12954. */
  12955. private _getCorrectLoopMode;
  12956. /**
  12957. * Move the current animation to a given frame
  12958. * @param frame defines the frame to move to
  12959. */
  12960. goToFrame(frame: number): void;
  12961. /**
  12962. * @hidden Internal use only
  12963. */
  12964. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12965. /**
  12966. * Execute the current animation
  12967. * @param delay defines the delay to add to the current frame
  12968. * @param from defines the lower bound of the animation range
  12969. * @param to defines the upper bound of the animation range
  12970. * @param loop defines if the current animation must loop
  12971. * @param speedRatio defines the current speed ratio
  12972. * @param weight defines the weight of the animation (default is -1 so no weight)
  12973. * @param onLoop optional callback called when animation loops
  12974. * @returns a boolean indicating if the animation is running
  12975. */
  12976. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12977. }
  12978. }
  12979. declare module "babylonjs/Animations/animatable" {
  12980. import { Animation } from "babylonjs/Animations/animation";
  12981. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12982. import { Nullable } from "babylonjs/types";
  12983. import { Observable } from "babylonjs/Misc/observable";
  12984. import { Scene } from "babylonjs/scene";
  12985. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12986. import { Node } from "babylonjs/node";
  12987. /**
  12988. * Class used to store an actual running animation
  12989. */
  12990. export class Animatable {
  12991. /** defines the target object */
  12992. target: any;
  12993. /** defines the starting frame number (default is 0) */
  12994. fromFrame: number;
  12995. /** defines the ending frame number (default is 100) */
  12996. toFrame: number;
  12997. /** defines if the animation must loop (default is false) */
  12998. loopAnimation: boolean;
  12999. /** defines a callback to call when animation ends if it is not looping */
  13000. onAnimationEnd?: (() => void) | null | undefined;
  13001. /** defines a callback to call when animation loops */
  13002. onAnimationLoop?: (() => void) | null | undefined;
  13003. private _localDelayOffset;
  13004. private _pausedDelay;
  13005. private _runtimeAnimations;
  13006. private _paused;
  13007. private _scene;
  13008. private _speedRatio;
  13009. private _weight;
  13010. private _syncRoot;
  13011. /**
  13012. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13013. * This will only apply for non looping animation (default is true)
  13014. */
  13015. disposeOnEnd: boolean;
  13016. /**
  13017. * Gets a boolean indicating if the animation has started
  13018. */
  13019. animationStarted: boolean;
  13020. /**
  13021. * Observer raised when the animation ends
  13022. */
  13023. onAnimationEndObservable: Observable<Animatable>;
  13024. /**
  13025. * Observer raised when the animation loops
  13026. */
  13027. onAnimationLoopObservable: Observable<Animatable>;
  13028. /**
  13029. * Gets the root Animatable used to synchronize and normalize animations
  13030. */
  13031. readonly syncRoot: Nullable<Animatable>;
  13032. /**
  13033. * Gets the current frame of the first RuntimeAnimation
  13034. * Used to synchronize Animatables
  13035. */
  13036. readonly masterFrame: number;
  13037. /**
  13038. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13039. */
  13040. weight: number;
  13041. /**
  13042. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13043. */
  13044. speedRatio: number;
  13045. /**
  13046. * Creates a new Animatable
  13047. * @param scene defines the hosting scene
  13048. * @param target defines the target object
  13049. * @param fromFrame defines the starting frame number (default is 0)
  13050. * @param toFrame defines the ending frame number (default is 100)
  13051. * @param loopAnimation defines if the animation must loop (default is false)
  13052. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13053. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13054. * @param animations defines a group of animation to add to the new Animatable
  13055. * @param onAnimationLoop defines a callback to call when animation loops
  13056. */
  13057. constructor(scene: Scene,
  13058. /** defines the target object */
  13059. target: any,
  13060. /** defines the starting frame number (default is 0) */
  13061. fromFrame?: number,
  13062. /** defines the ending frame number (default is 100) */
  13063. toFrame?: number,
  13064. /** defines if the animation must loop (default is false) */
  13065. loopAnimation?: boolean, speedRatio?: number,
  13066. /** defines a callback to call when animation ends if it is not looping */
  13067. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13068. /** defines a callback to call when animation loops */
  13069. onAnimationLoop?: (() => void) | null | undefined);
  13070. /**
  13071. * Synchronize and normalize current Animatable with a source Animatable
  13072. * This is useful when using animation weights and when animations are not of the same length
  13073. * @param root defines the root Animatable to synchronize with
  13074. * @returns the current Animatable
  13075. */
  13076. syncWith(root: Animatable): Animatable;
  13077. /**
  13078. * Gets the list of runtime animations
  13079. * @returns an array of RuntimeAnimation
  13080. */
  13081. getAnimations(): RuntimeAnimation[];
  13082. /**
  13083. * Adds more animations to the current animatable
  13084. * @param target defines the target of the animations
  13085. * @param animations defines the new animations to add
  13086. */
  13087. appendAnimations(target: any, animations: Animation[]): void;
  13088. /**
  13089. * Gets the source animation for a specific property
  13090. * @param property defines the propertyu to look for
  13091. * @returns null or the source animation for the given property
  13092. */
  13093. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13094. /**
  13095. * Gets the runtime animation for a specific property
  13096. * @param property defines the propertyu to look for
  13097. * @returns null or the runtime animation for the given property
  13098. */
  13099. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13100. /**
  13101. * Resets the animatable to its original state
  13102. */
  13103. reset(): void;
  13104. /**
  13105. * Allows the animatable to blend with current running animations
  13106. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13107. * @param blendingSpeed defines the blending speed to use
  13108. */
  13109. enableBlending(blendingSpeed: number): void;
  13110. /**
  13111. * Disable animation blending
  13112. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13113. */
  13114. disableBlending(): void;
  13115. /**
  13116. * Jump directly to a given frame
  13117. * @param frame defines the frame to jump to
  13118. */
  13119. goToFrame(frame: number): void;
  13120. /**
  13121. * Pause the animation
  13122. */
  13123. pause(): void;
  13124. /**
  13125. * Restart the animation
  13126. */
  13127. restart(): void;
  13128. private _raiseOnAnimationEnd;
  13129. /**
  13130. * Stop and delete the current animation
  13131. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13132. * @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)
  13133. */
  13134. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13135. /**
  13136. * Wait asynchronously for the animation to end
  13137. * @returns a promise which will be fullfilled when the animation ends
  13138. */
  13139. waitAsync(): Promise<Animatable>;
  13140. /** @hidden */
  13141. _animate(delay: number): boolean;
  13142. }
  13143. module "babylonjs/scene" {
  13144. interface Scene {
  13145. /** @hidden */
  13146. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13147. /** @hidden */
  13148. _processLateAnimationBindingsForMatrices(holder: {
  13149. totalWeight: number;
  13150. animations: RuntimeAnimation[];
  13151. originalValue: Matrix;
  13152. }): any;
  13153. /** @hidden */
  13154. _processLateAnimationBindingsForQuaternions(holder: {
  13155. totalWeight: number;
  13156. animations: RuntimeAnimation[];
  13157. originalValue: Quaternion;
  13158. }, refQuaternion: Quaternion): Quaternion;
  13159. /** @hidden */
  13160. _processLateAnimationBindings(): void;
  13161. /**
  13162. * Will start the animation sequence of a given target
  13163. * @param target defines the target
  13164. * @param from defines from which frame should animation start
  13165. * @param to defines until which frame should animation run.
  13166. * @param weight defines the weight to apply to the animation (1.0 by default)
  13167. * @param loop defines if the animation loops
  13168. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13169. * @param onAnimationEnd defines the function to be executed when the animation ends
  13170. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13171. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13172. * @param onAnimationLoop defines the callback to call when an animation loops
  13173. * @returns the animatable object created for this animation
  13174. */
  13175. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13176. /**
  13177. * Will start the animation sequence of a given target
  13178. * @param target defines the target
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the animatable object created for this animation
  13189. */
  13190. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13191. /**
  13192. * Will start the animation sequence of a given target and its hierarchy
  13193. * @param target defines the target
  13194. * @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.
  13195. * @param from defines from which frame should animation start
  13196. * @param to defines until which frame should animation run.
  13197. * @param loop defines if the animation loops
  13198. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13199. * @param onAnimationEnd defines the function to be executed when the animation ends
  13200. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13201. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13202. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13203. * @param onAnimationLoop defines the callback to call when an animation loops
  13204. * @returns the list of created animatables
  13205. */
  13206. 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[];
  13207. /**
  13208. * Begin a new animation on a given node
  13209. * @param target defines the target where the animation will take place
  13210. * @param animations defines the list of animations to start
  13211. * @param from defines the initial value
  13212. * @param to defines the final value
  13213. * @param loop defines if you want animation to loop (off by default)
  13214. * @param speedRatio defines the speed ratio to apply to all animations
  13215. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13216. * @param onAnimationLoop defines the callback to call when an animation loops
  13217. * @returns the list of created animatables
  13218. */
  13219. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13220. /**
  13221. * Begin a new animation on a given node and its hierarchy
  13222. * @param target defines the root node where the animation will take place
  13223. * @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.
  13224. * @param animations defines the list of animations to start
  13225. * @param from defines the initial value
  13226. * @param to defines the final value
  13227. * @param loop defines if you want animation to loop (off by default)
  13228. * @param speedRatio defines the speed ratio to apply to all animations
  13229. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13230. * @param onAnimationLoop defines the callback to call when an animation loops
  13231. * @returns the list of animatables created for all nodes
  13232. */
  13233. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13234. /**
  13235. * Gets the animatable associated with a specific target
  13236. * @param target defines the target of the animatable
  13237. * @returns the required animatable if found
  13238. */
  13239. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13240. /**
  13241. * Gets all animatables associated with a given target
  13242. * @param target defines the target to look animatables for
  13243. * @returns an array of Animatables
  13244. */
  13245. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13246. /**
  13247. * Stops and removes all animations that have been applied to the scene
  13248. */
  13249. stopAllAnimations(): void;
  13250. }
  13251. }
  13252. module "babylonjs/Bones/bone" {
  13253. interface Bone {
  13254. /**
  13255. * Copy an animation range from another bone
  13256. * @param source defines the source bone
  13257. * @param rangeName defines the range name to copy
  13258. * @param frameOffset defines the frame offset
  13259. * @param rescaleAsRequired defines if rescaling must be applied if required
  13260. * @param skelDimensionsRatio defines the scaling ratio
  13261. * @returns true if operation was successful
  13262. */
  13263. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13264. }
  13265. }
  13266. }
  13267. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13268. /**
  13269. * Class used to override all child animations of a given target
  13270. */
  13271. export class AnimationPropertiesOverride {
  13272. /**
  13273. * Gets or sets a value indicating if animation blending must be used
  13274. */
  13275. enableBlending: boolean;
  13276. /**
  13277. * Gets or sets the blending speed to use when enableBlending is true
  13278. */
  13279. blendingSpeed: number;
  13280. /**
  13281. * Gets or sets the default loop mode to use
  13282. */
  13283. loopMode: number;
  13284. }
  13285. }
  13286. declare module "babylonjs/Bones/skeleton" {
  13287. import { Bone } from "babylonjs/Bones/bone";
  13288. import { Observable } from "babylonjs/Misc/observable";
  13289. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Nullable } from "babylonjs/types";
  13292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13293. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13294. import { Animatable } from "babylonjs/Animations/animatable";
  13295. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13296. import { Animation } from "babylonjs/Animations/animation";
  13297. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13298. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13300. /**
  13301. * Class used to handle skinning animations
  13302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13303. */
  13304. export class Skeleton implements IAnimatable {
  13305. /** defines the skeleton name */
  13306. name: string;
  13307. /** defines the skeleton Id */
  13308. id: string;
  13309. /**
  13310. * Defines the list of child bones
  13311. */
  13312. bones: Bone[];
  13313. /**
  13314. * Defines an estimate of the dimension of the skeleton at rest
  13315. */
  13316. dimensionsAtRest: Vector3;
  13317. /**
  13318. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13319. */
  13320. needInitialSkinMatrix: boolean;
  13321. /**
  13322. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13323. */
  13324. overrideMesh: Nullable<AbstractMesh>;
  13325. /**
  13326. * Gets the list of animations attached to this skeleton
  13327. */
  13328. animations: Array<Animation>;
  13329. private _scene;
  13330. private _isDirty;
  13331. private _transformMatrices;
  13332. private _transformMatrixTexture;
  13333. private _meshesWithPoseMatrix;
  13334. private _animatables;
  13335. private _identity;
  13336. private _synchronizedWithMesh;
  13337. private _ranges;
  13338. private _lastAbsoluteTransformsUpdateId;
  13339. private _canUseTextureForBones;
  13340. private _uniqueId;
  13341. /** @hidden */
  13342. _numBonesWithLinkedTransformNode: number;
  13343. /** @hidden */
  13344. _hasWaitingData: Nullable<boolean>;
  13345. /**
  13346. * Specifies if the skeleton should be serialized
  13347. */
  13348. doNotSerialize: boolean;
  13349. private _useTextureToStoreBoneMatrices;
  13350. /**
  13351. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13352. * Please note that this option is not available if the hardware does not support it
  13353. */
  13354. useTextureToStoreBoneMatrices: boolean;
  13355. private _animationPropertiesOverride;
  13356. /**
  13357. * Gets or sets the animation properties override
  13358. */
  13359. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13360. /**
  13361. * List of inspectable custom properties (used by the Inspector)
  13362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13363. */
  13364. inspectableCustomProperties: IInspectable[];
  13365. /**
  13366. * An observable triggered before computing the skeleton's matrices
  13367. */
  13368. onBeforeComputeObservable: Observable<Skeleton>;
  13369. /**
  13370. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13371. */
  13372. readonly isUsingTextureForMatrices: boolean;
  13373. /**
  13374. * Gets the unique ID of this skeleton
  13375. */
  13376. readonly uniqueId: number;
  13377. /**
  13378. * Creates a new skeleton
  13379. * @param name defines the skeleton name
  13380. * @param id defines the skeleton Id
  13381. * @param scene defines the hosting scene
  13382. */
  13383. constructor(
  13384. /** defines the skeleton name */
  13385. name: string,
  13386. /** defines the skeleton Id */
  13387. id: string, scene: Scene);
  13388. /**
  13389. * Gets the current object class name.
  13390. * @return the class name
  13391. */
  13392. getClassName(): string;
  13393. /**
  13394. * Returns an array containing the root bones
  13395. * @returns an array containing the root bones
  13396. */
  13397. getChildren(): Array<Bone>;
  13398. /**
  13399. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13400. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13401. * @returns a Float32Array containing matrices data
  13402. */
  13403. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13404. /**
  13405. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13406. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13407. * @returns a raw texture containing the data
  13408. */
  13409. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13410. /**
  13411. * Gets the current hosting scene
  13412. * @returns a scene object
  13413. */
  13414. getScene(): Scene;
  13415. /**
  13416. * Gets a string representing the current skeleton data
  13417. * @param fullDetails defines a boolean indicating if we want a verbose version
  13418. * @returns a string representing the current skeleton data
  13419. */
  13420. toString(fullDetails?: boolean): string;
  13421. /**
  13422. * Get bone's index searching by name
  13423. * @param name defines bone's name to search for
  13424. * @return the indice of the bone. Returns -1 if not found
  13425. */
  13426. getBoneIndexByName(name: string): number;
  13427. /**
  13428. * Creater a new animation range
  13429. * @param name defines the name of the range
  13430. * @param from defines the start key
  13431. * @param to defines the end key
  13432. */
  13433. createAnimationRange(name: string, from: number, to: number): void;
  13434. /**
  13435. * Delete a specific animation range
  13436. * @param name defines the name of the range
  13437. * @param deleteFrames defines if frames must be removed as well
  13438. */
  13439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13440. /**
  13441. * Gets a specific animation range
  13442. * @param name defines the name of the range to look for
  13443. * @returns the requested animation range or null if not found
  13444. */
  13445. getAnimationRange(name: string): Nullable<AnimationRange>;
  13446. /**
  13447. * Gets the list of all animation ranges defined on this skeleton
  13448. * @returns an array
  13449. */
  13450. getAnimationRanges(): Nullable<AnimationRange>[];
  13451. /**
  13452. * Copy animation range from a source skeleton.
  13453. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13454. * @param source defines the source skeleton
  13455. * @param name defines the name of the range to copy
  13456. * @param rescaleAsRequired defines if rescaling must be applied if required
  13457. * @returns true if operation was successful
  13458. */
  13459. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13460. /**
  13461. * Forces the skeleton to go to rest pose
  13462. */
  13463. returnToRest(): void;
  13464. private _getHighestAnimationFrame;
  13465. /**
  13466. * Begin a specific animation range
  13467. * @param name defines the name of the range to start
  13468. * @param loop defines if looping must be turned on (false by default)
  13469. * @param speedRatio defines the speed ratio to apply (1 by default)
  13470. * @param onAnimationEnd defines a callback which will be called when animation will end
  13471. * @returns a new animatable
  13472. */
  13473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13474. /** @hidden */
  13475. _markAsDirty(): void;
  13476. /** @hidden */
  13477. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13478. /** @hidden */
  13479. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13480. private _computeTransformMatrices;
  13481. /**
  13482. * Build all resources required to render a skeleton
  13483. */
  13484. prepare(): void;
  13485. /**
  13486. * Gets the list of animatables currently running for this skeleton
  13487. * @returns an array of animatables
  13488. */
  13489. getAnimatables(): IAnimatable[];
  13490. /**
  13491. * Clone the current skeleton
  13492. * @param name defines the name of the new skeleton
  13493. * @param id defines the id of the new skeleton
  13494. * @returns the new skeleton
  13495. */
  13496. clone(name: string, id: string): Skeleton;
  13497. /**
  13498. * Enable animation blending for this skeleton
  13499. * @param blendingSpeed defines the blending speed to apply
  13500. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13501. */
  13502. enableBlending(blendingSpeed?: number): void;
  13503. /**
  13504. * Releases all resources associated with the current skeleton
  13505. */
  13506. dispose(): void;
  13507. /**
  13508. * Serialize the skeleton in a JSON object
  13509. * @returns a JSON object
  13510. */
  13511. serialize(): any;
  13512. /**
  13513. * Creates a new skeleton from serialized data
  13514. * @param parsedSkeleton defines the serialized data
  13515. * @param scene defines the hosting scene
  13516. * @returns a new skeleton
  13517. */
  13518. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13519. /**
  13520. * Compute all node absolute transforms
  13521. * @param forceUpdate defines if computation must be done even if cache is up to date
  13522. */
  13523. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13524. /**
  13525. * Gets the root pose matrix
  13526. * @returns a matrix
  13527. */
  13528. getPoseMatrix(): Nullable<Matrix>;
  13529. /**
  13530. * Sorts bones per internal index
  13531. */
  13532. sortBones(): void;
  13533. private _sortBones;
  13534. }
  13535. }
  13536. declare module "babylonjs/Bones/bone" {
  13537. import { Skeleton } from "babylonjs/Bones/skeleton";
  13538. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13539. import { Nullable } from "babylonjs/types";
  13540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13542. import { Node } from "babylonjs/node";
  13543. import { Space } from "babylonjs/Maths/math.axis";
  13544. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13545. /**
  13546. * Class used to store bone information
  13547. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13548. */
  13549. export class Bone extends Node {
  13550. /**
  13551. * defines the bone name
  13552. */
  13553. name: string;
  13554. private static _tmpVecs;
  13555. private static _tmpQuat;
  13556. private static _tmpMats;
  13557. /**
  13558. * Gets the list of child bones
  13559. */
  13560. children: Bone[];
  13561. /** Gets the animations associated with this bone */
  13562. animations: import("babylonjs/Animations/animation").Animation[];
  13563. /**
  13564. * Gets or sets bone length
  13565. */
  13566. length: number;
  13567. /**
  13568. * @hidden Internal only
  13569. * Set this value to map this bone to a different index in the transform matrices
  13570. * Set this value to -1 to exclude the bone from the transform matrices
  13571. */
  13572. _index: Nullable<number>;
  13573. private _skeleton;
  13574. private _localMatrix;
  13575. private _restPose;
  13576. private _baseMatrix;
  13577. private _absoluteTransform;
  13578. private _invertedAbsoluteTransform;
  13579. private _parent;
  13580. private _scalingDeterminant;
  13581. private _worldTransform;
  13582. private _localScaling;
  13583. private _localRotation;
  13584. private _localPosition;
  13585. private _needToDecompose;
  13586. private _needToCompose;
  13587. /** @hidden */
  13588. _linkedTransformNode: Nullable<TransformNode>;
  13589. /** @hidden */
  13590. _waitingTransformNodeId: Nullable<string>;
  13591. /** @hidden */
  13592. /** @hidden */
  13593. _matrix: Matrix;
  13594. /**
  13595. * Create a new bone
  13596. * @param name defines the bone name
  13597. * @param skeleton defines the parent skeleton
  13598. * @param parentBone defines the parent (can be null if the bone is the root)
  13599. * @param localMatrix defines the local matrix
  13600. * @param restPose defines the rest pose matrix
  13601. * @param baseMatrix defines the base matrix
  13602. * @param index defines index of the bone in the hiearchy
  13603. */
  13604. constructor(
  13605. /**
  13606. * defines the bone name
  13607. */
  13608. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13609. /**
  13610. * Gets the current object class name.
  13611. * @return the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Gets the parent skeleton
  13616. * @returns a skeleton
  13617. */
  13618. getSkeleton(): Skeleton;
  13619. /**
  13620. * Gets parent bone
  13621. * @returns a bone or null if the bone is the root of the bone hierarchy
  13622. */
  13623. getParent(): Nullable<Bone>;
  13624. /**
  13625. * Returns an array containing the root bones
  13626. * @returns an array containing the root bones
  13627. */
  13628. getChildren(): Array<Bone>;
  13629. /**
  13630. * Sets the parent bone
  13631. * @param parent defines the parent (can be null if the bone is the root)
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. */
  13634. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13635. /**
  13636. * Gets the local matrix
  13637. * @returns a matrix
  13638. */
  13639. getLocalMatrix(): Matrix;
  13640. /**
  13641. * Gets the base matrix (initial matrix which remains unchanged)
  13642. * @returns a matrix
  13643. */
  13644. getBaseMatrix(): Matrix;
  13645. /**
  13646. * Gets the rest pose matrix
  13647. * @returns a matrix
  13648. */
  13649. getRestPose(): Matrix;
  13650. /**
  13651. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13652. */
  13653. getWorldMatrix(): Matrix;
  13654. /**
  13655. * Sets the local matrix to rest pose matrix
  13656. */
  13657. returnToRest(): void;
  13658. /**
  13659. * Gets the inverse of the absolute transform matrix.
  13660. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13661. * @returns a matrix
  13662. */
  13663. getInvertedAbsoluteTransform(): Matrix;
  13664. /**
  13665. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13666. * @returns a matrix
  13667. */
  13668. getAbsoluteTransform(): Matrix;
  13669. /**
  13670. * Links with the given transform node.
  13671. * The local matrix of this bone is copied from the transform node every frame.
  13672. * @param transformNode defines the transform node to link to
  13673. */
  13674. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13675. /**
  13676. * Gets the node used to drive the bone's transformation
  13677. * @returns a transform node or null
  13678. */
  13679. getTransformNode(): Nullable<TransformNode>;
  13680. /** Gets or sets current position (in local space) */
  13681. position: Vector3;
  13682. /** Gets or sets current rotation (in local space) */
  13683. rotation: Vector3;
  13684. /** Gets or sets current rotation quaternion (in local space) */
  13685. rotationQuaternion: Quaternion;
  13686. /** Gets or sets current scaling (in local space) */
  13687. scaling: Vector3;
  13688. /**
  13689. * Gets the animation properties override
  13690. */
  13691. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. private _decompose;
  13693. private _compose;
  13694. /**
  13695. * Update the base and local matrices
  13696. * @param matrix defines the new base or local matrix
  13697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13698. * @param updateLocalMatrix defines if the local matrix should be updated
  13699. */
  13700. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13701. /** @hidden */
  13702. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13703. /**
  13704. * Flag the bone as dirty (Forcing it to update everything)
  13705. */
  13706. markAsDirty(): void;
  13707. /** @hidden */
  13708. _markAsDirtyAndCompose(): void;
  13709. private _markAsDirtyAndDecompose;
  13710. /**
  13711. * Translate the bone in local or world space
  13712. * @param vec The amount to translate the bone
  13713. * @param space The space that the translation is in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Set the postion of the bone in local or world space
  13719. * @param position The position to set the bone
  13720. * @param space The space that the position is in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. */
  13723. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13724. /**
  13725. * Set the absolute position of the bone (world space)
  13726. * @param position The position to set the bone
  13727. * @param mesh The mesh that this bone is attached to
  13728. */
  13729. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13730. /**
  13731. * Scale the bone on the x, y and z axes (in local space)
  13732. * @param x The amount to scale the bone on the x axis
  13733. * @param y The amount to scale the bone on the y axis
  13734. * @param z The amount to scale the bone on the z axis
  13735. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13736. */
  13737. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13738. /**
  13739. * Set the bone scaling in local space
  13740. * @param scale defines the scaling vector
  13741. */
  13742. setScale(scale: Vector3): void;
  13743. /**
  13744. * Gets the current scaling in local space
  13745. * @returns the current scaling vector
  13746. */
  13747. getScale(): Vector3;
  13748. /**
  13749. * Gets the current scaling in local space and stores it in a target vector
  13750. * @param result defines the target vector
  13751. */
  13752. getScaleToRef(result: Vector3): void;
  13753. /**
  13754. * Set the yaw, pitch, and roll of the bone in local or world space
  13755. * @param yaw The rotation of the bone on the y axis
  13756. * @param pitch The rotation of the bone on the x axis
  13757. * @param roll The rotation of the bone on the z axis
  13758. * @param space The space that the axes of rotation are in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Add a rotation to the bone on an axis in local or world space
  13764. * @param axis The axis to rotate the bone on
  13765. * @param amount The amount to rotate the bone
  13766. * @param space The space that the axis is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the rotation of the bone to a particular axis angle in local or world space
  13772. * @param axis The axis to rotate the bone on
  13773. * @param angle The angle that the bone should be rotated to
  13774. * @param space The space that the axis is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13778. /**
  13779. * Set the euler rotation of the bone in local of world space
  13780. * @param rotation The euler rotation that the bone should be set to
  13781. * @param space The space that the rotation is in
  13782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13783. */
  13784. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13785. /**
  13786. * Set the quaternion rotation of the bone in local of world space
  13787. * @param quat The quaternion rotation that the bone should be set to
  13788. * @param space The space that the rotation is in
  13789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13790. */
  13791. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13792. /**
  13793. * Set the rotation matrix of the bone in local of world space
  13794. * @param rotMat The rotation matrix that the bone should be set to
  13795. * @param space The space that the rotation is in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13799. private _rotateWithMatrix;
  13800. private _getNegativeRotationToRef;
  13801. /**
  13802. * Get the position of the bone in local or world space
  13803. * @param space The space that the returned position is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @returns The position of the bone
  13806. */
  13807. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13808. /**
  13809. * Copy the position of the bone to a vector3 in local or world space
  13810. * @param space The space that the returned position is in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @param result The vector3 to copy the position to
  13813. */
  13814. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13815. /**
  13816. * Get the absolute position of the bone (world space)
  13817. * @param mesh The mesh that this bone is attached to
  13818. * @returns The absolute position of the bone
  13819. */
  13820. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13821. /**
  13822. * Copy the absolute position of the bone (world space) to the result param
  13823. * @param mesh The mesh that this bone is attached to
  13824. * @param result The vector3 to copy the absolute position to
  13825. */
  13826. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13827. /**
  13828. * Compute the absolute transforms of this bone and its children
  13829. */
  13830. computeAbsoluteTransforms(): void;
  13831. /**
  13832. * Get the world direction from an axis that is in the local space of the bone
  13833. * @param localAxis The local direction that is used to compute the world direction
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The world direction
  13836. */
  13837. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13840. * @param localAxis The local direction that is used to compute the world direction
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the world direction will be copied to
  13843. */
  13844. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. /**
  13846. * Get the euler rotation of the bone in local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @returns The euler rotation
  13850. */
  13851. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13852. /**
  13853. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @param result The vector3 that the rotation should be copied to
  13857. */
  13858. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13859. /**
  13860. * Get the quaternion rotation of the bone in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @returns The quaternion rotation
  13864. */
  13865. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13866. /**
  13867. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13868. * @param space The space that the rotation should be in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. * @param result The quaternion that the rotation should be copied to
  13871. */
  13872. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13873. /**
  13874. * Get the rotation matrix of the bone in local or world space
  13875. * @param space The space that the rotation should be in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. * @returns The rotation matrix
  13878. */
  13879. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13880. /**
  13881. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13882. * @param space The space that the rotation should be in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. * @param result The quaternion that the rotation should be copied to
  13885. */
  13886. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13887. /**
  13888. * Get the world position of a point that is in the local space of the bone
  13889. * @param position The local position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @returns The world position
  13892. */
  13893. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13896. * @param position The local position
  13897. * @param mesh The mesh that this bone is attached to
  13898. * @param result The vector3 that the world position should be copied to
  13899. */
  13900. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the local position of a point that is in world space
  13903. * @param position The world position
  13904. * @param mesh The mesh that this bone is attached to
  13905. * @returns The local position
  13906. */
  13907. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13908. /**
  13909. * Get the local position of a point that is in world space and copy it to the result param
  13910. * @param position The world position
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 that the local position should be copied to
  13913. */
  13914. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13915. }
  13916. }
  13917. declare module "babylonjs/Meshes/transformNode" {
  13918. import { DeepImmutable } from "babylonjs/types";
  13919. import { Observable } from "babylonjs/Misc/observable";
  13920. import { Nullable } from "babylonjs/types";
  13921. import { Camera } from "babylonjs/Cameras/camera";
  13922. import { Scene } from "babylonjs/scene";
  13923. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13924. import { Node } from "babylonjs/node";
  13925. import { Bone } from "babylonjs/Bones/bone";
  13926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13927. import { Space } from "babylonjs/Maths/math.axis";
  13928. /**
  13929. * 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.
  13930. * @see https://doc.babylonjs.com/how_to/transformnode
  13931. */
  13932. export class TransformNode extends Node {
  13933. /**
  13934. * Object will not rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_NONE: number;
  13937. /**
  13938. * Object will rotate to face the camera but only on the x axis
  13939. */
  13940. static BILLBOARDMODE_X: number;
  13941. /**
  13942. * Object will rotate to face the camera but only on the y axis
  13943. */
  13944. static BILLBOARDMODE_Y: number;
  13945. /**
  13946. * Object will rotate to face the camera but only on the z axis
  13947. */
  13948. static BILLBOARDMODE_Z: number;
  13949. /**
  13950. * Object will rotate to face the camera
  13951. */
  13952. static BILLBOARDMODE_ALL: number;
  13953. /**
  13954. * Object will rotate to face the camera's position instead of orientation
  13955. */
  13956. static BILLBOARDMODE_USE_POSITION: number;
  13957. private _forward;
  13958. private _forwardInverted;
  13959. private _up;
  13960. private _right;
  13961. private _rightInverted;
  13962. private _position;
  13963. private _rotation;
  13964. private _rotationQuaternion;
  13965. protected _scaling: Vector3;
  13966. protected _isDirty: boolean;
  13967. private _transformToBoneReferal;
  13968. private _isAbsoluteSynced;
  13969. private _billboardMode;
  13970. /**
  13971. * Gets or sets the billboard mode. Default is 0.
  13972. *
  13973. * | Value | Type | Description |
  13974. * | --- | --- | --- |
  13975. * | 0 | BILLBOARDMODE_NONE | |
  13976. * | 1 | BILLBOARDMODE_X | |
  13977. * | 2 | BILLBOARDMODE_Y | |
  13978. * | 4 | BILLBOARDMODE_Z | |
  13979. * | 7 | BILLBOARDMODE_ALL | |
  13980. *
  13981. */
  13982. billboardMode: number;
  13983. private _preserveParentRotationForBillboard;
  13984. /**
  13985. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13986. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13987. */
  13988. preserveParentRotationForBillboard: boolean;
  13989. /**
  13990. * 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
  13991. */
  13992. scalingDeterminant: number;
  13993. private _infiniteDistance;
  13994. /**
  13995. * Gets or sets the distance of the object to max, often used by skybox
  13996. */
  13997. infiniteDistance: boolean;
  13998. /**
  13999. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14000. * By default the system will update normals to compensate
  14001. */
  14002. ignoreNonUniformScaling: boolean;
  14003. /**
  14004. * 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
  14005. */
  14006. reIntegrateRotationIntoRotationQuaternion: boolean;
  14007. /** @hidden */
  14008. _poseMatrix: Nullable<Matrix>;
  14009. /** @hidden */
  14010. _localMatrix: Matrix;
  14011. private _usePivotMatrix;
  14012. private _absolutePosition;
  14013. private _absoluteScaling;
  14014. private _absoluteRotationQuaternion;
  14015. private _pivotMatrix;
  14016. private _pivotMatrixInverse;
  14017. protected _postMultiplyPivotMatrix: boolean;
  14018. protected _isWorldMatrixFrozen: boolean;
  14019. /** @hidden */
  14020. _indexInSceneTransformNodesArray: number;
  14021. /**
  14022. * An event triggered after the world matrix is updated
  14023. */
  14024. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14025. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14026. /**
  14027. * Gets a string identifying the name of the class
  14028. * @returns "TransformNode" string
  14029. */
  14030. getClassName(): string;
  14031. /**
  14032. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14033. */
  14034. position: Vector3;
  14035. /**
  14036. * 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)).
  14037. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14038. */
  14039. rotation: Vector3;
  14040. /**
  14041. * 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)).
  14042. */
  14043. scaling: Vector3;
  14044. /**
  14045. * 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).
  14046. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14047. */
  14048. rotationQuaternion: Nullable<Quaternion>;
  14049. /**
  14050. * The forward direction of that transform in world space.
  14051. */
  14052. readonly forward: Vector3;
  14053. /**
  14054. * The up direction of that transform in world space.
  14055. */
  14056. readonly up: Vector3;
  14057. /**
  14058. * The right direction of that transform in world space.
  14059. */
  14060. readonly right: Vector3;
  14061. /**
  14062. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14063. * @param matrix the matrix to copy the pose from
  14064. * @returns this TransformNode.
  14065. */
  14066. updatePoseMatrix(matrix: Matrix): TransformNode;
  14067. /**
  14068. * Returns the mesh Pose matrix.
  14069. * @returns the pose matrix
  14070. */
  14071. getPoseMatrix(): Matrix;
  14072. /** @hidden */
  14073. _isSynchronized(): boolean;
  14074. /** @hidden */
  14075. _initCache(): void;
  14076. /**
  14077. * Flag the transform node as dirty (Forcing it to update everything)
  14078. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14079. * @returns this transform node
  14080. */
  14081. markAsDirty(property: string): TransformNode;
  14082. /**
  14083. * Returns the current mesh absolute position.
  14084. * Returns a Vector3.
  14085. */
  14086. readonly absolutePosition: Vector3;
  14087. /**
  14088. * Returns the current mesh absolute scaling.
  14089. * Returns a Vector3.
  14090. */
  14091. readonly absoluteScaling: Vector3;
  14092. /**
  14093. * Returns the current mesh absolute rotation.
  14094. * Returns a Quaternion.
  14095. */
  14096. readonly absoluteRotationQuaternion: Quaternion;
  14097. /**
  14098. * Sets a new matrix to apply before all other transformation
  14099. * @param matrix defines the transform matrix
  14100. * @returns the current TransformNode
  14101. */
  14102. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14103. /**
  14104. * Sets a new pivot matrix to the current node
  14105. * @param matrix defines the new pivot matrix to use
  14106. * @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
  14107. * @returns the current TransformNode
  14108. */
  14109. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14110. /**
  14111. * Returns the mesh pivot matrix.
  14112. * Default : Identity.
  14113. * @returns the matrix
  14114. */
  14115. getPivotMatrix(): Matrix;
  14116. /**
  14117. * Prevents the World matrix to be computed any longer.
  14118. * @returns the TransformNode.
  14119. */
  14120. freezeWorldMatrix(): TransformNode;
  14121. /**
  14122. * Allows back the World matrix computation.
  14123. * @returns the TransformNode.
  14124. */
  14125. unfreezeWorldMatrix(): this;
  14126. /**
  14127. * True if the World matrix has been frozen.
  14128. */
  14129. readonly isWorldMatrixFrozen: boolean;
  14130. /**
  14131. * Retuns the mesh absolute position in the World.
  14132. * @returns a Vector3.
  14133. */
  14134. getAbsolutePosition(): Vector3;
  14135. /**
  14136. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14137. * @param absolutePosition the absolute position to set
  14138. * @returns the TransformNode.
  14139. */
  14140. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14141. /**
  14142. * Sets the mesh position in its local space.
  14143. * @param vector3 the position to set in localspace
  14144. * @returns the TransformNode.
  14145. */
  14146. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14147. /**
  14148. * Returns the mesh position in the local space from the current World matrix values.
  14149. * @returns a new Vector3.
  14150. */
  14151. getPositionExpressedInLocalSpace(): Vector3;
  14152. /**
  14153. * Translates the mesh along the passed Vector3 in its local space.
  14154. * @param vector3 the distance to translate in localspace
  14155. * @returns the TransformNode.
  14156. */
  14157. locallyTranslate(vector3: Vector3): TransformNode;
  14158. private static _lookAtVectorCache;
  14159. /**
  14160. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14161. * @param targetPoint the position (must be in same space as current mesh) to look at
  14162. * @param yawCor optional yaw (y-axis) correction in radians
  14163. * @param pitchCor optional pitch (x-axis) correction in radians
  14164. * @param rollCor optional roll (z-axis) correction in radians
  14165. * @param space the choosen space of the target
  14166. * @returns the TransformNode.
  14167. */
  14168. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14169. /**
  14170. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14171. * This Vector3 is expressed in the World space.
  14172. * @param localAxis axis to rotate
  14173. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14174. */
  14175. getDirection(localAxis: Vector3): Vector3;
  14176. /**
  14177. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14178. * localAxis is expressed in the mesh local space.
  14179. * result is computed in the Wordl space from the mesh World matrix.
  14180. * @param localAxis axis to rotate
  14181. * @param result the resulting transformnode
  14182. * @returns this TransformNode.
  14183. */
  14184. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14185. /**
  14186. * Sets this transform node rotation to the given local axis.
  14187. * @param localAxis the axis in local space
  14188. * @param yawCor optional yaw (y-axis) correction in radians
  14189. * @param pitchCor optional pitch (x-axis) correction in radians
  14190. * @param rollCor optional roll (z-axis) correction in radians
  14191. * @returns this TransformNode
  14192. */
  14193. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14194. /**
  14195. * Sets a new pivot point to the current node
  14196. * @param point defines the new pivot point to use
  14197. * @param space defines if the point is in world or local space (local by default)
  14198. * @returns the current TransformNode
  14199. */
  14200. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14201. /**
  14202. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14203. * @returns the pivot point
  14204. */
  14205. getPivotPoint(): Vector3;
  14206. /**
  14207. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14208. * @param result the vector3 to store the result
  14209. * @returns this TransformNode.
  14210. */
  14211. getPivotPointToRef(result: Vector3): TransformNode;
  14212. /**
  14213. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14214. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14215. */
  14216. getAbsolutePivotPoint(): Vector3;
  14217. /**
  14218. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14219. * @param result vector3 to store the result
  14220. * @returns this TransformNode.
  14221. */
  14222. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14223. /**
  14224. * Defines the passed node as the parent of the current node.
  14225. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14226. * @see https://doc.babylonjs.com/how_to/parenting
  14227. * @param node the node ot set as the parent
  14228. * @returns this TransformNode.
  14229. */
  14230. setParent(node: Nullable<Node>): TransformNode;
  14231. private _nonUniformScaling;
  14232. /**
  14233. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14234. */
  14235. readonly nonUniformScaling: boolean;
  14236. /** @hidden */
  14237. _updateNonUniformScalingState(value: boolean): boolean;
  14238. /**
  14239. * Attach the current TransformNode to another TransformNode associated with a bone
  14240. * @param bone Bone affecting the TransformNode
  14241. * @param affectedTransformNode TransformNode associated with the bone
  14242. * @returns this object
  14243. */
  14244. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14245. /**
  14246. * Detach the transform node if its associated with a bone
  14247. * @returns this object
  14248. */
  14249. detachFromBone(): TransformNode;
  14250. private static _rotationAxisCache;
  14251. /**
  14252. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14254. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14255. * The passed axis is also normalized.
  14256. * @param axis the axis to rotate around
  14257. * @param amount the amount to rotate in radians
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14262. /**
  14263. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14264. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14265. * The passed axis is also normalized. .
  14266. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14267. * @param point the point to rotate around
  14268. * @param axis the axis to rotate around
  14269. * @param amount the amount to rotate in radians
  14270. * @returns the TransformNode
  14271. */
  14272. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14273. /**
  14274. * Translates the mesh along the axis vector for the passed distance in the given space.
  14275. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14276. * @param axis the axis to translate in
  14277. * @param distance the distance to translate
  14278. * @param space Space to rotate in (Default: local)
  14279. * @returns the TransformNode.
  14280. */
  14281. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14282. /**
  14283. * Adds a rotation step to the mesh current rotation.
  14284. * x, y, z are Euler angles expressed in radians.
  14285. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14286. * This means this rotation is made in the mesh local space only.
  14287. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14288. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14289. * ```javascript
  14290. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14291. * ```
  14292. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14293. * 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.
  14294. * @param x Rotation to add
  14295. * @param y Rotation to add
  14296. * @param z Rotation to add
  14297. * @returns the TransformNode.
  14298. */
  14299. addRotation(x: number, y: number, z: number): TransformNode;
  14300. /**
  14301. * @hidden
  14302. */
  14303. protected _getEffectiveParent(): Nullable<Node>;
  14304. /**
  14305. * Computes the world matrix of the node
  14306. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14307. * @returns the world matrix
  14308. */
  14309. computeWorldMatrix(force?: boolean): Matrix;
  14310. protected _afterComputeWorldMatrix(): void;
  14311. /**
  14312. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14313. * @param func callback function to add
  14314. *
  14315. * @returns the TransformNode.
  14316. */
  14317. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14318. /**
  14319. * Removes a registered callback function.
  14320. * @param func callback function to remove
  14321. * @returns the TransformNode.
  14322. */
  14323. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14324. /**
  14325. * Gets the position of the current mesh in camera space
  14326. * @param camera defines the camera to use
  14327. * @returns a position
  14328. */
  14329. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14330. /**
  14331. * Returns the distance from the mesh to the active camera
  14332. * @param camera defines the camera to use
  14333. * @returns the distance
  14334. */
  14335. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14336. /**
  14337. * Clone the current transform node
  14338. * @param name Name of the new clone
  14339. * @param newParent New parent for the clone
  14340. * @param doNotCloneChildren Do not clone children hierarchy
  14341. * @returns the new transform node
  14342. */
  14343. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14344. /**
  14345. * Serializes the objects information.
  14346. * @param currentSerializationObject defines the object to serialize in
  14347. * @returns the serialized object
  14348. */
  14349. serialize(currentSerializationObject?: any): any;
  14350. /**
  14351. * Returns a new TransformNode object parsed from the source provided.
  14352. * @param parsedTransformNode is the source.
  14353. * @param scene the scne the object belongs to
  14354. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14355. * @returns a new TransformNode object parsed from the source provided.
  14356. */
  14357. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14358. /**
  14359. * Get all child-transformNodes of this node
  14360. * @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
  14361. * @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
  14362. * @returns an array of TransformNode
  14363. */
  14364. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14365. /**
  14366. * Releases resources associated with this transform node.
  14367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14369. */
  14370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14371. /**
  14372. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14373. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14374. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14375. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14376. * @returns the current mesh
  14377. */
  14378. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14379. private _syncAbsoluteScalingAndRotation;
  14380. }
  14381. }
  14382. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14383. import { Observable } from "babylonjs/Misc/observable";
  14384. import { Nullable } from "babylonjs/types";
  14385. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14388. import { Ray } from "babylonjs/Culling/ray";
  14389. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14390. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14391. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14392. /**
  14393. * Defines the types of pose enabled controllers that are supported
  14394. */
  14395. export enum PoseEnabledControllerType {
  14396. /**
  14397. * HTC Vive
  14398. */
  14399. VIVE = 0,
  14400. /**
  14401. * Oculus Rift
  14402. */
  14403. OCULUS = 1,
  14404. /**
  14405. * Windows mixed reality
  14406. */
  14407. WINDOWS = 2,
  14408. /**
  14409. * Samsung gear VR
  14410. */
  14411. GEAR_VR = 3,
  14412. /**
  14413. * Google Daydream
  14414. */
  14415. DAYDREAM = 4,
  14416. /**
  14417. * Generic
  14418. */
  14419. GENERIC = 5
  14420. }
  14421. /**
  14422. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14423. */
  14424. export interface MutableGamepadButton {
  14425. /**
  14426. * Value of the button/trigger
  14427. */
  14428. value: number;
  14429. /**
  14430. * If the button/trigger is currently touched
  14431. */
  14432. touched: boolean;
  14433. /**
  14434. * If the button/trigger is currently pressed
  14435. */
  14436. pressed: boolean;
  14437. }
  14438. /**
  14439. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14440. * @hidden
  14441. */
  14442. export interface ExtendedGamepadButton extends GamepadButton {
  14443. /**
  14444. * If the button/trigger is currently pressed
  14445. */
  14446. readonly pressed: boolean;
  14447. /**
  14448. * If the button/trigger is currently touched
  14449. */
  14450. readonly touched: boolean;
  14451. /**
  14452. * Value of the button/trigger
  14453. */
  14454. readonly value: number;
  14455. }
  14456. /** @hidden */
  14457. export interface _GamePadFactory {
  14458. /**
  14459. * Returns wether or not the current gamepad can be created for this type of controller.
  14460. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14461. * @returns true if it can be created, otherwise false
  14462. */
  14463. canCreate(gamepadInfo: any): boolean;
  14464. /**
  14465. * Creates a new instance of the Gamepad.
  14466. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14467. * @returns the new gamepad instance
  14468. */
  14469. create(gamepadInfo: any): Gamepad;
  14470. }
  14471. /**
  14472. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14473. */
  14474. export class PoseEnabledControllerHelper {
  14475. /** @hidden */
  14476. static _ControllerFactories: _GamePadFactory[];
  14477. /** @hidden */
  14478. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14479. /**
  14480. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14481. * @param vrGamepad the gamepad to initialized
  14482. * @returns a vr controller of the type the gamepad identified as
  14483. */
  14484. static InitiateController(vrGamepad: any): Gamepad;
  14485. }
  14486. /**
  14487. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14488. */
  14489. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14490. /**
  14491. * If the controller is used in a webXR session
  14492. */
  14493. isXR: boolean;
  14494. private _deviceRoomPosition;
  14495. private _deviceRoomRotationQuaternion;
  14496. /**
  14497. * The device position in babylon space
  14498. */
  14499. devicePosition: Vector3;
  14500. /**
  14501. * The device rotation in babylon space
  14502. */
  14503. deviceRotationQuaternion: Quaternion;
  14504. /**
  14505. * The scale factor of the device in babylon space
  14506. */
  14507. deviceScaleFactor: number;
  14508. /**
  14509. * (Likely devicePosition should be used instead) The device position in its room space
  14510. */
  14511. position: Vector3;
  14512. /**
  14513. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14514. */
  14515. rotationQuaternion: Quaternion;
  14516. /**
  14517. * The type of controller (Eg. Windows mixed reality)
  14518. */
  14519. controllerType: PoseEnabledControllerType;
  14520. protected _calculatedPosition: Vector3;
  14521. private _calculatedRotation;
  14522. /**
  14523. * The raw pose from the device
  14524. */
  14525. rawPose: DevicePose;
  14526. private _trackPosition;
  14527. private _maxRotationDistFromHeadset;
  14528. private _draggedRoomRotation;
  14529. /**
  14530. * @hidden
  14531. */
  14532. _disableTrackPosition(fixedPosition: Vector3): void;
  14533. /**
  14534. * Internal, the mesh attached to the controller
  14535. * @hidden
  14536. */
  14537. _mesh: Nullable<AbstractMesh>;
  14538. private _poseControlledCamera;
  14539. private _leftHandSystemQuaternion;
  14540. /**
  14541. * Internal, matrix used to convert room space to babylon space
  14542. * @hidden
  14543. */
  14544. _deviceToWorld: Matrix;
  14545. /**
  14546. * Node to be used when casting a ray from the controller
  14547. * @hidden
  14548. */
  14549. _pointingPoseNode: Nullable<TransformNode>;
  14550. /**
  14551. * Name of the child mesh that can be used to cast a ray from the controller
  14552. */
  14553. static readonly POINTING_POSE: string;
  14554. /**
  14555. * Creates a new PoseEnabledController from a gamepad
  14556. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14557. */
  14558. constructor(browserGamepad: any);
  14559. private _workingMatrix;
  14560. /**
  14561. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14562. */
  14563. update(): void;
  14564. /**
  14565. * Updates only the pose device and mesh without doing any button event checking
  14566. */
  14567. protected _updatePoseAndMesh(): void;
  14568. /**
  14569. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14570. * @param poseData raw pose fromthe device
  14571. */
  14572. updateFromDevice(poseData: DevicePose): void;
  14573. /**
  14574. * @hidden
  14575. */
  14576. _meshAttachedObservable: Observable<AbstractMesh>;
  14577. /**
  14578. * Attaches a mesh to the controller
  14579. * @param mesh the mesh to be attached
  14580. */
  14581. attachToMesh(mesh: AbstractMesh): void;
  14582. /**
  14583. * Attaches the controllers mesh to a camera
  14584. * @param camera the camera the mesh should be attached to
  14585. */
  14586. attachToPoseControlledCamera(camera: TargetCamera): void;
  14587. /**
  14588. * Disposes of the controller
  14589. */
  14590. dispose(): void;
  14591. /**
  14592. * The mesh that is attached to the controller
  14593. */
  14594. readonly mesh: Nullable<AbstractMesh>;
  14595. /**
  14596. * Gets the ray of the controller in the direction the controller is pointing
  14597. * @param length the length the resulting ray should be
  14598. * @returns a ray in the direction the controller is pointing
  14599. */
  14600. getForwardRay(length?: number): Ray;
  14601. }
  14602. }
  14603. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14604. import { Observable } from "babylonjs/Misc/observable";
  14605. import { Scene } from "babylonjs/scene";
  14606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14607. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14608. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14609. /**
  14610. * Defines the WebVRController object that represents controllers tracked in 3D space
  14611. */
  14612. export abstract class WebVRController extends PoseEnabledController {
  14613. /**
  14614. * Internal, the default controller model for the controller
  14615. */
  14616. protected _defaultModel: AbstractMesh;
  14617. /**
  14618. * Fired when the trigger state has changed
  14619. */
  14620. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14621. /**
  14622. * Fired when the main button state has changed
  14623. */
  14624. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14625. /**
  14626. * Fired when the secondary button state has changed
  14627. */
  14628. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14629. /**
  14630. * Fired when the pad state has changed
  14631. */
  14632. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14633. /**
  14634. * Fired when controllers stick values have changed
  14635. */
  14636. onPadValuesChangedObservable: Observable<StickValues>;
  14637. /**
  14638. * Array of button availible on the controller
  14639. */
  14640. protected _buttons: Array<MutableGamepadButton>;
  14641. private _onButtonStateChange;
  14642. /**
  14643. * Fired when a controller button's state has changed
  14644. * @param callback the callback containing the button that was modified
  14645. */
  14646. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14647. /**
  14648. * X and Y axis corresponding to the controllers joystick
  14649. */
  14650. pad: StickValues;
  14651. /**
  14652. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14653. */
  14654. hand: string;
  14655. /**
  14656. * The default controller model for the controller
  14657. */
  14658. readonly defaultModel: AbstractMesh;
  14659. /**
  14660. * Creates a new WebVRController from a gamepad
  14661. * @param vrGamepad the gamepad that the WebVRController should be created from
  14662. */
  14663. constructor(vrGamepad: any);
  14664. /**
  14665. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14666. */
  14667. update(): void;
  14668. /**
  14669. * Function to be called when a button is modified
  14670. */
  14671. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14672. /**
  14673. * Loads a mesh and attaches it to the controller
  14674. * @param scene the scene the mesh should be added to
  14675. * @param meshLoaded callback for when the mesh has been loaded
  14676. */
  14677. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14678. private _setButtonValue;
  14679. private _changes;
  14680. private _checkChanges;
  14681. /**
  14682. * Disposes of th webVRCOntroller
  14683. */
  14684. dispose(): void;
  14685. }
  14686. }
  14687. declare module "babylonjs/Lights/hemisphericLight" {
  14688. import { Nullable } from "babylonjs/types";
  14689. import { Scene } from "babylonjs/scene";
  14690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14691. import { Color3 } from "babylonjs/Maths/math.color";
  14692. import { Effect } from "babylonjs/Materials/effect";
  14693. import { Light } from "babylonjs/Lights/light";
  14694. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14695. /**
  14696. * The HemisphericLight simulates the ambient environment light,
  14697. * so the passed direction is the light reflection direction, not the incoming direction.
  14698. */
  14699. export class HemisphericLight extends Light {
  14700. /**
  14701. * The groundColor is the light in the opposite direction to the one specified during creation.
  14702. * 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.
  14703. */
  14704. groundColor: Color3;
  14705. /**
  14706. * The light reflection direction, not the incoming direction.
  14707. */
  14708. direction: Vector3;
  14709. /**
  14710. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14711. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14712. * The HemisphericLight can't cast shadows.
  14713. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14714. * @param name The friendly name of the light
  14715. * @param direction The direction of the light reflection
  14716. * @param scene The scene the light belongs to
  14717. */
  14718. constructor(name: string, direction: Vector3, scene: Scene);
  14719. protected _buildUniformLayout(): void;
  14720. /**
  14721. * Returns the string "HemisphericLight".
  14722. * @return The class name
  14723. */
  14724. getClassName(): string;
  14725. /**
  14726. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14727. * Returns the updated direction.
  14728. * @param target The target the direction should point to
  14729. * @return The computed direction
  14730. */
  14731. setDirectionToTarget(target: Vector3): Vector3;
  14732. /**
  14733. * Returns the shadow generator associated to the light.
  14734. * @returns Always null for hemispheric lights because it does not support shadows.
  14735. */
  14736. getShadowGenerator(): Nullable<IShadowGenerator>;
  14737. /**
  14738. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14739. * @param effect The effect to update
  14740. * @param lightIndex The index of the light in the effect to update
  14741. * @returns The hemispheric light
  14742. */
  14743. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14744. /**
  14745. * Computes the world matrix of the node
  14746. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14747. * @param useWasUpdatedFlag defines a reserved property
  14748. * @returns the world matrix
  14749. */
  14750. computeWorldMatrix(): Matrix;
  14751. /**
  14752. * Returns the integer 3.
  14753. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14754. */
  14755. getTypeID(): number;
  14756. /**
  14757. * Prepares the list of defines specific to the light type.
  14758. * @param defines the list of defines
  14759. * @param lightIndex defines the index of the light for the effect
  14760. */
  14761. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14762. }
  14763. }
  14764. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14765. /** @hidden */
  14766. export var vrMultiviewToSingleviewPixelShader: {
  14767. name: string;
  14768. shader: string;
  14769. };
  14770. }
  14771. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14773. import { Scene } from "babylonjs/scene";
  14774. /**
  14775. * Renders to multiple views with a single draw call
  14776. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14777. */
  14778. export class MultiviewRenderTarget extends RenderTargetTexture {
  14779. /**
  14780. * Creates a multiview render target
  14781. * @param scene scene used with the render target
  14782. * @param size the size of the render target (used for each view)
  14783. */
  14784. constructor(scene: Scene, size?: number | {
  14785. width: number;
  14786. height: number;
  14787. } | {
  14788. ratio: number;
  14789. });
  14790. /**
  14791. * @hidden
  14792. * @param faceIndex the face index, if its a cube texture
  14793. */
  14794. _bindFrameBuffer(faceIndex?: number): void;
  14795. /**
  14796. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14797. * @returns the view count
  14798. */
  14799. getViewCount(): number;
  14800. }
  14801. }
  14802. declare module "babylonjs/Maths/math.frustum" {
  14803. import { Matrix } from "babylonjs/Maths/math.vector";
  14804. import { DeepImmutable } from "babylonjs/types";
  14805. import { Plane } from "babylonjs/Maths/math.plane";
  14806. /**
  14807. * Reprasents a camera frustum
  14808. */
  14809. export class Frustum {
  14810. /**
  14811. * Gets the planes representing the frustum
  14812. * @param transform matrix to be applied to the returned planes
  14813. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14814. */
  14815. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14816. /**
  14817. * Gets the near frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the far frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Gets the left frustum plane transformed by the transform matrix
  14830. * @param transform transformation matrix to be applied to the resulting frustum plane
  14831. * @param frustumPlane the resuling frustum plane
  14832. */
  14833. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14834. /**
  14835. * Gets the right frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Gets the top frustum plane transformed by the transform matrix
  14842. * @param transform transformation matrix to be applied to the resulting frustum plane
  14843. * @param frustumPlane the resuling frustum plane
  14844. */
  14845. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14846. /**
  14847. * Gets the bottom frustum plane transformed by the transform matrix
  14848. * @param transform transformation matrix to be applied to the resulting frustum plane
  14849. * @param frustumPlane the resuling frustum plane
  14850. */
  14851. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14852. /**
  14853. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14854. * @param transform transformation matrix to be applied to the resulting frustum planes
  14855. * @param frustumPlanes the resuling frustum planes
  14856. */
  14857. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14858. }
  14859. }
  14860. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14861. import { Camera } from "babylonjs/Cameras/camera";
  14862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14863. import { Nullable } from "babylonjs/types";
  14864. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14865. import { Matrix } from "babylonjs/Maths/math.vector";
  14866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14867. module "babylonjs/Engines/engine" {
  14868. interface Engine {
  14869. /**
  14870. * Creates a new multiview render target
  14871. * @param width defines the width of the texture
  14872. * @param height defines the height of the texture
  14873. * @returns the created multiview texture
  14874. */
  14875. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14876. /**
  14877. * Binds a multiview framebuffer to be drawn to
  14878. * @param multiviewTexture texture to bind
  14879. */
  14880. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14881. }
  14882. }
  14883. module "babylonjs/Cameras/camera" {
  14884. interface Camera {
  14885. /**
  14886. * @hidden
  14887. * 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)
  14888. */
  14889. _useMultiviewToSingleView: boolean;
  14890. /**
  14891. * @hidden
  14892. * 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)
  14893. */
  14894. _multiviewTexture: Nullable<RenderTargetTexture>;
  14895. /**
  14896. * @hidden
  14897. * ensures the multiview texture of the camera exists and has the specified width/height
  14898. * @param width height to set on the multiview texture
  14899. * @param height width to set on the multiview texture
  14900. */
  14901. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14902. }
  14903. }
  14904. module "babylonjs/scene" {
  14905. interface Scene {
  14906. /** @hidden */
  14907. _transformMatrixR: Matrix;
  14908. /** @hidden */
  14909. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14910. /** @hidden */
  14911. _createMultiviewUbo(): void;
  14912. /** @hidden */
  14913. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14914. /** @hidden */
  14915. _renderMultiviewToSingleView(camera: Camera): void;
  14916. }
  14917. }
  14918. }
  14919. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14920. import { Camera } from "babylonjs/Cameras/camera";
  14921. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14922. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14923. import "babylonjs/Engines/Extensions/engine.multiview";
  14924. /**
  14925. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14926. * This will not be used for webXR as it supports displaying texture arrays directly
  14927. */
  14928. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14929. /**
  14930. * Initializes a VRMultiviewToSingleview
  14931. * @param name name of the post process
  14932. * @param camera camera to be applied to
  14933. * @param scaleFactor scaling factor to the size of the output texture
  14934. */
  14935. constructor(name: string, camera: Camera, scaleFactor: number);
  14936. }
  14937. }
  14938. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14939. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14940. import { Nullable } from "babylonjs/types";
  14941. import { Size } from "babylonjs/Maths/math.size";
  14942. import { Observable } from "babylonjs/Misc/observable";
  14943. module "babylonjs/Engines/engine" {
  14944. interface Engine {
  14945. /** @hidden */
  14946. _vrDisplay: any;
  14947. /** @hidden */
  14948. _vrSupported: boolean;
  14949. /** @hidden */
  14950. _oldSize: Size;
  14951. /** @hidden */
  14952. _oldHardwareScaleFactor: number;
  14953. /** @hidden */
  14954. _vrExclusivePointerMode: boolean;
  14955. /** @hidden */
  14956. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14957. /** @hidden */
  14958. _onVRDisplayPointerRestricted: () => void;
  14959. /** @hidden */
  14960. _onVRDisplayPointerUnrestricted: () => void;
  14961. /** @hidden */
  14962. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14963. /** @hidden */
  14964. _onVrDisplayDisconnect: Nullable<() => void>;
  14965. /** @hidden */
  14966. _onVrDisplayPresentChange: Nullable<() => void>;
  14967. /**
  14968. * Observable signaled when VR display mode changes
  14969. */
  14970. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14971. /**
  14972. * Observable signaled when VR request present is complete
  14973. */
  14974. onVRRequestPresentComplete: Observable<boolean>;
  14975. /**
  14976. * Observable signaled when VR request present starts
  14977. */
  14978. onVRRequestPresentStart: Observable<Engine>;
  14979. /**
  14980. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14981. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14982. */
  14983. isInVRExclusivePointerMode: boolean;
  14984. /**
  14985. * Gets a boolean indicating if a webVR device was detected
  14986. * @returns true if a webVR device was detected
  14987. */
  14988. isVRDevicePresent(): boolean;
  14989. /**
  14990. * Gets the current webVR device
  14991. * @returns the current webVR device (or null)
  14992. */
  14993. getVRDevice(): any;
  14994. /**
  14995. * Initializes a webVR display and starts listening to display change events
  14996. * The onVRDisplayChangedObservable will be notified upon these changes
  14997. * @returns A promise containing a VRDisplay and if vr is supported
  14998. */
  14999. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15000. /** @hidden */
  15001. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15002. /**
  15003. * Call this function to switch to webVR mode
  15004. * Will do nothing if webVR is not supported or if there is no webVR device
  15005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15006. */
  15007. enableVR(): void;
  15008. /** @hidden */
  15009. _onVRFullScreenTriggered(): void;
  15010. }
  15011. }
  15012. }
  15013. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15014. import { Nullable } from "babylonjs/types";
  15015. import { Observable } from "babylonjs/Misc/observable";
  15016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15017. import { Scene } from "babylonjs/scene";
  15018. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15019. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15020. import { Node } from "babylonjs/node";
  15021. import { Ray } from "babylonjs/Culling/ray";
  15022. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15023. import "babylonjs/Engines/Extensions/engine.webVR";
  15024. /**
  15025. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15026. * IMPORTANT!! The data is right-hand data.
  15027. * @export
  15028. * @interface DevicePose
  15029. */
  15030. export interface DevicePose {
  15031. /**
  15032. * The position of the device, values in array are [x,y,z].
  15033. */
  15034. readonly position: Nullable<Float32Array>;
  15035. /**
  15036. * The linearVelocity of the device, values in array are [x,y,z].
  15037. */
  15038. readonly linearVelocity: Nullable<Float32Array>;
  15039. /**
  15040. * The linearAcceleration of the device, values in array are [x,y,z].
  15041. */
  15042. readonly linearAcceleration: Nullable<Float32Array>;
  15043. /**
  15044. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15045. */
  15046. readonly orientation: Nullable<Float32Array>;
  15047. /**
  15048. * The angularVelocity of the device, values in array are [x,y,z].
  15049. */
  15050. readonly angularVelocity: Nullable<Float32Array>;
  15051. /**
  15052. * The angularAcceleration of the device, values in array are [x,y,z].
  15053. */
  15054. readonly angularAcceleration: Nullable<Float32Array>;
  15055. }
  15056. /**
  15057. * Interface representing a pose controlled object in Babylon.
  15058. * A pose controlled object has both regular pose values as well as pose values
  15059. * from an external device such as a VR head mounted display
  15060. */
  15061. export interface PoseControlled {
  15062. /**
  15063. * The position of the object in babylon space.
  15064. */
  15065. position: Vector3;
  15066. /**
  15067. * The rotation quaternion of the object in babylon space.
  15068. */
  15069. rotationQuaternion: Quaternion;
  15070. /**
  15071. * The position of the device in babylon space.
  15072. */
  15073. devicePosition?: Vector3;
  15074. /**
  15075. * The rotation quaternion of the device in babylon space.
  15076. */
  15077. deviceRotationQuaternion: Quaternion;
  15078. /**
  15079. * The raw pose coming from the device.
  15080. */
  15081. rawPose: Nullable<DevicePose>;
  15082. /**
  15083. * The scale of the device to be used when translating from device space to babylon space.
  15084. */
  15085. deviceScaleFactor: number;
  15086. /**
  15087. * Updates the poseControlled values based on the input device pose.
  15088. * @param poseData the pose data to update the object with
  15089. */
  15090. updateFromDevice(poseData: DevicePose): void;
  15091. }
  15092. /**
  15093. * Set of options to customize the webVRCamera
  15094. */
  15095. export interface WebVROptions {
  15096. /**
  15097. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15098. */
  15099. trackPosition?: boolean;
  15100. /**
  15101. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15102. */
  15103. positionScale?: number;
  15104. /**
  15105. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15106. */
  15107. displayName?: string;
  15108. /**
  15109. * Should the native controller meshes be initialized. (default: true)
  15110. */
  15111. controllerMeshes?: boolean;
  15112. /**
  15113. * Creating a default HemiLight only on controllers. (default: true)
  15114. */
  15115. defaultLightingOnControllers?: boolean;
  15116. /**
  15117. * If you don't want to use the default VR button of the helper. (default: false)
  15118. */
  15119. useCustomVRButton?: boolean;
  15120. /**
  15121. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15122. */
  15123. customVRButton?: HTMLButtonElement;
  15124. /**
  15125. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15126. */
  15127. rayLength?: number;
  15128. /**
  15129. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15130. */
  15131. defaultHeight?: number;
  15132. /**
  15133. * If multiview should be used if availible (default: false)
  15134. */
  15135. useMultiview?: boolean;
  15136. }
  15137. /**
  15138. * This represents a WebVR camera.
  15139. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15140. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15141. */
  15142. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15143. private webVROptions;
  15144. /**
  15145. * @hidden
  15146. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15147. */
  15148. _vrDevice: any;
  15149. /**
  15150. * The rawPose of the vrDevice.
  15151. */
  15152. rawPose: Nullable<DevicePose>;
  15153. private _onVREnabled;
  15154. private _specsVersion;
  15155. private _attached;
  15156. private _frameData;
  15157. protected _descendants: Array<Node>;
  15158. private _deviceRoomPosition;
  15159. /** @hidden */
  15160. _deviceRoomRotationQuaternion: Quaternion;
  15161. private _standingMatrix;
  15162. /**
  15163. * Represents device position in babylon space.
  15164. */
  15165. devicePosition: Vector3;
  15166. /**
  15167. * Represents device rotation in babylon space.
  15168. */
  15169. deviceRotationQuaternion: Quaternion;
  15170. /**
  15171. * The scale of the device to be used when translating from device space to babylon space.
  15172. */
  15173. deviceScaleFactor: number;
  15174. private _deviceToWorld;
  15175. private _worldToDevice;
  15176. /**
  15177. * References to the webVR controllers for the vrDevice.
  15178. */
  15179. controllers: Array<WebVRController>;
  15180. /**
  15181. * Emits an event when a controller is attached.
  15182. */
  15183. onControllersAttachedObservable: Observable<WebVRController[]>;
  15184. /**
  15185. * Emits an event when a controller's mesh has been loaded;
  15186. */
  15187. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15188. /**
  15189. * Emits an event when the HMD's pose has been updated.
  15190. */
  15191. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15192. private _poseSet;
  15193. /**
  15194. * If the rig cameras be used as parent instead of this camera.
  15195. */
  15196. rigParenting: boolean;
  15197. private _lightOnControllers;
  15198. private _defaultHeight?;
  15199. /**
  15200. * Instantiates a WebVRFreeCamera.
  15201. * @param name The name of the WebVRFreeCamera
  15202. * @param position The starting anchor position for the camera
  15203. * @param scene The scene the camera belongs to
  15204. * @param webVROptions a set of customizable options for the webVRCamera
  15205. */
  15206. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15207. /**
  15208. * Gets the device distance from the ground in meters.
  15209. * @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.
  15210. */
  15211. deviceDistanceToRoomGround(): number;
  15212. /**
  15213. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15214. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15215. */
  15216. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15217. /**
  15218. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15219. * @returns A promise with a boolean set to if the standing matrix is supported.
  15220. */
  15221. useStandingMatrixAsync(): Promise<boolean>;
  15222. /**
  15223. * Disposes the camera
  15224. */
  15225. dispose(): void;
  15226. /**
  15227. * Gets a vrController by name.
  15228. * @param name The name of the controller to retreive
  15229. * @returns the controller matching the name specified or null if not found
  15230. */
  15231. getControllerByName(name: string): Nullable<WebVRController>;
  15232. private _leftController;
  15233. /**
  15234. * The controller corresponding to the users left hand.
  15235. */
  15236. readonly leftController: Nullable<WebVRController>;
  15237. private _rightController;
  15238. /**
  15239. * The controller corresponding to the users right hand.
  15240. */
  15241. readonly rightController: Nullable<WebVRController>;
  15242. /**
  15243. * Casts a ray forward from the vrCamera's gaze.
  15244. * @param length Length of the ray (default: 100)
  15245. * @returns the ray corresponding to the gaze
  15246. */
  15247. getForwardRay(length?: number): Ray;
  15248. /**
  15249. * @hidden
  15250. * Updates the camera based on device's frame data
  15251. */
  15252. _checkInputs(): void;
  15253. /**
  15254. * Updates the poseControlled values based on the input device pose.
  15255. * @param poseData Pose coming from the device
  15256. */
  15257. updateFromDevice(poseData: DevicePose): void;
  15258. private _htmlElementAttached;
  15259. private _detachIfAttached;
  15260. /**
  15261. * WebVR's attach control will start broadcasting frames to the device.
  15262. * Note that in certain browsers (chrome for example) this function must be called
  15263. * within a user-interaction callback. Example:
  15264. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15265. *
  15266. * @param element html element to attach the vrDevice to
  15267. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15268. */
  15269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15270. /**
  15271. * Detaches the camera from the html element and disables VR
  15272. *
  15273. * @param element html element to detach from
  15274. */
  15275. detachControl(element: HTMLElement): void;
  15276. /**
  15277. * @returns the name of this class
  15278. */
  15279. getClassName(): string;
  15280. /**
  15281. * Calls resetPose on the vrDisplay
  15282. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15283. */
  15284. resetToCurrentRotation(): void;
  15285. /**
  15286. * @hidden
  15287. * Updates the rig cameras (left and right eye)
  15288. */
  15289. _updateRigCameras(): void;
  15290. private _workingVector;
  15291. private _oneVector;
  15292. private _workingMatrix;
  15293. private updateCacheCalled;
  15294. private _correctPositionIfNotTrackPosition;
  15295. /**
  15296. * @hidden
  15297. * Updates the cached values of the camera
  15298. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15299. */
  15300. _updateCache(ignoreParentClass?: boolean): void;
  15301. /**
  15302. * @hidden
  15303. * Get current device position in babylon world
  15304. */
  15305. _computeDevicePosition(): void;
  15306. /**
  15307. * Updates the current device position and rotation in the babylon world
  15308. */
  15309. update(): void;
  15310. /**
  15311. * @hidden
  15312. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15313. * @returns an identity matrix
  15314. */
  15315. _getViewMatrix(): Matrix;
  15316. private _tmpMatrix;
  15317. /**
  15318. * This function is called by the two RIG cameras.
  15319. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15320. * @hidden
  15321. */
  15322. _getWebVRViewMatrix(): Matrix;
  15323. /** @hidden */
  15324. _getWebVRProjectionMatrix(): Matrix;
  15325. private _onGamepadConnectedObserver;
  15326. private _onGamepadDisconnectedObserver;
  15327. private _updateCacheWhenTrackingDisabledObserver;
  15328. /**
  15329. * Initializes the controllers and their meshes
  15330. */
  15331. initControllers(): void;
  15332. }
  15333. }
  15334. declare module "babylonjs/PostProcesses/postProcess" {
  15335. import { Nullable } from "babylonjs/types";
  15336. import { SmartArray } from "babylonjs/Misc/smartArray";
  15337. import { Observable } from "babylonjs/Misc/observable";
  15338. import { Vector2 } from "babylonjs/Maths/math.vector";
  15339. import { Camera } from "babylonjs/Cameras/camera";
  15340. import { Effect } from "babylonjs/Materials/effect";
  15341. import "babylonjs/Shaders/postprocess.vertex";
  15342. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15343. import { Engine } from "babylonjs/Engines/engine";
  15344. import { Color4 } from "babylonjs/Maths/math.color";
  15345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15346. /**
  15347. * Size options for a post process
  15348. */
  15349. export type PostProcessOptions = {
  15350. width: number;
  15351. height: number;
  15352. };
  15353. /**
  15354. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15356. */
  15357. export class PostProcess {
  15358. /** Name of the PostProcess. */
  15359. name: string;
  15360. /**
  15361. * Gets or sets the unique id of the post process
  15362. */
  15363. uniqueId: number;
  15364. /**
  15365. * Width of the texture to apply the post process on
  15366. */
  15367. width: number;
  15368. /**
  15369. * Height of the texture to apply the post process on
  15370. */
  15371. height: number;
  15372. /**
  15373. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15374. * @hidden
  15375. */
  15376. _outputTexture: Nullable<InternalTexture>;
  15377. /**
  15378. * Sampling mode used by the shader
  15379. * See https://doc.babylonjs.com/classes/3.1/texture
  15380. */
  15381. renderTargetSamplingMode: number;
  15382. /**
  15383. * Clear color to use when screen clearing
  15384. */
  15385. clearColor: Color4;
  15386. /**
  15387. * If the buffer needs to be cleared before applying the post process. (default: true)
  15388. * Should be set to false if shader will overwrite all previous pixels.
  15389. */
  15390. autoClear: boolean;
  15391. /**
  15392. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15393. */
  15394. alphaMode: number;
  15395. /**
  15396. * Sets the setAlphaBlendConstants of the babylon engine
  15397. */
  15398. alphaConstants: Color4;
  15399. /**
  15400. * Animations to be used for the post processing
  15401. */
  15402. animations: import("babylonjs/Animations/animation").Animation[];
  15403. /**
  15404. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15405. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15406. */
  15407. enablePixelPerfectMode: boolean;
  15408. /**
  15409. * Force the postprocess to be applied without taking in account viewport
  15410. */
  15411. forceFullscreenViewport: boolean;
  15412. /**
  15413. * List of inspectable custom properties (used by the Inspector)
  15414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15415. */
  15416. inspectableCustomProperties: IInspectable[];
  15417. /**
  15418. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15419. *
  15420. * | Value | Type | Description |
  15421. * | ----- | ----------------------------------- | ----------- |
  15422. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15423. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15424. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15425. *
  15426. */
  15427. scaleMode: number;
  15428. /**
  15429. * Force textures to be a power of two (default: false)
  15430. */
  15431. alwaysForcePOT: boolean;
  15432. private _samples;
  15433. /**
  15434. * Number of sample textures (default: 1)
  15435. */
  15436. samples: number;
  15437. /**
  15438. * Modify the scale of the post process to be the same as the viewport (default: false)
  15439. */
  15440. adaptScaleToCurrentViewport: boolean;
  15441. private _camera;
  15442. private _scene;
  15443. private _engine;
  15444. private _options;
  15445. private _reusable;
  15446. private _textureType;
  15447. /**
  15448. * Smart array of input and output textures for the post process.
  15449. * @hidden
  15450. */
  15451. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15452. /**
  15453. * The index in _textures that corresponds to the output texture.
  15454. * @hidden
  15455. */
  15456. _currentRenderTextureInd: number;
  15457. private _effect;
  15458. private _samplers;
  15459. private _fragmentUrl;
  15460. private _vertexUrl;
  15461. private _parameters;
  15462. private _scaleRatio;
  15463. protected _indexParameters: any;
  15464. private _shareOutputWithPostProcess;
  15465. private _texelSize;
  15466. private _forcedOutputTexture;
  15467. /**
  15468. * Returns the fragment url or shader name used in the post process.
  15469. * @returns the fragment url or name in the shader store.
  15470. */
  15471. getEffectName(): string;
  15472. /**
  15473. * An event triggered when the postprocess is activated.
  15474. */
  15475. onActivateObservable: Observable<Camera>;
  15476. private _onActivateObserver;
  15477. /**
  15478. * A function that is added to the onActivateObservable
  15479. */
  15480. onActivate: Nullable<(camera: Camera) => void>;
  15481. /**
  15482. * An event triggered when the postprocess changes its size.
  15483. */
  15484. onSizeChangedObservable: Observable<PostProcess>;
  15485. private _onSizeChangedObserver;
  15486. /**
  15487. * A function that is added to the onSizeChangedObservable
  15488. */
  15489. onSizeChanged: (postProcess: PostProcess) => void;
  15490. /**
  15491. * An event triggered when the postprocess applies its effect.
  15492. */
  15493. onApplyObservable: Observable<Effect>;
  15494. private _onApplyObserver;
  15495. /**
  15496. * A function that is added to the onApplyObservable
  15497. */
  15498. onApply: (effect: Effect) => void;
  15499. /**
  15500. * An event triggered before rendering the postprocess
  15501. */
  15502. onBeforeRenderObservable: Observable<Effect>;
  15503. private _onBeforeRenderObserver;
  15504. /**
  15505. * A function that is added to the onBeforeRenderObservable
  15506. */
  15507. onBeforeRender: (effect: Effect) => void;
  15508. /**
  15509. * An event triggered after rendering the postprocess
  15510. */
  15511. onAfterRenderObservable: Observable<Effect>;
  15512. private _onAfterRenderObserver;
  15513. /**
  15514. * A function that is added to the onAfterRenderObservable
  15515. */
  15516. onAfterRender: (efect: Effect) => void;
  15517. /**
  15518. * 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
  15519. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15520. */
  15521. inputTexture: InternalTexture;
  15522. /**
  15523. * Gets the camera which post process is applied to.
  15524. * @returns The camera the post process is applied to.
  15525. */
  15526. getCamera(): Camera;
  15527. /**
  15528. * Gets the texel size of the postprocess.
  15529. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15530. */
  15531. readonly texelSize: Vector2;
  15532. /**
  15533. * Creates a new instance PostProcess
  15534. * @param name The name of the PostProcess.
  15535. * @param fragmentUrl The url of the fragment shader to be used.
  15536. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15537. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15538. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15539. * @param camera The camera to apply the render pass to.
  15540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15541. * @param engine The engine which the post process will be applied. (default: current engine)
  15542. * @param reusable If the post process can be reused on the same frame. (default: false)
  15543. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15544. * @param textureType Type of textures used when performing the post process. (default: 0)
  15545. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15546. * @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
  15547. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15548. */
  15549. constructor(
  15550. /** Name of the PostProcess. */
  15551. 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);
  15552. /**
  15553. * Gets a string idenfifying the name of the class
  15554. * @returns "PostProcess" string
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Gets the engine which this post process belongs to.
  15559. * @returns The engine the post process was enabled with.
  15560. */
  15561. getEngine(): Engine;
  15562. /**
  15563. * The effect that is created when initializing the post process.
  15564. * @returns The created effect corresponding the the postprocess.
  15565. */
  15566. getEffect(): Effect;
  15567. /**
  15568. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15569. * @param postProcess The post process to share the output with.
  15570. * @returns This post process.
  15571. */
  15572. shareOutputWith(postProcess: PostProcess): PostProcess;
  15573. /**
  15574. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15575. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15576. */
  15577. useOwnOutput(): void;
  15578. /**
  15579. * Updates the effect with the current post process compile time values and recompiles the shader.
  15580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15583. * @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
  15584. * @param onCompiled Called when the shader has been compiled.
  15585. * @param onError Called if there is an error when compiling a shader.
  15586. */
  15587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15588. /**
  15589. * The post process is reusable if it can be used multiple times within one frame.
  15590. * @returns If the post process is reusable
  15591. */
  15592. isReusable(): boolean;
  15593. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15594. markTextureDirty(): void;
  15595. /**
  15596. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15597. * 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.
  15598. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15599. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15600. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15601. * @returns The target texture that was bound to be written to.
  15602. */
  15603. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15604. /**
  15605. * If the post process is supported.
  15606. */
  15607. readonly isSupported: boolean;
  15608. /**
  15609. * The aspect ratio of the output texture.
  15610. */
  15611. readonly aspectRatio: number;
  15612. /**
  15613. * Get a value indicating if the post-process is ready to be used
  15614. * @returns true if the post-process is ready (shader is compiled)
  15615. */
  15616. isReady(): boolean;
  15617. /**
  15618. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15619. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15620. */
  15621. apply(): Nullable<Effect>;
  15622. private _disposeTextures;
  15623. /**
  15624. * Disposes the post process.
  15625. * @param camera The camera to dispose the post process on.
  15626. */
  15627. dispose(camera?: Camera): void;
  15628. }
  15629. }
  15630. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15631. /** @hidden */
  15632. export var kernelBlurVaryingDeclaration: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15638. /** @hidden */
  15639. export var kernelBlurFragment: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15645. /** @hidden */
  15646. export var kernelBlurFragment2: {
  15647. name: string;
  15648. shader: string;
  15649. };
  15650. }
  15651. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15652. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15653. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15654. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15655. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15656. /** @hidden */
  15657. export var kernelBlurPixelShader: {
  15658. name: string;
  15659. shader: string;
  15660. };
  15661. }
  15662. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15663. /** @hidden */
  15664. export var kernelBlurVertex: {
  15665. name: string;
  15666. shader: string;
  15667. };
  15668. }
  15669. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15670. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15671. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15672. /** @hidden */
  15673. export var kernelBlurVertexShader: {
  15674. name: string;
  15675. shader: string;
  15676. };
  15677. }
  15678. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15679. import { Vector2 } from "babylonjs/Maths/math.vector";
  15680. import { Nullable } from "babylonjs/types";
  15681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15682. import { Camera } from "babylonjs/Cameras/camera";
  15683. import { Effect } from "babylonjs/Materials/effect";
  15684. import { Engine } from "babylonjs/Engines/engine";
  15685. import "babylonjs/Shaders/kernelBlur.fragment";
  15686. import "babylonjs/Shaders/kernelBlur.vertex";
  15687. /**
  15688. * The Blur Post Process which blurs an image based on a kernel and direction.
  15689. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15690. */
  15691. export class BlurPostProcess extends PostProcess {
  15692. /** The direction in which to blur the image. */
  15693. direction: Vector2;
  15694. private blockCompilation;
  15695. protected _kernel: number;
  15696. protected _idealKernel: number;
  15697. protected _packedFloat: boolean;
  15698. private _staticDefines;
  15699. /**
  15700. * Sets the length in pixels of the blur sample region
  15701. */
  15702. /**
  15703. * Gets the length in pixels of the blur sample region
  15704. */
  15705. kernel: number;
  15706. /**
  15707. * Sets wether or not the blur needs to unpack/repack floats
  15708. */
  15709. /**
  15710. * Gets wether or not the blur is unpacking/repacking floats
  15711. */
  15712. packedFloat: boolean;
  15713. /**
  15714. * Creates a new instance BlurPostProcess
  15715. * @param name The name of the effect.
  15716. * @param direction The direction in which to blur the image.
  15717. * @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.
  15718. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15719. * @param camera The camera to apply the render pass to.
  15720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15721. * @param engine The engine which the post process will be applied. (default: current engine)
  15722. * @param reusable If the post process can be reused on the same frame. (default: false)
  15723. * @param textureType Type of textures used when performing the post process. (default: 0)
  15724. * @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)
  15725. */
  15726. constructor(name: string,
  15727. /** The direction in which to blur the image. */
  15728. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15729. /**
  15730. * Updates the effect with the current post process compile time values and recompiles the shader.
  15731. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15732. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15733. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15734. * @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
  15735. * @param onCompiled Called when the shader has been compiled.
  15736. * @param onError Called if there is an error when compiling a shader.
  15737. */
  15738. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15739. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15740. /**
  15741. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15742. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15743. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15744. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15745. * The gaps between physical kernels are compensated for in the weighting of the samples
  15746. * @param idealKernel Ideal blur kernel.
  15747. * @return Nearest best kernel.
  15748. */
  15749. protected _nearestBestKernel(idealKernel: number): number;
  15750. /**
  15751. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15752. * @param x The point on the Gaussian distribution to sample.
  15753. * @return the value of the Gaussian function at x.
  15754. */
  15755. protected _gaussianWeight(x: number): number;
  15756. /**
  15757. * Generates a string that can be used as a floating point number in GLSL.
  15758. * @param x Value to print.
  15759. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15760. * @return GLSL float string.
  15761. */
  15762. protected _glslFloat(x: number, decimalFigures?: number): string;
  15763. }
  15764. }
  15765. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15766. import { Scene } from "babylonjs/scene";
  15767. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15768. import { Plane } from "babylonjs/Maths/math.plane";
  15769. /**
  15770. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15771. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15772. * You can then easily use it as a reflectionTexture on a flat surface.
  15773. * In case the surface is not a plane, please consider relying on reflection probes.
  15774. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15775. */
  15776. export class MirrorTexture extends RenderTargetTexture {
  15777. private scene;
  15778. /**
  15779. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15780. * 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.
  15781. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15782. */
  15783. mirrorPlane: Plane;
  15784. /**
  15785. * Define the blur ratio used to blur the reflection if needed.
  15786. */
  15787. blurRatio: number;
  15788. /**
  15789. * Define the adaptive blur kernel used to blur the reflection if needed.
  15790. * This will autocompute the closest best match for the `blurKernel`
  15791. */
  15792. adaptiveBlurKernel: number;
  15793. /**
  15794. * Define the blur kernel used to blur the reflection if needed.
  15795. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15796. */
  15797. blurKernel: number;
  15798. /**
  15799. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15801. */
  15802. blurKernelX: number;
  15803. /**
  15804. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15805. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15806. */
  15807. blurKernelY: number;
  15808. private _autoComputeBlurKernel;
  15809. protected _onRatioRescale(): void;
  15810. private _updateGammaSpace;
  15811. private _imageProcessingConfigChangeObserver;
  15812. private _transformMatrix;
  15813. private _mirrorMatrix;
  15814. private _savedViewMatrix;
  15815. private _blurX;
  15816. private _blurY;
  15817. private _adaptiveBlurKernel;
  15818. private _blurKernelX;
  15819. private _blurKernelY;
  15820. private _blurRatio;
  15821. /**
  15822. * Instantiates a Mirror Texture.
  15823. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15824. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15825. * You can then easily use it as a reflectionTexture on a flat surface.
  15826. * In case the surface is not a plane, please consider relying on reflection probes.
  15827. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15828. * @param name
  15829. * @param size
  15830. * @param scene
  15831. * @param generateMipMaps
  15832. * @param type
  15833. * @param samplingMode
  15834. * @param generateDepthBuffer
  15835. */
  15836. constructor(name: string, size: number | {
  15837. width: number;
  15838. height: number;
  15839. } | {
  15840. ratio: number;
  15841. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15842. private _preparePostProcesses;
  15843. /**
  15844. * Clone the mirror texture.
  15845. * @returns the cloned texture
  15846. */
  15847. clone(): MirrorTexture;
  15848. /**
  15849. * Serialize the texture to a JSON representation you could use in Parse later on
  15850. * @returns the serialized JSON representation
  15851. */
  15852. serialize(): any;
  15853. /**
  15854. * Dispose the texture and release its associated resources.
  15855. */
  15856. dispose(): void;
  15857. }
  15858. }
  15859. declare module "babylonjs/Materials/Textures/texture" {
  15860. import { Observable } from "babylonjs/Misc/observable";
  15861. import { Nullable } from "babylonjs/types";
  15862. import { Scene } from "babylonjs/scene";
  15863. import { Matrix } from "babylonjs/Maths/math.vector";
  15864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15865. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15866. import { Engine } from "babylonjs/Engines/engine";
  15867. /**
  15868. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15869. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15870. */
  15871. export class Texture extends BaseTexture {
  15872. /** @hidden */
  15873. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15874. /** @hidden */
  15875. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15876. /** @hidden */
  15877. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15878. /** nearest is mag = nearest and min = nearest and mip = linear */
  15879. static readonly NEAREST_SAMPLINGMODE: number;
  15880. /** nearest is mag = nearest and min = nearest and mip = linear */
  15881. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15882. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15883. static readonly BILINEAR_SAMPLINGMODE: number;
  15884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15885. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15886. /** Trilinear is mag = linear and min = linear and mip = linear */
  15887. static readonly TRILINEAR_SAMPLINGMODE: number;
  15888. /** Trilinear is mag = linear and min = linear and mip = linear */
  15889. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15890. /** mag = nearest and min = nearest and mip = nearest */
  15891. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15892. /** mag = nearest and min = linear and mip = nearest */
  15893. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15894. /** mag = nearest and min = linear and mip = linear */
  15895. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15896. /** mag = nearest and min = linear and mip = none */
  15897. static readonly NEAREST_LINEAR: number;
  15898. /** mag = nearest and min = nearest and mip = none */
  15899. static readonly NEAREST_NEAREST: number;
  15900. /** mag = linear and min = nearest and mip = nearest */
  15901. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15902. /** mag = linear and min = nearest and mip = linear */
  15903. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15904. /** mag = linear and min = linear and mip = none */
  15905. static readonly LINEAR_LINEAR: number;
  15906. /** mag = linear and min = nearest and mip = none */
  15907. static readonly LINEAR_NEAREST: number;
  15908. /** Explicit coordinates mode */
  15909. static readonly EXPLICIT_MODE: number;
  15910. /** Spherical coordinates mode */
  15911. static readonly SPHERICAL_MODE: number;
  15912. /** Planar coordinates mode */
  15913. static readonly PLANAR_MODE: number;
  15914. /** Cubic coordinates mode */
  15915. static readonly CUBIC_MODE: number;
  15916. /** Projection coordinates mode */
  15917. static readonly PROJECTION_MODE: number;
  15918. /** Inverse Cubic coordinates mode */
  15919. static readonly SKYBOX_MODE: number;
  15920. /** Inverse Cubic coordinates mode */
  15921. static readonly INVCUBIC_MODE: number;
  15922. /** Equirectangular coordinates mode */
  15923. static readonly EQUIRECTANGULAR_MODE: number;
  15924. /** Equirectangular Fixed coordinates mode */
  15925. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15926. /** Equirectangular Fixed Mirrored coordinates mode */
  15927. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15928. /** Texture is not repeating outside of 0..1 UVs */
  15929. static readonly CLAMP_ADDRESSMODE: number;
  15930. /** Texture is repeating outside of 0..1 UVs */
  15931. static readonly WRAP_ADDRESSMODE: number;
  15932. /** Texture is repeating and mirrored */
  15933. static readonly MIRROR_ADDRESSMODE: number;
  15934. /**
  15935. * 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
  15936. */
  15937. static UseSerializedUrlIfAny: boolean;
  15938. /**
  15939. * Define the url of the texture.
  15940. */
  15941. url: Nullable<string>;
  15942. /**
  15943. * Define an offset on the texture to offset the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15945. */
  15946. uOffset: number;
  15947. /**
  15948. * Define an offset on the texture to offset the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15950. */
  15951. vOffset: number;
  15952. /**
  15953. * Define an offset on the texture to scale the u coordinates of the UVs
  15954. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15955. */
  15956. uScale: number;
  15957. /**
  15958. * Define an offset on the texture to scale the v coordinates of the UVs
  15959. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15960. */
  15961. vScale: number;
  15962. /**
  15963. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15964. * @see http://doc.babylonjs.com/how_to/more_materials
  15965. */
  15966. uAng: number;
  15967. /**
  15968. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15969. * @see http://doc.babylonjs.com/how_to/more_materials
  15970. */
  15971. vAng: number;
  15972. /**
  15973. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15974. * @see http://doc.babylonjs.com/how_to/more_materials
  15975. */
  15976. wAng: number;
  15977. /**
  15978. * Defines the center of rotation (U)
  15979. */
  15980. uRotationCenter: number;
  15981. /**
  15982. * Defines the center of rotation (V)
  15983. */
  15984. vRotationCenter: number;
  15985. /**
  15986. * Defines the center of rotation (W)
  15987. */
  15988. wRotationCenter: number;
  15989. /**
  15990. * Are mip maps generated for this texture or not.
  15991. */
  15992. readonly noMipmap: boolean;
  15993. /**
  15994. * List of inspectable custom properties (used by the Inspector)
  15995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15996. */
  15997. inspectableCustomProperties: Nullable<IInspectable[]>;
  15998. private _noMipmap;
  15999. /** @hidden */
  16000. _invertY: boolean;
  16001. private _rowGenerationMatrix;
  16002. private _cachedTextureMatrix;
  16003. private _projectionModeMatrix;
  16004. private _t0;
  16005. private _t1;
  16006. private _t2;
  16007. private _cachedUOffset;
  16008. private _cachedVOffset;
  16009. private _cachedUScale;
  16010. private _cachedVScale;
  16011. private _cachedUAng;
  16012. private _cachedVAng;
  16013. private _cachedWAng;
  16014. private _cachedProjectionMatrixId;
  16015. private _cachedCoordinatesMode;
  16016. /** @hidden */
  16017. protected _initialSamplingMode: number;
  16018. /** @hidden */
  16019. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16020. private _deleteBuffer;
  16021. protected _format: Nullable<number>;
  16022. private _delayedOnLoad;
  16023. private _delayedOnError;
  16024. /**
  16025. * Observable triggered once the texture has been loaded.
  16026. */
  16027. onLoadObservable: Observable<Texture>;
  16028. protected _isBlocking: boolean;
  16029. /**
  16030. * Is the texture preventing material to render while loading.
  16031. * If false, a default texture will be used instead of the loading one during the preparation step.
  16032. */
  16033. isBlocking: boolean;
  16034. /**
  16035. * Get the current sampling mode associated with the texture.
  16036. */
  16037. readonly samplingMode: number;
  16038. /**
  16039. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16040. */
  16041. readonly invertY: boolean;
  16042. /**
  16043. * Instantiates a new texture.
  16044. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16045. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16046. * @param url define the url of the picture to load as a texture
  16047. * @param scene define the scene or engine the texture will belong to
  16048. * @param noMipmap define if the texture will require mip maps or not
  16049. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16050. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16051. * @param onLoad define a callback triggered when the texture has been loaded
  16052. * @param onError define a callback triggered when an error occurred during the loading session
  16053. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16054. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16055. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16056. */
  16057. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16058. /**
  16059. * Update the url (and optional buffer) of this texture if url was null during construction.
  16060. * @param url the url of the texture
  16061. * @param buffer the buffer of the texture (defaults to null)
  16062. * @param onLoad callback called when the texture is loaded (defaults to null)
  16063. */
  16064. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16065. /**
  16066. * Finish the loading sequence of a texture flagged as delayed load.
  16067. * @hidden
  16068. */
  16069. delayLoad(): void;
  16070. private _prepareRowForTextureGeneration;
  16071. /**
  16072. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16073. * @returns the transform matrix of the texture.
  16074. */
  16075. getTextureMatrix(): Matrix;
  16076. /**
  16077. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16078. * @returns The reflection texture transform
  16079. */
  16080. getReflectionTextureMatrix(): Matrix;
  16081. /**
  16082. * Clones the texture.
  16083. * @returns the cloned texture
  16084. */
  16085. clone(): Texture;
  16086. /**
  16087. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16088. * @returns The JSON representation of the texture
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Get the current class name of the texture useful for serialization or dynamic coding.
  16093. * @returns "Texture"
  16094. */
  16095. getClassName(): string;
  16096. /**
  16097. * Dispose the texture and release its associated resources.
  16098. */
  16099. dispose(): void;
  16100. /**
  16101. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16102. * @param parsedTexture Define the JSON representation of the texture
  16103. * @param scene Define the scene the parsed texture should be instantiated in
  16104. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16105. * @returns The parsed texture if successful
  16106. */
  16107. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16108. /**
  16109. * Creates a texture from its base 64 representation.
  16110. * @param data Define the base64 payload without the data: prefix
  16111. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16112. * @param scene Define the scene the texture should belong to
  16113. * @param noMipmap Forces the texture to not create mip map information if true
  16114. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16115. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16116. * @param onLoad define a callback triggered when the texture has been loaded
  16117. * @param onError define a callback triggered when an error occurred during the loading session
  16118. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16119. * @returns the created texture
  16120. */
  16121. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16122. /**
  16123. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16124. * @param data Define the base64 payload without the data: prefix
  16125. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16126. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16127. * @param scene Define the scene the texture should belong to
  16128. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16129. * @param noMipmap Forces the texture to not create mip map information if true
  16130. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16131. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16132. * @param onLoad define a callback triggered when the texture has been loaded
  16133. * @param onError define a callback triggered when an error occurred during the loading session
  16134. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16135. * @returns the created texture
  16136. */
  16137. 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;
  16138. }
  16139. }
  16140. declare module "babylonjs/PostProcesses/postProcessManager" {
  16141. import { Nullable } from "babylonjs/types";
  16142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16144. import { Scene } from "babylonjs/scene";
  16145. /**
  16146. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16147. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16148. */
  16149. export class PostProcessManager {
  16150. private _scene;
  16151. private _indexBuffer;
  16152. private _vertexBuffers;
  16153. /**
  16154. * Creates a new instance PostProcess
  16155. * @param scene The scene that the post process is associated with.
  16156. */
  16157. constructor(scene: Scene);
  16158. private _prepareBuffers;
  16159. private _buildIndexBuffer;
  16160. /**
  16161. * Rebuilds the vertex buffers of the manager.
  16162. * @hidden
  16163. */
  16164. _rebuild(): void;
  16165. /**
  16166. * Prepares a frame to be run through a post process.
  16167. * @param sourceTexture The input texture to the post procesess. (default: null)
  16168. * @param postProcesses An array of post processes to be run. (default: null)
  16169. * @returns True if the post processes were able to be run.
  16170. * @hidden
  16171. */
  16172. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16173. /**
  16174. * Manually render a set of post processes to a texture.
  16175. * @param postProcesses An array of post processes to be run.
  16176. * @param targetTexture The target texture to render to.
  16177. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16178. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16179. * @param lodLevel defines which lod of the texture to render to
  16180. */
  16181. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16182. /**
  16183. * Finalize the result of the output of the postprocesses.
  16184. * @param doNotPresent If true the result will not be displayed to the screen.
  16185. * @param targetTexture The target texture to render to.
  16186. * @param faceIndex The index of the face to bind the target texture to.
  16187. * @param postProcesses The array of post processes to render.
  16188. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16189. * @hidden
  16190. */
  16191. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16192. /**
  16193. * Disposes of the post process manager.
  16194. */
  16195. dispose(): void;
  16196. }
  16197. }
  16198. declare module "babylonjs/Misc/gradients" {
  16199. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16200. /** Interface used by value gradients (color, factor, ...) */
  16201. export interface IValueGradient {
  16202. /**
  16203. * Gets or sets the gradient value (between 0 and 1)
  16204. */
  16205. gradient: number;
  16206. }
  16207. /** Class used to store color4 gradient */
  16208. export class ColorGradient implements IValueGradient {
  16209. /**
  16210. * Gets or sets the gradient value (between 0 and 1)
  16211. */
  16212. gradient: number;
  16213. /**
  16214. * Gets or sets first associated color
  16215. */
  16216. color1: Color4;
  16217. /**
  16218. * Gets or sets second associated color
  16219. */
  16220. color2?: Color4;
  16221. /**
  16222. * Will get a color picked randomly between color1 and color2.
  16223. * If color2 is undefined then color1 will be used
  16224. * @param result defines the target Color4 to store the result in
  16225. */
  16226. getColorToRef(result: Color4): void;
  16227. }
  16228. /** Class used to store color 3 gradient */
  16229. export class Color3Gradient implements IValueGradient {
  16230. /**
  16231. * Gets or sets the gradient value (between 0 and 1)
  16232. */
  16233. gradient: number;
  16234. /**
  16235. * Gets or sets the associated color
  16236. */
  16237. color: Color3;
  16238. }
  16239. /** Class used to store factor gradient */
  16240. export class FactorGradient implements IValueGradient {
  16241. /**
  16242. * Gets or sets the gradient value (between 0 and 1)
  16243. */
  16244. gradient: number;
  16245. /**
  16246. * Gets or sets first associated factor
  16247. */
  16248. factor1: number;
  16249. /**
  16250. * Gets or sets second associated factor
  16251. */
  16252. factor2?: number;
  16253. /**
  16254. * Will get a number picked randomly between factor1 and factor2.
  16255. * If factor2 is undefined then factor1 will be used
  16256. * @returns the picked number
  16257. */
  16258. getFactor(): number;
  16259. }
  16260. /**
  16261. * Helper used to simplify some generic gradient tasks
  16262. */
  16263. export class GradientHelper {
  16264. /**
  16265. * Gets the current gradient from an array of IValueGradient
  16266. * @param ratio defines the current ratio to get
  16267. * @param gradients defines the array of IValueGradient
  16268. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16269. */
  16270. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16271. }
  16272. }
  16273. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16274. import { Scene } from "babylonjs/scene";
  16275. import { ISceneComponent } from "babylonjs/sceneComponent";
  16276. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16277. module "babylonjs/abstractScene" {
  16278. interface AbstractScene {
  16279. /**
  16280. * The list of procedural textures added to the scene
  16281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16282. */
  16283. proceduralTextures: Array<ProceduralTexture>;
  16284. }
  16285. }
  16286. /**
  16287. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16288. * in a given scene.
  16289. */
  16290. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16291. /**
  16292. * The component name helpfull to identify the component in the list of scene components.
  16293. */
  16294. readonly name: string;
  16295. /**
  16296. * The scene the component belongs to.
  16297. */
  16298. scene: Scene;
  16299. /**
  16300. * Creates a new instance of the component for the given scene
  16301. * @param scene Defines the scene to register the component in
  16302. */
  16303. constructor(scene: Scene);
  16304. /**
  16305. * Registers the component in a given scene
  16306. */
  16307. register(): void;
  16308. /**
  16309. * Rebuilds the elements related to this component in case of
  16310. * context lost for instance.
  16311. */
  16312. rebuild(): void;
  16313. /**
  16314. * Disposes the component and the associated ressources.
  16315. */
  16316. dispose(): void;
  16317. private _beforeClear;
  16318. }
  16319. }
  16320. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16321. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16323. module "babylonjs/Engines/engine" {
  16324. interface Engine {
  16325. /**
  16326. * Creates a new render target cube texture
  16327. * @param size defines the size of the texture
  16328. * @param options defines the options used to create the texture
  16329. * @returns a new render target cube texture stored in an InternalTexture
  16330. */
  16331. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16332. }
  16333. }
  16334. }
  16335. declare module "babylonjs/Shaders/procedural.vertex" {
  16336. /** @hidden */
  16337. export var proceduralVertexShader: {
  16338. name: string;
  16339. shader: string;
  16340. };
  16341. }
  16342. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16343. import { Observable } from "babylonjs/Misc/observable";
  16344. import { Nullable } from "babylonjs/types";
  16345. import { Scene } from "babylonjs/scene";
  16346. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16347. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16348. import { Effect } from "babylonjs/Materials/effect";
  16349. import { Texture } from "babylonjs/Materials/Textures/texture";
  16350. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16351. import "babylonjs/Shaders/procedural.vertex";
  16352. /**
  16353. * 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.
  16354. * This is the base class of any Procedural texture and contains most of the shareable code.
  16355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16356. */
  16357. export class ProceduralTexture extends Texture {
  16358. isCube: boolean;
  16359. /**
  16360. * Define if the texture is enabled or not (disabled texture will not render)
  16361. */
  16362. isEnabled: boolean;
  16363. /**
  16364. * Define if the texture must be cleared before rendering (default is true)
  16365. */
  16366. autoClear: boolean;
  16367. /**
  16368. * Callback called when the texture is generated
  16369. */
  16370. onGenerated: () => void;
  16371. /**
  16372. * Event raised when the texture is generated
  16373. */
  16374. onGeneratedObservable: Observable<ProceduralTexture>;
  16375. /** @hidden */
  16376. _generateMipMaps: boolean;
  16377. /** @hidden **/
  16378. _effect: Effect;
  16379. /** @hidden */
  16380. _textures: {
  16381. [key: string]: Texture;
  16382. };
  16383. private _size;
  16384. private _currentRefreshId;
  16385. private _refreshRate;
  16386. private _vertexBuffers;
  16387. private _indexBuffer;
  16388. private _uniforms;
  16389. private _samplers;
  16390. private _fragment;
  16391. private _floats;
  16392. private _ints;
  16393. private _floatsArrays;
  16394. private _colors3;
  16395. private _colors4;
  16396. private _vectors2;
  16397. private _vectors3;
  16398. private _matrices;
  16399. private _fallbackTexture;
  16400. private _fallbackTextureUsed;
  16401. private _engine;
  16402. private _cachedDefines;
  16403. private _contentUpdateId;
  16404. private _contentData;
  16405. /**
  16406. * Instantiates a new procedural texture.
  16407. * 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.
  16408. * This is the base class of any Procedural texture and contains most of the shareable code.
  16409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16410. * @param name Define the name of the texture
  16411. * @param size Define the size of the texture to create
  16412. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16413. * @param scene Define the scene the texture belongs to
  16414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16415. * @param generateMipMaps Define if the texture should creates mip maps or not
  16416. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16417. */
  16418. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16419. /**
  16420. * The effect that is created when initializing the post process.
  16421. * @returns The created effect corresponding the the postprocess.
  16422. */
  16423. getEffect(): Effect;
  16424. /**
  16425. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16426. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16427. */
  16428. getContent(): Nullable<ArrayBufferView>;
  16429. private _createIndexBuffer;
  16430. /** @hidden */
  16431. _rebuild(): void;
  16432. /**
  16433. * Resets the texture in order to recreate its associated resources.
  16434. * This can be called in case of context loss
  16435. */
  16436. reset(): void;
  16437. protected _getDefines(): string;
  16438. /**
  16439. * Is the texture ready to be used ? (rendered at least once)
  16440. * @returns true if ready, otherwise, false.
  16441. */
  16442. isReady(): boolean;
  16443. /**
  16444. * Resets the refresh counter of the texture and start bak from scratch.
  16445. * Could be useful to regenerate the texture if it is setup to render only once.
  16446. */
  16447. resetRefreshCounter(): void;
  16448. /**
  16449. * Set the fragment shader to use in order to render the texture.
  16450. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16451. */
  16452. setFragment(fragment: any): void;
  16453. /**
  16454. * Define the refresh rate of the texture or the rendering frequency.
  16455. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16456. */
  16457. refreshRate: number;
  16458. /** @hidden */
  16459. _shouldRender(): boolean;
  16460. /**
  16461. * Get the size the texture is rendering at.
  16462. * @returns the size (texture is always squared)
  16463. */
  16464. getRenderSize(): number;
  16465. /**
  16466. * Resize the texture to new value.
  16467. * @param size Define the new size the texture should have
  16468. * @param generateMipMaps Define whether the new texture should create mip maps
  16469. */
  16470. resize(size: number, generateMipMaps: boolean): void;
  16471. private _checkUniform;
  16472. /**
  16473. * Set a texture in the shader program used to render.
  16474. * @param name Define the name of the uniform samplers as defined in the shader
  16475. * @param texture Define the texture to bind to this sampler
  16476. * @return the texture itself allowing "fluent" like uniform updates
  16477. */
  16478. setTexture(name: string, texture: Texture): ProceduralTexture;
  16479. /**
  16480. * Set a float in the shader.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the texture itself allowing "fluent" like uniform updates
  16484. */
  16485. setFloat(name: string, value: number): ProceduralTexture;
  16486. /**
  16487. * Set a int in the shader.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the texture itself allowing "fluent" like uniform updates
  16491. */
  16492. setInt(name: string, value: number): ProceduralTexture;
  16493. /**
  16494. * Set an array of floats in the shader.
  16495. * @param name Define the name of the uniform as defined in the shader
  16496. * @param value Define the value to give to the uniform
  16497. * @return the texture itself allowing "fluent" like uniform updates
  16498. */
  16499. setFloats(name: string, value: number[]): ProceduralTexture;
  16500. /**
  16501. * Set a vec3 in the shader from a Color3.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the texture itself allowing "fluent" like uniform updates
  16505. */
  16506. setColor3(name: string, value: Color3): ProceduralTexture;
  16507. /**
  16508. * Set a vec4 in the shader from a Color4.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the texture itself allowing "fluent" like uniform updates
  16512. */
  16513. setColor4(name: string, value: Color4): ProceduralTexture;
  16514. /**
  16515. * Set a vec2 in the shader from a Vector2.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the texture itself allowing "fluent" like uniform updates
  16519. */
  16520. setVector2(name: string, value: Vector2): ProceduralTexture;
  16521. /**
  16522. * Set a vec3 in the shader from a Vector3.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the texture itself allowing "fluent" like uniform updates
  16526. */
  16527. setVector3(name: string, value: Vector3): ProceduralTexture;
  16528. /**
  16529. * Set a mat4 in the shader from a MAtrix.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the texture itself allowing "fluent" like uniform updates
  16533. */
  16534. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16535. /**
  16536. * Render the texture to its associated render target.
  16537. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16538. */
  16539. render(useCameraPostProcess?: boolean): void;
  16540. /**
  16541. * Clone the texture.
  16542. * @returns the cloned texture
  16543. */
  16544. clone(): ProceduralTexture;
  16545. /**
  16546. * Dispose the texture and release its asoociated resources.
  16547. */
  16548. dispose(): void;
  16549. }
  16550. }
  16551. declare module "babylonjs/Particles/baseParticleSystem" {
  16552. import { Nullable } from "babylonjs/types";
  16553. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16555. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16556. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16557. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16558. import { Scene } from "babylonjs/scene";
  16559. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16560. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16561. import { Texture } from "babylonjs/Materials/Textures/texture";
  16562. import { Color4 } from "babylonjs/Maths/math.color";
  16563. import { Animation } from "babylonjs/Animations/animation";
  16564. /**
  16565. * This represents the base class for particle system in Babylon.
  16566. * 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.
  16567. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16568. * @example https://doc.babylonjs.com/babylon101/particles
  16569. */
  16570. export class BaseParticleSystem {
  16571. /**
  16572. * Source color is added to the destination color without alpha affecting the result
  16573. */
  16574. static BLENDMODE_ONEONE: number;
  16575. /**
  16576. * Blend current color and particle color using particle’s alpha
  16577. */
  16578. static BLENDMODE_STANDARD: number;
  16579. /**
  16580. * Add current color and particle color multiplied by particle’s alpha
  16581. */
  16582. static BLENDMODE_ADD: number;
  16583. /**
  16584. * Multiply current color with particle color
  16585. */
  16586. static BLENDMODE_MULTIPLY: number;
  16587. /**
  16588. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16589. */
  16590. static BLENDMODE_MULTIPLYADD: number;
  16591. /**
  16592. * List of animations used by the particle system.
  16593. */
  16594. animations: Animation[];
  16595. /**
  16596. * The id of the Particle system.
  16597. */
  16598. id: string;
  16599. /**
  16600. * The friendly name of the Particle system.
  16601. */
  16602. name: string;
  16603. /**
  16604. * The rendering group used by the Particle system to chose when to render.
  16605. */
  16606. renderingGroupId: number;
  16607. /**
  16608. * The emitter represents the Mesh or position we are attaching the particle system to.
  16609. */
  16610. emitter: Nullable<AbstractMesh | Vector3>;
  16611. /**
  16612. * The maximum number of particles to emit per frame
  16613. */
  16614. emitRate: number;
  16615. /**
  16616. * If you want to launch only a few particles at once, that can be done, as well.
  16617. */
  16618. manualEmitCount: number;
  16619. /**
  16620. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16621. */
  16622. updateSpeed: number;
  16623. /**
  16624. * The amount of time the particle system is running (depends of the overall update speed).
  16625. */
  16626. targetStopDuration: number;
  16627. /**
  16628. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16629. */
  16630. disposeOnStop: boolean;
  16631. /**
  16632. * Minimum power of emitting particles.
  16633. */
  16634. minEmitPower: number;
  16635. /**
  16636. * Maximum power of emitting particles.
  16637. */
  16638. maxEmitPower: number;
  16639. /**
  16640. * Minimum life time of emitting particles.
  16641. */
  16642. minLifeTime: number;
  16643. /**
  16644. * Maximum life time of emitting particles.
  16645. */
  16646. maxLifeTime: number;
  16647. /**
  16648. * Minimum Size of emitting particles.
  16649. */
  16650. minSize: number;
  16651. /**
  16652. * Maximum Size of emitting particles.
  16653. */
  16654. maxSize: number;
  16655. /**
  16656. * Minimum scale of emitting particles on X axis.
  16657. */
  16658. minScaleX: number;
  16659. /**
  16660. * Maximum scale of emitting particles on X axis.
  16661. */
  16662. maxScaleX: number;
  16663. /**
  16664. * Minimum scale of emitting particles on Y axis.
  16665. */
  16666. minScaleY: number;
  16667. /**
  16668. * Maximum scale of emitting particles on Y axis.
  16669. */
  16670. maxScaleY: number;
  16671. /**
  16672. * Gets or sets the minimal initial rotation in radians.
  16673. */
  16674. minInitialRotation: number;
  16675. /**
  16676. * Gets or sets the maximal initial rotation in radians.
  16677. */
  16678. maxInitialRotation: number;
  16679. /**
  16680. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16681. */
  16682. minAngularSpeed: number;
  16683. /**
  16684. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16685. */
  16686. maxAngularSpeed: number;
  16687. /**
  16688. * The texture used to render each particle. (this can be a spritesheet)
  16689. */
  16690. particleTexture: Nullable<Texture>;
  16691. /**
  16692. * The layer mask we are rendering the particles through.
  16693. */
  16694. layerMask: number;
  16695. /**
  16696. * This can help using your own shader to render the particle system.
  16697. * The according effect will be created
  16698. */
  16699. customShader: any;
  16700. /**
  16701. * By default particle system starts as soon as they are created. This prevents the
  16702. * automatic start to happen and let you decide when to start emitting particles.
  16703. */
  16704. preventAutoStart: boolean;
  16705. private _noiseTexture;
  16706. /**
  16707. * Gets or sets a texture used to add random noise to particle positions
  16708. */
  16709. noiseTexture: Nullable<ProceduralTexture>;
  16710. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16711. noiseStrength: Vector3;
  16712. /**
  16713. * Callback triggered when the particle animation is ending.
  16714. */
  16715. onAnimationEnd: Nullable<() => void>;
  16716. /**
  16717. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16718. */
  16719. blendMode: number;
  16720. /**
  16721. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16722. * to override the particles.
  16723. */
  16724. forceDepthWrite: boolean;
  16725. /** 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 */
  16726. preWarmCycles: number;
  16727. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16728. preWarmStepOffset: number;
  16729. /**
  16730. * 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)
  16731. */
  16732. spriteCellChangeSpeed: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16735. */
  16736. startSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16739. */
  16740. endSpriteCellID: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16743. */
  16744. spriteCellWidth: number;
  16745. /**
  16746. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16747. */
  16748. spriteCellHeight: number;
  16749. /**
  16750. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16751. */
  16752. spriteRandomStartCell: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /** @hidden */
  16756. protected _isAnimationSheetEnabled: boolean;
  16757. /**
  16758. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16759. */
  16760. beginAnimationOnStart: boolean;
  16761. /**
  16762. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16763. */
  16764. beginAnimationFrom: number;
  16765. /**
  16766. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16767. */
  16768. beginAnimationTo: number;
  16769. /**
  16770. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16771. */
  16772. beginAnimationLoop: boolean;
  16773. /**
  16774. * Gets or sets a world offset applied to all particles
  16775. */
  16776. worldOffset: Vector3;
  16777. /**
  16778. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16779. */
  16780. isAnimationSheetEnabled: boolean;
  16781. /**
  16782. * Get hosting scene
  16783. * @returns the scene
  16784. */
  16785. getScene(): Scene;
  16786. /**
  16787. * You can use gravity if you want to give an orientation to your particles.
  16788. */
  16789. gravity: Vector3;
  16790. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16791. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16792. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16793. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16794. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16795. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16796. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16797. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16798. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16799. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16800. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16801. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16802. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16803. /**
  16804. * Defines the delay in milliseconds before starting the system (0 by default)
  16805. */
  16806. startDelay: number;
  16807. /**
  16808. * Gets the current list of drag gradients.
  16809. * You must use addDragGradient and removeDragGradient to udpate this list
  16810. * @returns the list of drag gradients
  16811. */
  16812. getDragGradients(): Nullable<Array<FactorGradient>>;
  16813. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16814. limitVelocityDamping: number;
  16815. /**
  16816. * Gets the current list of limit velocity gradients.
  16817. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16818. * @returns the list of limit velocity gradients
  16819. */
  16820. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16821. /**
  16822. * Gets the current list of color gradients.
  16823. * You must use addColorGradient and removeColorGradient to udpate this list
  16824. * @returns the list of color gradients
  16825. */
  16826. getColorGradients(): Nullable<Array<ColorGradient>>;
  16827. /**
  16828. * Gets the current list of size gradients.
  16829. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16830. * @returns the list of size gradients
  16831. */
  16832. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of color remap gradients.
  16835. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16836. * @returns the list of color remap gradients
  16837. */
  16838. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Gets the current list of alpha remap gradients.
  16841. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16842. * @returns the list of alpha remap gradients
  16843. */
  16844. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16845. /**
  16846. * Gets the current list of life time gradients.
  16847. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16848. * @returns the list of life time gradients
  16849. */
  16850. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Gets the current list of angular speed gradients.
  16853. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16854. * @returns the list of angular speed gradients
  16855. */
  16856. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Gets the current list of velocity gradients.
  16859. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16860. * @returns the list of velocity gradients
  16861. */
  16862. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16863. /**
  16864. * Gets the current list of start size gradients.
  16865. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16866. * @returns the list of start size gradients
  16867. */
  16868. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16869. /**
  16870. * Gets the current list of emit rate gradients.
  16871. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16872. * @returns the list of emit rate gradients
  16873. */
  16874. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16875. /**
  16876. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16877. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16878. */
  16879. direction1: Vector3;
  16880. /**
  16881. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16882. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16883. */
  16884. direction2: Vector3;
  16885. /**
  16886. * 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.
  16887. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16888. */
  16889. minEmitBox: Vector3;
  16890. /**
  16891. * 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.
  16892. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16893. */
  16894. maxEmitBox: Vector3;
  16895. /**
  16896. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16897. */
  16898. color1: Color4;
  16899. /**
  16900. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16901. */
  16902. color2: Color4;
  16903. /**
  16904. * Color the particle will have at the end of its lifetime
  16905. */
  16906. colorDead: Color4;
  16907. /**
  16908. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16909. */
  16910. textureMask: Color4;
  16911. /**
  16912. * The particle emitter type defines the emitter used by the particle system.
  16913. * It can be for example box, sphere, or cone...
  16914. */
  16915. particleEmitterType: IParticleEmitterType;
  16916. /** @hidden */
  16917. _isSubEmitter: boolean;
  16918. /**
  16919. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16920. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16921. */
  16922. billboardMode: number;
  16923. protected _isBillboardBased: boolean;
  16924. /**
  16925. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16926. */
  16927. isBillboardBased: boolean;
  16928. /**
  16929. * The scene the particle system belongs to.
  16930. */
  16931. protected _scene: Scene;
  16932. /**
  16933. * Local cache of defines for image processing.
  16934. */
  16935. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16936. /**
  16937. * Default configuration related to image processing available in the standard Material.
  16938. */
  16939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16940. /**
  16941. * Gets the image processing configuration used either in this material.
  16942. */
  16943. /**
  16944. * Sets the Default image processing configuration used either in the this material.
  16945. *
  16946. * If sets to null, the scene one is in use.
  16947. */
  16948. imageProcessingConfiguration: ImageProcessingConfiguration;
  16949. /**
  16950. * Attaches a new image processing configuration to the Standard Material.
  16951. * @param configuration
  16952. */
  16953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16954. /** @hidden */
  16955. protected _reset(): void;
  16956. /** @hidden */
  16957. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16958. /**
  16959. * Instantiates a particle system.
  16960. * 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.
  16961. * @param name The name of the particle system
  16962. */
  16963. constructor(name: string);
  16964. /**
  16965. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16966. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16967. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16968. * @returns the emitter
  16969. */
  16970. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16971. /**
  16972. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16973. * @param radius The radius of the hemisphere to emit from
  16974. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16975. * @returns the emitter
  16976. */
  16977. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16978. /**
  16979. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16980. * @param radius The radius of the sphere to emit from
  16981. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16982. * @returns the emitter
  16983. */
  16984. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16985. /**
  16986. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16987. * @param radius The radius of the sphere to emit from
  16988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16990. * @returns the emitter
  16991. */
  16992. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16993. /**
  16994. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16995. * @param radius The radius of the emission cylinder
  16996. * @param height The height of the emission cylinder
  16997. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16998. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16999. * @returns the emitter
  17000. */
  17001. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17002. /**
  17003. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17004. * @param radius The radius of the cylinder to emit from
  17005. * @param height The height of the emission cylinder
  17006. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17009. * @returns the emitter
  17010. */
  17011. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17012. /**
  17013. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17014. * @param radius The radius of the cone to emit from
  17015. * @param angle The base angle of the cone
  17016. * @returns the emitter
  17017. */
  17018. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17019. /**
  17020. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17023. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17024. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17025. * @returns the emitter
  17026. */
  17027. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17028. }
  17029. }
  17030. declare module "babylonjs/Particles/subEmitter" {
  17031. import { Scene } from "babylonjs/scene";
  17032. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17033. /**
  17034. * Type of sub emitter
  17035. */
  17036. export enum SubEmitterType {
  17037. /**
  17038. * Attached to the particle over it's lifetime
  17039. */
  17040. ATTACHED = 0,
  17041. /**
  17042. * Created when the particle dies
  17043. */
  17044. END = 1
  17045. }
  17046. /**
  17047. * Sub emitter class used to emit particles from an existing particle
  17048. */
  17049. export class SubEmitter {
  17050. /**
  17051. * the particle system to be used by the sub emitter
  17052. */
  17053. particleSystem: ParticleSystem;
  17054. /**
  17055. * Type of the submitter (Default: END)
  17056. */
  17057. type: SubEmitterType;
  17058. /**
  17059. * 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)
  17060. * Note: This only is supported when using an emitter of type Mesh
  17061. */
  17062. inheritDirection: boolean;
  17063. /**
  17064. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17065. */
  17066. inheritedVelocityAmount: number;
  17067. /**
  17068. * Creates a sub emitter
  17069. * @param particleSystem the particle system to be used by the sub emitter
  17070. */
  17071. constructor(
  17072. /**
  17073. * the particle system to be used by the sub emitter
  17074. */
  17075. particleSystem: ParticleSystem);
  17076. /**
  17077. * Clones the sub emitter
  17078. * @returns the cloned sub emitter
  17079. */
  17080. clone(): SubEmitter;
  17081. /**
  17082. * Serialize current object to a JSON object
  17083. * @returns the serialized object
  17084. */
  17085. serialize(): any;
  17086. /** @hidden */
  17087. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17088. /**
  17089. * Creates a new SubEmitter from a serialized JSON version
  17090. * @param serializationObject defines the JSON object to read from
  17091. * @param scene defines the hosting scene
  17092. * @param rootUrl defines the rootUrl for data loading
  17093. * @returns a new SubEmitter
  17094. */
  17095. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17096. /** Release associated resources */
  17097. dispose(): void;
  17098. }
  17099. }
  17100. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17101. /** @hidden */
  17102. export var clipPlaneFragmentDeclaration: {
  17103. name: string;
  17104. shader: string;
  17105. };
  17106. }
  17107. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17108. /** @hidden */
  17109. export var imageProcessingDeclaration: {
  17110. name: string;
  17111. shader: string;
  17112. };
  17113. }
  17114. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17115. /** @hidden */
  17116. export var imageProcessingFunctions: {
  17117. name: string;
  17118. shader: string;
  17119. };
  17120. }
  17121. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17122. /** @hidden */
  17123. export var clipPlaneFragment: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/particles.fragment" {
  17129. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17130. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17131. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17132. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17134. /** @hidden */
  17135. export var particlesPixelShader: {
  17136. name: string;
  17137. shader: string;
  17138. };
  17139. }
  17140. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17141. /** @hidden */
  17142. export var clipPlaneVertexDeclaration: {
  17143. name: string;
  17144. shader: string;
  17145. };
  17146. }
  17147. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17148. /** @hidden */
  17149. export var clipPlaneVertex: {
  17150. name: string;
  17151. shader: string;
  17152. };
  17153. }
  17154. declare module "babylonjs/Shaders/particles.vertex" {
  17155. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17157. /** @hidden */
  17158. export var particlesVertexShader: {
  17159. name: string;
  17160. shader: string;
  17161. };
  17162. }
  17163. declare module "babylonjs/Particles/particleSystem" {
  17164. import { Nullable } from "babylonjs/types";
  17165. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17166. import { Observable } from "babylonjs/Misc/observable";
  17167. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17168. import { Effect } from "babylonjs/Materials/effect";
  17169. import { Scene, IDisposable } from "babylonjs/scene";
  17170. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17171. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17172. import { Particle } from "babylonjs/Particles/particle";
  17173. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17174. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17175. import "babylonjs/Shaders/particles.fragment";
  17176. import "babylonjs/Shaders/particles.vertex";
  17177. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17178. /**
  17179. * This represents a particle system in Babylon.
  17180. * 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.
  17181. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17182. * @example https://doc.babylonjs.com/babylon101/particles
  17183. */
  17184. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17185. /**
  17186. * Billboard mode will only apply to Y axis
  17187. */
  17188. static readonly BILLBOARDMODE_Y: number;
  17189. /**
  17190. * Billboard mode will apply to all axes
  17191. */
  17192. static readonly BILLBOARDMODE_ALL: number;
  17193. /**
  17194. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17195. */
  17196. static readonly BILLBOARDMODE_STRETCHED: number;
  17197. /**
  17198. * This function can be defined to provide custom update for active particles.
  17199. * This function will be called instead of regular update (age, position, color, etc.).
  17200. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17201. */
  17202. updateFunction: (particles: Particle[]) => void;
  17203. private _emitterWorldMatrix;
  17204. /**
  17205. * This function can be defined to specify initial direction for every new particle.
  17206. * It by default use the emitterType defined function
  17207. */
  17208. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17209. /**
  17210. * This function can be defined to specify initial position for every new particle.
  17211. * It by default use the emitterType defined function
  17212. */
  17213. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17214. /**
  17215. * @hidden
  17216. */
  17217. _inheritedVelocityOffset: Vector3;
  17218. /**
  17219. * An event triggered when the system is disposed
  17220. */
  17221. onDisposeObservable: Observable<ParticleSystem>;
  17222. private _onDisposeObserver;
  17223. /**
  17224. * Sets a callback that will be triggered when the system is disposed
  17225. */
  17226. onDispose: () => void;
  17227. private _particles;
  17228. private _epsilon;
  17229. private _capacity;
  17230. private _stockParticles;
  17231. private _newPartsExcess;
  17232. private _vertexData;
  17233. private _vertexBuffer;
  17234. private _vertexBuffers;
  17235. private _spriteBuffer;
  17236. private _indexBuffer;
  17237. private _effect;
  17238. private _customEffect;
  17239. private _cachedDefines;
  17240. private _scaledColorStep;
  17241. private _colorDiff;
  17242. private _scaledDirection;
  17243. private _scaledGravity;
  17244. private _currentRenderId;
  17245. private _alive;
  17246. private _useInstancing;
  17247. private _started;
  17248. private _stopped;
  17249. private _actualFrame;
  17250. private _scaledUpdateSpeed;
  17251. private _vertexBufferSize;
  17252. /** @hidden */
  17253. _currentEmitRateGradient: Nullable<FactorGradient>;
  17254. /** @hidden */
  17255. _currentEmitRate1: number;
  17256. /** @hidden */
  17257. _currentEmitRate2: number;
  17258. /** @hidden */
  17259. _currentStartSizeGradient: Nullable<FactorGradient>;
  17260. /** @hidden */
  17261. _currentStartSize1: number;
  17262. /** @hidden */
  17263. _currentStartSize2: number;
  17264. private readonly _rawTextureWidth;
  17265. private _rampGradientsTexture;
  17266. private _useRampGradients;
  17267. /** Gets or sets a boolean indicating that ramp gradients must be used
  17268. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17269. */
  17270. useRampGradients: boolean;
  17271. /**
  17272. * 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.
  17273. * 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: [])
  17274. */
  17275. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17276. private _subEmitters;
  17277. /**
  17278. * @hidden
  17279. * If the particle systems emitter should be disposed when the particle system is disposed
  17280. */
  17281. _disposeEmitterOnDispose: boolean;
  17282. /**
  17283. * The current active Sub-systems, this property is used by the root particle system only.
  17284. */
  17285. activeSubSystems: Array<ParticleSystem>;
  17286. private _rootParticleSystem;
  17287. /**
  17288. * Gets the current list of active particles
  17289. */
  17290. readonly particles: Particle[];
  17291. /**
  17292. * Returns the string "ParticleSystem"
  17293. * @returns a string containing the class name
  17294. */
  17295. getClassName(): string;
  17296. /**
  17297. * Instantiates a particle system.
  17298. * 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.
  17299. * @param name The name of the particle system
  17300. * @param capacity The max number of particles alive at the same time
  17301. * @param scene The scene the particle system belongs to
  17302. * @param customEffect a custom effect used to change the way particles are rendered by default
  17303. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17304. * @param epsilon Offset used to render the particles
  17305. */
  17306. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17307. private _addFactorGradient;
  17308. private _removeFactorGradient;
  17309. /**
  17310. * Adds a new life time gradient
  17311. * @param gradient defines the gradient to use (between 0 and 1)
  17312. * @param factor defines the life time factor to affect to the specified gradient
  17313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17314. * @returns the current particle system
  17315. */
  17316. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17317. /**
  17318. * Remove a specific life time gradient
  17319. * @param gradient defines the gradient to remove
  17320. * @returns the current particle system
  17321. */
  17322. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17323. /**
  17324. * Adds a new size gradient
  17325. * @param gradient defines the gradient to use (between 0 and 1)
  17326. * @param factor defines the size factor to affect to the specified gradient
  17327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17328. * @returns the current particle system
  17329. */
  17330. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17331. /**
  17332. * Remove a specific size gradient
  17333. * @param gradient defines the gradient to remove
  17334. * @returns the current particle system
  17335. */
  17336. removeSizeGradient(gradient: number): IParticleSystem;
  17337. /**
  17338. * Adds a new color remap gradient
  17339. * @param gradient defines the gradient to use (between 0 and 1)
  17340. * @param min defines the color remap minimal range
  17341. * @param max defines the color remap maximal range
  17342. * @returns the current particle system
  17343. */
  17344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17345. /**
  17346. * Remove a specific color remap gradient
  17347. * @param gradient defines the gradient to remove
  17348. * @returns the current particle system
  17349. */
  17350. removeColorRemapGradient(gradient: number): IParticleSystem;
  17351. /**
  17352. * Adds a new alpha remap gradient
  17353. * @param gradient defines the gradient to use (between 0 and 1)
  17354. * @param min defines the alpha remap minimal range
  17355. * @param max defines the alpha remap maximal range
  17356. * @returns the current particle system
  17357. */
  17358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17359. /**
  17360. * Remove a specific alpha remap gradient
  17361. * @param gradient defines the gradient to remove
  17362. * @returns the current particle system
  17363. */
  17364. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17365. /**
  17366. * Adds a new angular speed gradient
  17367. * @param gradient defines the gradient to use (between 0 and 1)
  17368. * @param factor defines the angular speed to affect to the specified gradient
  17369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17370. * @returns the current particle system
  17371. */
  17372. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17373. /**
  17374. * Remove a specific angular speed gradient
  17375. * @param gradient defines the gradient to remove
  17376. * @returns the current particle system
  17377. */
  17378. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17379. /**
  17380. * Adds a new velocity gradient
  17381. * @param gradient defines the gradient to use (between 0 and 1)
  17382. * @param factor defines the velocity to affect to the specified gradient
  17383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17384. * @returns the current particle system
  17385. */
  17386. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17387. /**
  17388. * Remove a specific velocity gradient
  17389. * @param gradient defines the gradient to remove
  17390. * @returns the current particle system
  17391. */
  17392. removeVelocityGradient(gradient: number): IParticleSystem;
  17393. /**
  17394. * Adds a new limit velocity gradient
  17395. * @param gradient defines the gradient to use (between 0 and 1)
  17396. * @param factor defines the limit velocity value to affect to the specified gradient
  17397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17398. * @returns the current particle system
  17399. */
  17400. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17401. /**
  17402. * Remove a specific limit velocity gradient
  17403. * @param gradient defines the gradient to remove
  17404. * @returns the current particle system
  17405. */
  17406. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17407. /**
  17408. * Adds a new drag gradient
  17409. * @param gradient defines the gradient to use (between 0 and 1)
  17410. * @param factor defines the drag value to affect to the specified gradient
  17411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17412. * @returns the current particle system
  17413. */
  17414. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17415. /**
  17416. * Remove a specific drag gradient
  17417. * @param gradient defines the gradient to remove
  17418. * @returns the current particle system
  17419. */
  17420. removeDragGradient(gradient: number): IParticleSystem;
  17421. /**
  17422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17423. * @param gradient defines the gradient to use (between 0 and 1)
  17424. * @param factor defines the emit rate value to affect to the specified gradient
  17425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17426. * @returns the current particle system
  17427. */
  17428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17429. /**
  17430. * Remove a specific emit rate gradient
  17431. * @param gradient defines the gradient to remove
  17432. * @returns the current particle system
  17433. */
  17434. removeEmitRateGradient(gradient: number): IParticleSystem;
  17435. /**
  17436. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17437. * @param gradient defines the gradient to use (between 0 and 1)
  17438. * @param factor defines the start size value to affect to the specified gradient
  17439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17440. * @returns the current particle system
  17441. */
  17442. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17443. /**
  17444. * Remove a specific start size gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeStartSizeGradient(gradient: number): IParticleSystem;
  17449. private _createRampGradientTexture;
  17450. /**
  17451. * Gets the current list of ramp gradients.
  17452. * You must use addRampGradient and removeRampGradient to udpate this list
  17453. * @returns the list of ramp gradients
  17454. */
  17455. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17456. /**
  17457. * Adds a new ramp gradient used to remap particle colors
  17458. * @param gradient defines the gradient to use (between 0 and 1)
  17459. * @param color defines the color to affect to the specified gradient
  17460. * @returns the current particle system
  17461. */
  17462. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17463. /**
  17464. * Remove a specific ramp gradient
  17465. * @param gradient defines the gradient to remove
  17466. * @returns the current particle system
  17467. */
  17468. removeRampGradient(gradient: number): ParticleSystem;
  17469. /**
  17470. * Adds a new color gradient
  17471. * @param gradient defines the gradient to use (between 0 and 1)
  17472. * @param color1 defines the color to affect to the specified gradient
  17473. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17474. * @returns this particle system
  17475. */
  17476. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17477. /**
  17478. * Remove a specific color gradient
  17479. * @param gradient defines the gradient to remove
  17480. * @returns this particle system
  17481. */
  17482. removeColorGradient(gradient: number): IParticleSystem;
  17483. private _fetchR;
  17484. protected _reset(): void;
  17485. private _resetEffect;
  17486. private _createVertexBuffers;
  17487. private _createIndexBuffer;
  17488. /**
  17489. * Gets the maximum number of particles active at the same time.
  17490. * @returns The max number of active particles.
  17491. */
  17492. getCapacity(): number;
  17493. /**
  17494. * Gets whether there are still active particles in the system.
  17495. * @returns True if it is alive, otherwise false.
  17496. */
  17497. isAlive(): boolean;
  17498. /**
  17499. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17500. * @returns True if it has been started, otherwise false.
  17501. */
  17502. isStarted(): boolean;
  17503. private _prepareSubEmitterInternalArray;
  17504. /**
  17505. * Starts the particle system and begins to emit
  17506. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17507. */
  17508. start(delay?: number): void;
  17509. /**
  17510. * Stops the particle system.
  17511. * @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.
  17512. */
  17513. stop(stopSubEmitters?: boolean): void;
  17514. /**
  17515. * Remove all active particles
  17516. */
  17517. reset(): void;
  17518. /**
  17519. * @hidden (for internal use only)
  17520. */
  17521. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17522. /**
  17523. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17524. * Its lifetime will start back at 0.
  17525. */
  17526. recycleParticle: (particle: Particle) => void;
  17527. private _stopSubEmitters;
  17528. private _createParticle;
  17529. private _removeFromRoot;
  17530. private _emitFromParticle;
  17531. private _update;
  17532. /** @hidden */
  17533. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17534. /** @hidden */
  17535. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17536. /** @hidden */
  17537. private _getEffect;
  17538. /**
  17539. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17540. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17541. */
  17542. animate(preWarmOnly?: boolean): void;
  17543. private _appendParticleVertices;
  17544. /**
  17545. * Rebuilds the particle system.
  17546. */
  17547. rebuild(): void;
  17548. /**
  17549. * Is this system ready to be used/rendered
  17550. * @return true if the system is ready
  17551. */
  17552. isReady(): boolean;
  17553. private _render;
  17554. /**
  17555. * Renders the particle system in its current state.
  17556. * @returns the current number of particles
  17557. */
  17558. render(): number;
  17559. /**
  17560. * Disposes the particle system and free the associated resources
  17561. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17562. */
  17563. dispose(disposeTexture?: boolean): void;
  17564. /**
  17565. * Clones the particle system.
  17566. * @param name The name of the cloned object
  17567. * @param newEmitter The new emitter to use
  17568. * @returns the cloned particle system
  17569. */
  17570. clone(name: string, newEmitter: any): ParticleSystem;
  17571. /**
  17572. * Serializes the particle system to a JSON object.
  17573. * @returns the JSON object
  17574. */
  17575. serialize(): any;
  17576. /** @hidden */
  17577. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17578. /** @hidden */
  17579. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17580. /**
  17581. * Parses a JSON object to create a particle system.
  17582. * @param parsedParticleSystem The JSON object to parse
  17583. * @param scene The scene to create the particle system in
  17584. * @param rootUrl The root url to use to load external dependencies like texture
  17585. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17586. * @returns the Parsed particle system
  17587. */
  17588. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17589. }
  17590. }
  17591. declare module "babylonjs/Particles/particle" {
  17592. import { Nullable } from "babylonjs/types";
  17593. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17594. import { Color4 } from "babylonjs/Maths/math.color";
  17595. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17596. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17597. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17598. /**
  17599. * A particle represents one of the element emitted by a particle system.
  17600. * This is mainly define by its coordinates, direction, velocity and age.
  17601. */
  17602. export class Particle {
  17603. /**
  17604. * The particle system the particle belongs to.
  17605. */
  17606. particleSystem: ParticleSystem;
  17607. private static _Count;
  17608. /**
  17609. * Unique ID of the particle
  17610. */
  17611. id: number;
  17612. /**
  17613. * The world position of the particle in the scene.
  17614. */
  17615. position: Vector3;
  17616. /**
  17617. * The world direction of the particle in the scene.
  17618. */
  17619. direction: Vector3;
  17620. /**
  17621. * The color of the particle.
  17622. */
  17623. color: Color4;
  17624. /**
  17625. * The color change of the particle per step.
  17626. */
  17627. colorStep: Color4;
  17628. /**
  17629. * Defines how long will the life of the particle be.
  17630. */
  17631. lifeTime: number;
  17632. /**
  17633. * The current age of the particle.
  17634. */
  17635. age: number;
  17636. /**
  17637. * The current size of the particle.
  17638. */
  17639. size: number;
  17640. /**
  17641. * The current scale of the particle.
  17642. */
  17643. scale: Vector2;
  17644. /**
  17645. * The current angle of the particle.
  17646. */
  17647. angle: number;
  17648. /**
  17649. * Defines how fast is the angle changing.
  17650. */
  17651. angularSpeed: number;
  17652. /**
  17653. * Defines the cell index used by the particle to be rendered from a sprite.
  17654. */
  17655. cellIndex: number;
  17656. /**
  17657. * The information required to support color remapping
  17658. */
  17659. remapData: Vector4;
  17660. /** @hidden */
  17661. _randomCellOffset?: number;
  17662. /** @hidden */
  17663. _initialDirection: Nullable<Vector3>;
  17664. /** @hidden */
  17665. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17666. /** @hidden */
  17667. _initialStartSpriteCellID: number;
  17668. /** @hidden */
  17669. _initialEndSpriteCellID: number;
  17670. /** @hidden */
  17671. _currentColorGradient: Nullable<ColorGradient>;
  17672. /** @hidden */
  17673. _currentColor1: Color4;
  17674. /** @hidden */
  17675. _currentColor2: Color4;
  17676. /** @hidden */
  17677. _currentSizeGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentSize1: number;
  17680. /** @hidden */
  17681. _currentSize2: number;
  17682. /** @hidden */
  17683. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentAngularSpeed1: number;
  17686. /** @hidden */
  17687. _currentAngularSpeed2: number;
  17688. /** @hidden */
  17689. _currentVelocityGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentVelocity1: number;
  17692. /** @hidden */
  17693. _currentVelocity2: number;
  17694. /** @hidden */
  17695. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17696. /** @hidden */
  17697. _currentLimitVelocity1: number;
  17698. /** @hidden */
  17699. _currentLimitVelocity2: number;
  17700. /** @hidden */
  17701. _currentDragGradient: Nullable<FactorGradient>;
  17702. /** @hidden */
  17703. _currentDrag1: number;
  17704. /** @hidden */
  17705. _currentDrag2: number;
  17706. /** @hidden */
  17707. _randomNoiseCoordinates1: Vector3;
  17708. /** @hidden */
  17709. _randomNoiseCoordinates2: Vector3;
  17710. /**
  17711. * Creates a new instance Particle
  17712. * @param particleSystem the particle system the particle belongs to
  17713. */
  17714. constructor(
  17715. /**
  17716. * The particle system the particle belongs to.
  17717. */
  17718. particleSystem: ParticleSystem);
  17719. private updateCellInfoFromSystem;
  17720. /**
  17721. * Defines how the sprite cell index is updated for the particle
  17722. */
  17723. updateCellIndex(): void;
  17724. /** @hidden */
  17725. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17726. /** @hidden */
  17727. _inheritParticleInfoToSubEmitters(): void;
  17728. /** @hidden */
  17729. _reset(): void;
  17730. /**
  17731. * Copy the properties of particle to another one.
  17732. * @param other the particle to copy the information to.
  17733. */
  17734. copyTo(other: Particle): void;
  17735. }
  17736. }
  17737. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17739. import { Effect } from "babylonjs/Materials/effect";
  17740. import { Particle } from "babylonjs/Particles/particle";
  17741. /**
  17742. * Particle emitter represents a volume emitting particles.
  17743. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17744. */
  17745. export interface IParticleEmitterType {
  17746. /**
  17747. * Called by the particle System when the direction is computed for the created particle.
  17748. * @param worldMatrix is the world matrix of the particle system
  17749. * @param directionToUpdate is the direction vector to update with the result
  17750. * @param particle is the particle we are computed the direction for
  17751. */
  17752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17753. /**
  17754. * Called by the particle System when the position is computed for the created particle.
  17755. * @param worldMatrix is the world matrix of the particle system
  17756. * @param positionToUpdate is the position vector to update with the result
  17757. * @param particle is the particle we are computed the position for
  17758. */
  17759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17760. /**
  17761. * Clones the current emitter and returns a copy of it
  17762. * @returns the new emitter
  17763. */
  17764. clone(): IParticleEmitterType;
  17765. /**
  17766. * Called by the GPUParticleSystem to setup the update shader
  17767. * @param effect defines the update shader
  17768. */
  17769. applyToShader(effect: Effect): void;
  17770. /**
  17771. * Returns a string to use to update the GPU particles update shader
  17772. * @returns the effect defines string
  17773. */
  17774. getEffectDefines(): string;
  17775. /**
  17776. * Returns a string representing the class name
  17777. * @returns a string containing the class name
  17778. */
  17779. getClassName(): string;
  17780. /**
  17781. * Serializes the particle system to a JSON object.
  17782. * @returns the JSON object
  17783. */
  17784. serialize(): any;
  17785. /**
  17786. * Parse properties from a JSON object
  17787. * @param serializationObject defines the JSON object
  17788. */
  17789. parse(serializationObject: any): void;
  17790. }
  17791. }
  17792. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17793. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17794. import { Effect } from "babylonjs/Materials/effect";
  17795. import { Particle } from "babylonjs/Particles/particle";
  17796. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17797. /**
  17798. * Particle emitter emitting particles from the inside of a box.
  17799. * It emits the particles randomly between 2 given directions.
  17800. */
  17801. export class BoxParticleEmitter implements IParticleEmitterType {
  17802. /**
  17803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17804. */
  17805. direction1: Vector3;
  17806. /**
  17807. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17808. */
  17809. direction2: Vector3;
  17810. /**
  17811. * 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.
  17812. */
  17813. minEmitBox: Vector3;
  17814. /**
  17815. * 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.
  17816. */
  17817. maxEmitBox: Vector3;
  17818. /**
  17819. * Creates a new instance BoxParticleEmitter
  17820. */
  17821. constructor();
  17822. /**
  17823. * Called by the particle System when the direction is computed for the created particle.
  17824. * @param worldMatrix is the world matrix of the particle system
  17825. * @param directionToUpdate is the direction vector to update with the result
  17826. * @param particle is the particle we are computed the direction for
  17827. */
  17828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17829. /**
  17830. * Called by the particle System when the position is computed for the created particle.
  17831. * @param worldMatrix is the world matrix of the particle system
  17832. * @param positionToUpdate is the position vector to update with the result
  17833. * @param particle is the particle we are computed the position for
  17834. */
  17835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17836. /**
  17837. * Clones the current emitter and returns a copy of it
  17838. * @returns the new emitter
  17839. */
  17840. clone(): BoxParticleEmitter;
  17841. /**
  17842. * Called by the GPUParticleSystem to setup the update shader
  17843. * @param effect defines the update shader
  17844. */
  17845. applyToShader(effect: Effect): void;
  17846. /**
  17847. * Returns a string to use to update the GPU particles update shader
  17848. * @returns a string containng the defines string
  17849. */
  17850. getEffectDefines(): string;
  17851. /**
  17852. * Returns the string "BoxParticleEmitter"
  17853. * @returns a string containing the class name
  17854. */
  17855. getClassName(): string;
  17856. /**
  17857. * Serializes the particle system to a JSON object.
  17858. * @returns the JSON object
  17859. */
  17860. serialize(): any;
  17861. /**
  17862. * Parse properties from a JSON object
  17863. * @param serializationObject defines the JSON object
  17864. */
  17865. parse(serializationObject: any): void;
  17866. }
  17867. }
  17868. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17870. import { Effect } from "babylonjs/Materials/effect";
  17871. import { Particle } from "babylonjs/Particles/particle";
  17872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17873. /**
  17874. * Particle emitter emitting particles from the inside of a cone.
  17875. * It emits the particles alongside the cone volume from the base to the particle.
  17876. * The emission direction might be randomized.
  17877. */
  17878. export class ConeParticleEmitter implements IParticleEmitterType {
  17879. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17880. directionRandomizer: number;
  17881. private _radius;
  17882. private _angle;
  17883. private _height;
  17884. /**
  17885. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17886. */
  17887. radiusRange: number;
  17888. /**
  17889. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17890. */
  17891. heightRange: number;
  17892. /**
  17893. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17894. */
  17895. emitFromSpawnPointOnly: boolean;
  17896. /**
  17897. * Gets or sets the radius of the emission cone
  17898. */
  17899. radius: number;
  17900. /**
  17901. * Gets or sets the angle of the emission cone
  17902. */
  17903. angle: number;
  17904. private _buildHeight;
  17905. /**
  17906. * Creates a new instance ConeParticleEmitter
  17907. * @param radius the radius of the emission cone (1 by default)
  17908. * @param angle the cone base angle (PI by default)
  17909. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17910. */
  17911. constructor(radius?: number, angle?: number,
  17912. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17913. directionRandomizer?: number);
  17914. /**
  17915. * Called by the particle System when the direction is computed for the created particle.
  17916. * @param worldMatrix is the world matrix of the particle system
  17917. * @param directionToUpdate is the direction vector to update with the result
  17918. * @param particle is the particle we are computed the direction for
  17919. */
  17920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17921. /**
  17922. * Called by the particle System when the position is computed for the created particle.
  17923. * @param worldMatrix is the world matrix of the particle system
  17924. * @param positionToUpdate is the position vector to update with the result
  17925. * @param particle is the particle we are computed the position for
  17926. */
  17927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17928. /**
  17929. * Clones the current emitter and returns a copy of it
  17930. * @returns the new emitter
  17931. */
  17932. clone(): ConeParticleEmitter;
  17933. /**
  17934. * Called by the GPUParticleSystem to setup the update shader
  17935. * @param effect defines the update shader
  17936. */
  17937. applyToShader(effect: Effect): void;
  17938. /**
  17939. * Returns a string to use to update the GPU particles update shader
  17940. * @returns a string containng the defines string
  17941. */
  17942. getEffectDefines(): string;
  17943. /**
  17944. * Returns the string "ConeParticleEmitter"
  17945. * @returns a string containing the class name
  17946. */
  17947. getClassName(): string;
  17948. /**
  17949. * Serializes the particle system to a JSON object.
  17950. * @returns the JSON object
  17951. */
  17952. serialize(): any;
  17953. /**
  17954. * Parse properties from a JSON object
  17955. * @param serializationObject defines the JSON object
  17956. */
  17957. parse(serializationObject: any): void;
  17958. }
  17959. }
  17960. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17961. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17962. import { Effect } from "babylonjs/Materials/effect";
  17963. import { Particle } from "babylonjs/Particles/particle";
  17964. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17965. /**
  17966. * Particle emitter emitting particles from the inside of a cylinder.
  17967. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17968. */
  17969. export class CylinderParticleEmitter implements IParticleEmitterType {
  17970. /**
  17971. * The radius of the emission cylinder.
  17972. */
  17973. radius: number;
  17974. /**
  17975. * The height of the emission cylinder.
  17976. */
  17977. height: number;
  17978. /**
  17979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17980. */
  17981. radiusRange: number;
  17982. /**
  17983. * How much to randomize the particle direction [0-1].
  17984. */
  17985. directionRandomizer: number;
  17986. /**
  17987. * Creates a new instance CylinderParticleEmitter
  17988. * @param radius the radius of the emission cylinder (1 by default)
  17989. * @param height the height of the emission cylinder (1 by default)
  17990. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17991. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17992. */
  17993. constructor(
  17994. /**
  17995. * The radius of the emission cylinder.
  17996. */
  17997. radius?: number,
  17998. /**
  17999. * The height of the emission cylinder.
  18000. */
  18001. height?: number,
  18002. /**
  18003. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18004. */
  18005. radiusRange?: number,
  18006. /**
  18007. * How much to randomize the particle direction [0-1].
  18008. */
  18009. directionRandomizer?: number);
  18010. /**
  18011. * Called by the particle System when the direction is computed for the created particle.
  18012. * @param worldMatrix is the world matrix of the particle system
  18013. * @param directionToUpdate is the direction vector to update with the result
  18014. * @param particle is the particle we are computed the direction for
  18015. */
  18016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18017. /**
  18018. * Called by the particle System when the position is computed for the created particle.
  18019. * @param worldMatrix is the world matrix of the particle system
  18020. * @param positionToUpdate is the position vector to update with the result
  18021. * @param particle is the particle we are computed the position for
  18022. */
  18023. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18024. /**
  18025. * Clones the current emitter and returns a copy of it
  18026. * @returns the new emitter
  18027. */
  18028. clone(): CylinderParticleEmitter;
  18029. /**
  18030. * Called by the GPUParticleSystem to setup the update shader
  18031. * @param effect defines the update shader
  18032. */
  18033. applyToShader(effect: Effect): void;
  18034. /**
  18035. * Returns a string to use to update the GPU particles update shader
  18036. * @returns a string containng the defines string
  18037. */
  18038. getEffectDefines(): string;
  18039. /**
  18040. * Returns the string "CylinderParticleEmitter"
  18041. * @returns a string containing the class name
  18042. */
  18043. getClassName(): string;
  18044. /**
  18045. * Serializes the particle system to a JSON object.
  18046. * @returns the JSON object
  18047. */
  18048. serialize(): any;
  18049. /**
  18050. * Parse properties from a JSON object
  18051. * @param serializationObject defines the JSON object
  18052. */
  18053. parse(serializationObject: any): void;
  18054. }
  18055. /**
  18056. * Particle emitter emitting particles from the inside of a cylinder.
  18057. * It emits the particles randomly between two vectors.
  18058. */
  18059. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18060. /**
  18061. * The min limit of the emission direction.
  18062. */
  18063. direction1: Vector3;
  18064. /**
  18065. * The max limit of the emission direction.
  18066. */
  18067. direction2: Vector3;
  18068. /**
  18069. * Creates a new instance CylinderDirectedParticleEmitter
  18070. * @param radius the radius of the emission cylinder (1 by default)
  18071. * @param height the height of the emission cylinder (1 by default)
  18072. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18073. * @param direction1 the min limit of the emission direction (up vector by default)
  18074. * @param direction2 the max limit of the emission direction (up vector by default)
  18075. */
  18076. constructor(radius?: number, height?: number, radiusRange?: number,
  18077. /**
  18078. * The min limit of the emission direction.
  18079. */
  18080. direction1?: Vector3,
  18081. /**
  18082. * The max limit of the emission direction.
  18083. */
  18084. direction2?: Vector3);
  18085. /**
  18086. * Called by the particle System when the direction is computed for the created particle.
  18087. * @param worldMatrix is the world matrix of the particle system
  18088. * @param directionToUpdate is the direction vector to update with the result
  18089. * @param particle is the particle we are computed the direction for
  18090. */
  18091. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18092. /**
  18093. * Clones the current emitter and returns a copy of it
  18094. * @returns the new emitter
  18095. */
  18096. clone(): CylinderDirectedParticleEmitter;
  18097. /**
  18098. * Called by the GPUParticleSystem to setup the update shader
  18099. * @param effect defines the update shader
  18100. */
  18101. applyToShader(effect: Effect): void;
  18102. /**
  18103. * Returns a string to use to update the GPU particles update shader
  18104. * @returns a string containng the defines string
  18105. */
  18106. getEffectDefines(): string;
  18107. /**
  18108. * Returns the string "CylinderDirectedParticleEmitter"
  18109. * @returns a string containing the class name
  18110. */
  18111. getClassName(): string;
  18112. /**
  18113. * Serializes the particle system to a JSON object.
  18114. * @returns the JSON object
  18115. */
  18116. serialize(): any;
  18117. /**
  18118. * Parse properties from a JSON object
  18119. * @param serializationObject defines the JSON object
  18120. */
  18121. parse(serializationObject: any): void;
  18122. }
  18123. }
  18124. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18125. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18126. import { Effect } from "babylonjs/Materials/effect";
  18127. import { Particle } from "babylonjs/Particles/particle";
  18128. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18129. /**
  18130. * Particle emitter emitting particles from the inside of a hemisphere.
  18131. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18132. */
  18133. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18134. /**
  18135. * The radius of the emission hemisphere.
  18136. */
  18137. radius: number;
  18138. /**
  18139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18140. */
  18141. radiusRange: number;
  18142. /**
  18143. * How much to randomize the particle direction [0-1].
  18144. */
  18145. directionRandomizer: number;
  18146. /**
  18147. * Creates a new instance HemisphericParticleEmitter
  18148. * @param radius the radius of the emission hemisphere (1 by default)
  18149. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18150. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18151. */
  18152. constructor(
  18153. /**
  18154. * The radius of the emission hemisphere.
  18155. */
  18156. radius?: number,
  18157. /**
  18158. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18159. */
  18160. radiusRange?: number,
  18161. /**
  18162. * How much to randomize the particle direction [0-1].
  18163. */
  18164. directionRandomizer?: number);
  18165. /**
  18166. * Called by the particle System when the direction is computed for the created particle.
  18167. * @param worldMatrix is the world matrix of the particle system
  18168. * @param directionToUpdate is the direction vector to update with the result
  18169. * @param particle is the particle we are computed the direction for
  18170. */
  18171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18172. /**
  18173. * Called by the particle System when the position is computed for the created particle.
  18174. * @param worldMatrix is the world matrix of the particle system
  18175. * @param positionToUpdate is the position vector to update with the result
  18176. * @param particle is the particle we are computed the position for
  18177. */
  18178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18179. /**
  18180. * Clones the current emitter and returns a copy of it
  18181. * @returns the new emitter
  18182. */
  18183. clone(): HemisphericParticleEmitter;
  18184. /**
  18185. * Called by the GPUParticleSystem to setup the update shader
  18186. * @param effect defines the update shader
  18187. */
  18188. applyToShader(effect: Effect): void;
  18189. /**
  18190. * Returns a string to use to update the GPU particles update shader
  18191. * @returns a string containng the defines string
  18192. */
  18193. getEffectDefines(): string;
  18194. /**
  18195. * Returns the string "HemisphericParticleEmitter"
  18196. * @returns a string containing the class name
  18197. */
  18198. getClassName(): string;
  18199. /**
  18200. * Serializes the particle system to a JSON object.
  18201. * @returns the JSON object
  18202. */
  18203. serialize(): any;
  18204. /**
  18205. * Parse properties from a JSON object
  18206. * @param serializationObject defines the JSON object
  18207. */
  18208. parse(serializationObject: any): void;
  18209. }
  18210. }
  18211. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18213. import { Effect } from "babylonjs/Materials/effect";
  18214. import { Particle } from "babylonjs/Particles/particle";
  18215. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18216. /**
  18217. * Particle emitter emitting particles from a point.
  18218. * It emits the particles randomly between 2 given directions.
  18219. */
  18220. export class PointParticleEmitter implements IParticleEmitterType {
  18221. /**
  18222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18223. */
  18224. direction1: Vector3;
  18225. /**
  18226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18227. */
  18228. direction2: Vector3;
  18229. /**
  18230. * Creates a new instance PointParticleEmitter
  18231. */
  18232. constructor();
  18233. /**
  18234. * Called by the particle System when the direction is computed for the created particle.
  18235. * @param worldMatrix is the world matrix of the particle system
  18236. * @param directionToUpdate is the direction vector to update with the result
  18237. * @param particle is the particle we are computed the direction for
  18238. */
  18239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18240. /**
  18241. * Called by the particle System when the position is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param positionToUpdate is the position vector to update with the result
  18244. * @param particle is the particle we are computed the position for
  18245. */
  18246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Clones the current emitter and returns a copy of it
  18249. * @returns the new emitter
  18250. */
  18251. clone(): PointParticleEmitter;
  18252. /**
  18253. * Called by the GPUParticleSystem to setup the update shader
  18254. * @param effect defines the update shader
  18255. */
  18256. applyToShader(effect: Effect): void;
  18257. /**
  18258. * Returns a string to use to update the GPU particles update shader
  18259. * @returns a string containng the defines string
  18260. */
  18261. getEffectDefines(): string;
  18262. /**
  18263. * Returns the string "PointParticleEmitter"
  18264. * @returns a string containing the class name
  18265. */
  18266. getClassName(): string;
  18267. /**
  18268. * Serializes the particle system to a JSON object.
  18269. * @returns the JSON object
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Parse properties from a JSON object
  18274. * @param serializationObject defines the JSON object
  18275. */
  18276. parse(serializationObject: any): void;
  18277. }
  18278. }
  18279. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18280. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18281. import { Effect } from "babylonjs/Materials/effect";
  18282. import { Particle } from "babylonjs/Particles/particle";
  18283. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18284. /**
  18285. * Particle emitter emitting particles from the inside of a sphere.
  18286. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18287. */
  18288. export class SphereParticleEmitter implements IParticleEmitterType {
  18289. /**
  18290. * The radius of the emission sphere.
  18291. */
  18292. radius: number;
  18293. /**
  18294. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18295. */
  18296. radiusRange: number;
  18297. /**
  18298. * How much to randomize the particle direction [0-1].
  18299. */
  18300. directionRandomizer: number;
  18301. /**
  18302. * Creates a new instance SphereParticleEmitter
  18303. * @param radius the radius of the emission sphere (1 by default)
  18304. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18305. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18306. */
  18307. constructor(
  18308. /**
  18309. * The radius of the emission sphere.
  18310. */
  18311. radius?: number,
  18312. /**
  18313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18314. */
  18315. radiusRange?: number,
  18316. /**
  18317. * How much to randomize the particle direction [0-1].
  18318. */
  18319. directionRandomizer?: number);
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): SphereParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "SphereParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. /**
  18366. * Particle emitter emitting particles from the inside of a sphere.
  18367. * It emits the particles randomly between two vectors.
  18368. */
  18369. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18370. /**
  18371. * The min limit of the emission direction.
  18372. */
  18373. direction1: Vector3;
  18374. /**
  18375. * The max limit of the emission direction.
  18376. */
  18377. direction2: Vector3;
  18378. /**
  18379. * Creates a new instance SphereDirectedParticleEmitter
  18380. * @param radius the radius of the emission sphere (1 by default)
  18381. * @param direction1 the min limit of the emission direction (up vector by default)
  18382. * @param direction2 the max limit of the emission direction (up vector by default)
  18383. */
  18384. constructor(radius?: number,
  18385. /**
  18386. * The min limit of the emission direction.
  18387. */
  18388. direction1?: Vector3,
  18389. /**
  18390. * The max limit of the emission direction.
  18391. */
  18392. direction2?: Vector3);
  18393. /**
  18394. * Called by the particle System when the direction is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param directionToUpdate is the direction vector to update with the result
  18397. * @param particle is the particle we are computed the direction for
  18398. */
  18399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): SphereDirectedParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "SphereDirectedParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/index" {
  18433. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18434. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18435. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18436. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18437. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18438. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18439. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18440. }
  18441. declare module "babylonjs/Particles/IParticleSystem" {
  18442. import { Nullable } from "babylonjs/types";
  18443. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18444. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18447. import { Texture } from "babylonjs/Materials/Textures/texture";
  18448. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18449. import { Scene } from "babylonjs/scene";
  18450. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18451. import { Animation } from "babylonjs/Animations/animation";
  18452. /**
  18453. * Interface representing a particle system in Babylon.js.
  18454. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18455. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18456. */
  18457. export interface IParticleSystem {
  18458. /**
  18459. * List of animations used by the particle system.
  18460. */
  18461. animations: Animation[];
  18462. /**
  18463. * The id of the Particle system.
  18464. */
  18465. id: string;
  18466. /**
  18467. * The name of the Particle system.
  18468. */
  18469. name: string;
  18470. /**
  18471. * The emitter represents the Mesh or position we are attaching the particle system to.
  18472. */
  18473. emitter: Nullable<AbstractMesh | Vector3>;
  18474. /**
  18475. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18476. */
  18477. isBillboardBased: boolean;
  18478. /**
  18479. * The rendering group used by the Particle system to chose when to render.
  18480. */
  18481. renderingGroupId: number;
  18482. /**
  18483. * The layer mask we are rendering the particles through.
  18484. */
  18485. layerMask: number;
  18486. /**
  18487. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18488. */
  18489. updateSpeed: number;
  18490. /**
  18491. * The amount of time the particle system is running (depends of the overall update speed).
  18492. */
  18493. targetStopDuration: number;
  18494. /**
  18495. * The texture used to render each particle. (this can be a spritesheet)
  18496. */
  18497. particleTexture: Nullable<Texture>;
  18498. /**
  18499. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18500. */
  18501. blendMode: number;
  18502. /**
  18503. * Minimum life time of emitting particles.
  18504. */
  18505. minLifeTime: number;
  18506. /**
  18507. * Maximum life time of emitting particles.
  18508. */
  18509. maxLifeTime: number;
  18510. /**
  18511. * Minimum Size of emitting particles.
  18512. */
  18513. minSize: number;
  18514. /**
  18515. * Maximum Size of emitting particles.
  18516. */
  18517. maxSize: number;
  18518. /**
  18519. * Minimum scale of emitting particles on X axis.
  18520. */
  18521. minScaleX: number;
  18522. /**
  18523. * Maximum scale of emitting particles on X axis.
  18524. */
  18525. maxScaleX: number;
  18526. /**
  18527. * Minimum scale of emitting particles on Y axis.
  18528. */
  18529. minScaleY: number;
  18530. /**
  18531. * Maximum scale of emitting particles on Y axis.
  18532. */
  18533. maxScaleY: number;
  18534. /**
  18535. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18536. */
  18537. color1: Color4;
  18538. /**
  18539. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18540. */
  18541. color2: Color4;
  18542. /**
  18543. * Color the particle will have at the end of its lifetime.
  18544. */
  18545. colorDead: Color4;
  18546. /**
  18547. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18548. */
  18549. emitRate: number;
  18550. /**
  18551. * You can use gravity if you want to give an orientation to your particles.
  18552. */
  18553. gravity: Vector3;
  18554. /**
  18555. * Minimum power of emitting particles.
  18556. */
  18557. minEmitPower: number;
  18558. /**
  18559. * Maximum power of emitting particles.
  18560. */
  18561. maxEmitPower: number;
  18562. /**
  18563. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18564. */
  18565. minAngularSpeed: number;
  18566. /**
  18567. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18568. */
  18569. maxAngularSpeed: number;
  18570. /**
  18571. * Gets or sets the minimal initial rotation in radians.
  18572. */
  18573. minInitialRotation: number;
  18574. /**
  18575. * Gets or sets the maximal initial rotation in radians.
  18576. */
  18577. maxInitialRotation: number;
  18578. /**
  18579. * The particle emitter type defines the emitter used by the particle system.
  18580. * It can be for example box, sphere, or cone...
  18581. */
  18582. particleEmitterType: Nullable<IParticleEmitterType>;
  18583. /**
  18584. * Defines the delay in milliseconds before starting the system (0 by default)
  18585. */
  18586. startDelay: number;
  18587. /**
  18588. * 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
  18589. */
  18590. preWarmCycles: number;
  18591. /**
  18592. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18593. */
  18594. preWarmStepOffset: number;
  18595. /**
  18596. * 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)
  18597. */
  18598. spriteCellChangeSpeed: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18601. */
  18602. startSpriteCellID: number;
  18603. /**
  18604. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18605. */
  18606. endSpriteCellID: number;
  18607. /**
  18608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18609. */
  18610. spriteCellWidth: number;
  18611. /**
  18612. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18613. */
  18614. spriteCellHeight: number;
  18615. /**
  18616. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18617. */
  18618. spriteRandomStartCell: boolean;
  18619. /**
  18620. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18621. */
  18622. isAnimationSheetEnabled: boolean;
  18623. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18624. translationPivot: Vector2;
  18625. /**
  18626. * Gets or sets a texture used to add random noise to particle positions
  18627. */
  18628. noiseTexture: Nullable<BaseTexture>;
  18629. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18630. noiseStrength: Vector3;
  18631. /**
  18632. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18633. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18634. */
  18635. billboardMode: number;
  18636. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18637. limitVelocityDamping: number;
  18638. /**
  18639. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18640. */
  18641. beginAnimationOnStart: boolean;
  18642. /**
  18643. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18644. */
  18645. beginAnimationFrom: number;
  18646. /**
  18647. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18648. */
  18649. beginAnimationTo: number;
  18650. /**
  18651. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18652. */
  18653. beginAnimationLoop: boolean;
  18654. /**
  18655. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18656. */
  18657. disposeOnStop: boolean;
  18658. /**
  18659. * Gets the maximum number of particles active at the same time.
  18660. * @returns The max number of active particles.
  18661. */
  18662. getCapacity(): number;
  18663. /**
  18664. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18665. * @returns True if it has been started, otherwise false.
  18666. */
  18667. isStarted(): boolean;
  18668. /**
  18669. * Animates the particle system for this frame.
  18670. */
  18671. animate(): void;
  18672. /**
  18673. * Renders the particle system in its current state.
  18674. * @returns the current number of particles
  18675. */
  18676. render(): number;
  18677. /**
  18678. * Dispose the particle system and frees its associated resources.
  18679. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18680. */
  18681. dispose(disposeTexture?: boolean): void;
  18682. /**
  18683. * Clones the particle system.
  18684. * @param name The name of the cloned object
  18685. * @param newEmitter The new emitter to use
  18686. * @returns the cloned particle system
  18687. */
  18688. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18689. /**
  18690. * Serializes the particle system to a JSON object.
  18691. * @returns the JSON object
  18692. */
  18693. serialize(): any;
  18694. /**
  18695. * Rebuild the particle system
  18696. */
  18697. rebuild(): void;
  18698. /**
  18699. * Starts the particle system and begins to emit
  18700. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18701. */
  18702. start(delay?: number): void;
  18703. /**
  18704. * Stops the particle system.
  18705. */
  18706. stop(): void;
  18707. /**
  18708. * Remove all active particles
  18709. */
  18710. reset(): void;
  18711. /**
  18712. * Is this system ready to be used/rendered
  18713. * @return true if the system is ready
  18714. */
  18715. isReady(): boolean;
  18716. /**
  18717. * Adds a new color gradient
  18718. * @param gradient defines the gradient to use (between 0 and 1)
  18719. * @param color1 defines the color to affect to the specified gradient
  18720. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18721. * @returns the current particle system
  18722. */
  18723. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18724. /**
  18725. * Remove a specific color gradient
  18726. * @param gradient defines the gradient to remove
  18727. * @returns the current particle system
  18728. */
  18729. removeColorGradient(gradient: number): IParticleSystem;
  18730. /**
  18731. * Adds a new size gradient
  18732. * @param gradient defines the gradient to use (between 0 and 1)
  18733. * @param factor defines the size factor to affect to the specified gradient
  18734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18735. * @returns the current particle system
  18736. */
  18737. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18738. /**
  18739. * Remove a specific size gradient
  18740. * @param gradient defines the gradient to remove
  18741. * @returns the current particle system
  18742. */
  18743. removeSizeGradient(gradient: number): IParticleSystem;
  18744. /**
  18745. * Gets the current list of color gradients.
  18746. * You must use addColorGradient and removeColorGradient to udpate this list
  18747. * @returns the list of color gradients
  18748. */
  18749. getColorGradients(): Nullable<Array<ColorGradient>>;
  18750. /**
  18751. * Gets the current list of size gradients.
  18752. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18753. * @returns the list of size gradients
  18754. */
  18755. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18756. /**
  18757. * Gets the current list of angular speed gradients.
  18758. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18759. * @returns the list of angular speed gradients
  18760. */
  18761. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new angular speed gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the angular speed to affect to the specified gradient
  18766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18767. * @returns the current particle system
  18768. */
  18769. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific angular speed gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of velocity gradients.
  18778. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18779. * @returns the list of velocity gradients
  18780. */
  18781. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the velocity to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Gets the current list of limit velocity gradients.
  18798. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18799. * @returns the list of limit velocity gradients
  18800. */
  18801. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18802. /**
  18803. * Adds a new limit velocity gradient
  18804. * @param gradient defines the gradient to use (between 0 and 1)
  18805. * @param factor defines the limit velocity to affect to the specified gradient
  18806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18807. * @returns the current particle system
  18808. */
  18809. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18810. /**
  18811. * Remove a specific limit velocity gradient
  18812. * @param gradient defines the gradient to remove
  18813. * @returns the current particle system
  18814. */
  18815. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18816. /**
  18817. * Adds a new drag gradient
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the drag to affect to the specified gradient
  18820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18821. * @returns the current particle system
  18822. */
  18823. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific drag gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeDragGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of drag gradients.
  18832. * You must use addDragGradient and removeDragGradient to udpate this list
  18833. * @returns the list of drag gradients
  18834. */
  18835. getDragGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18838. * @param gradient defines the gradient to use (between 0 and 1)
  18839. * @param factor defines the emit rate to affect to the specified gradient
  18840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18841. * @returns the current particle system
  18842. */
  18843. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific emit rate gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeEmitRateGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of emit rate gradients.
  18852. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18853. * @returns the list of emit rate gradients
  18854. */
  18855. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the start size to affect to the specified gradient
  18860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18861. * @returns the current particle system
  18862. */
  18863. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific start size gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeStartSizeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of start size gradients.
  18872. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18873. * @returns the list of start size gradients
  18874. */
  18875. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Adds a new life time gradient
  18878. * @param gradient defines the gradient to use (between 0 and 1)
  18879. * @param factor defines the life time factor to affect to the specified gradient
  18880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18881. * @returns the current particle system
  18882. */
  18883. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18884. /**
  18885. * Remove a specific life time gradient
  18886. * @param gradient defines the gradient to remove
  18887. * @returns the current particle system
  18888. */
  18889. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18890. /**
  18891. * Gets the current list of life time gradients.
  18892. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18893. * @returns the list of life time gradients
  18894. */
  18895. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18896. /**
  18897. * Gets the current list of color gradients.
  18898. * You must use addColorGradient and removeColorGradient to udpate this list
  18899. * @returns the list of color gradients
  18900. */
  18901. getColorGradients(): Nullable<Array<ColorGradient>>;
  18902. /**
  18903. * Adds a new ramp gradient used to remap particle colors
  18904. * @param gradient defines the gradient to use (between 0 and 1)
  18905. * @param color defines the color to affect to the specified gradient
  18906. * @returns the current particle system
  18907. */
  18908. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18909. /**
  18910. * Gets the current list of ramp gradients.
  18911. * You must use addRampGradient and removeRampGradient to udpate this list
  18912. * @returns the list of ramp gradients
  18913. */
  18914. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18915. /** Gets or sets a boolean indicating that ramp gradients must be used
  18916. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18917. */
  18918. useRampGradients: boolean;
  18919. /**
  18920. * Adds a new color remap gradient
  18921. * @param gradient defines the gradient to use (between 0 and 1)
  18922. * @param min defines the color remap minimal range
  18923. * @param max defines the color remap maximal range
  18924. * @returns the current particle system
  18925. */
  18926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18927. /**
  18928. * Gets the current list of color remap gradients.
  18929. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18930. * @returns the list of color remap gradients
  18931. */
  18932. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18933. /**
  18934. * Adds a new alpha remap gradient
  18935. * @param gradient defines the gradient to use (between 0 and 1)
  18936. * @param min defines the alpha remap minimal range
  18937. * @param max defines the alpha remap maximal range
  18938. * @returns the current particle system
  18939. */
  18940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18941. /**
  18942. * Gets the current list of alpha remap gradients.
  18943. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18944. * @returns the list of alpha remap gradients
  18945. */
  18946. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18947. /**
  18948. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18951. * @returns the emitter
  18952. */
  18953. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18954. /**
  18955. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18956. * @param radius The radius of the hemisphere to emit from
  18957. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18958. * @returns the emitter
  18959. */
  18960. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18961. /**
  18962. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18963. * @param radius The radius of the sphere to emit from
  18964. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18965. * @returns the emitter
  18966. */
  18967. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18968. /**
  18969. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18970. * @param radius The radius of the sphere to emit from
  18971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18973. * @returns the emitter
  18974. */
  18975. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18976. /**
  18977. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18978. * @param radius The radius of the emission cylinder
  18979. * @param height The height of the emission cylinder
  18980. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18981. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18982. * @returns the emitter
  18983. */
  18984. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18985. /**
  18986. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18987. * @param radius The radius of the cylinder to emit from
  18988. * @param height The height of the emission cylinder
  18989. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18992. * @returns the emitter
  18993. */
  18994. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18995. /**
  18996. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18997. * @param radius The radius of the cone to emit from
  18998. * @param angle The base angle of the cone
  18999. * @returns the emitter
  19000. */
  19001. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19002. /**
  19003. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19006. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19007. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19008. * @returns the emitter
  19009. */
  19010. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19011. /**
  19012. * Get hosting scene
  19013. * @returns the scene
  19014. */
  19015. getScene(): Scene;
  19016. }
  19017. }
  19018. declare module "babylonjs/Meshes/instancedMesh" {
  19019. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19020. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19021. import { Camera } from "babylonjs/Cameras/camera";
  19022. import { Node } from "babylonjs/node";
  19023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19024. import { Mesh } from "babylonjs/Meshes/mesh";
  19025. import { Material } from "babylonjs/Materials/material";
  19026. import { Skeleton } from "babylonjs/Bones/skeleton";
  19027. import { Light } from "babylonjs/Lights/light";
  19028. /**
  19029. * Creates an instance based on a source mesh.
  19030. */
  19031. export class InstancedMesh extends AbstractMesh {
  19032. private _sourceMesh;
  19033. private _currentLOD;
  19034. /** @hidden */
  19035. _indexInSourceMeshInstanceArray: number;
  19036. constructor(name: string, source: Mesh);
  19037. /**
  19038. * Returns the string "InstancedMesh".
  19039. */
  19040. getClassName(): string;
  19041. /** Gets the list of lights affecting that mesh */
  19042. readonly lightSources: Light[];
  19043. _resyncLightSources(): void;
  19044. _resyncLighSource(light: Light): void;
  19045. _removeLightSource(light: Light): void;
  19046. /**
  19047. * If the source mesh receives shadows
  19048. */
  19049. readonly receiveShadows: boolean;
  19050. /**
  19051. * The material of the source mesh
  19052. */
  19053. readonly material: Nullable<Material>;
  19054. /**
  19055. * Visibility of the source mesh
  19056. */
  19057. readonly visibility: number;
  19058. /**
  19059. * Skeleton of the source mesh
  19060. */
  19061. readonly skeleton: Nullable<Skeleton>;
  19062. /**
  19063. * Rendering ground id of the source mesh
  19064. */
  19065. renderingGroupId: number;
  19066. /**
  19067. * Returns the total number of vertices (integer).
  19068. */
  19069. getTotalVertices(): number;
  19070. /**
  19071. * Returns a positive integer : the total number of indices in this mesh geometry.
  19072. * @returns the numner of indices or zero if the mesh has no geometry.
  19073. */
  19074. getTotalIndices(): number;
  19075. /**
  19076. * The source mesh of the instance
  19077. */
  19078. readonly sourceMesh: Mesh;
  19079. /**
  19080. * Is this node ready to be used/rendered
  19081. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19082. * @return {boolean} is it ready
  19083. */
  19084. isReady(completeCheck?: boolean): boolean;
  19085. /**
  19086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19087. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19088. * @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.
  19089. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19090. */
  19091. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19092. /**
  19093. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19094. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19095. * The `data` are either a numeric array either a Float32Array.
  19096. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19097. * 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).
  19098. * Note that a new underlying VertexBuffer object is created each call.
  19099. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19100. *
  19101. * Possible `kind` values :
  19102. * - VertexBuffer.PositionKind
  19103. * - VertexBuffer.UVKind
  19104. * - VertexBuffer.UV2Kind
  19105. * - VertexBuffer.UV3Kind
  19106. * - VertexBuffer.UV4Kind
  19107. * - VertexBuffer.UV5Kind
  19108. * - VertexBuffer.UV6Kind
  19109. * - VertexBuffer.ColorKind
  19110. * - VertexBuffer.MatricesIndicesKind
  19111. * - VertexBuffer.MatricesIndicesExtraKind
  19112. * - VertexBuffer.MatricesWeightsKind
  19113. * - VertexBuffer.MatricesWeightsExtraKind
  19114. *
  19115. * Returns the Mesh.
  19116. */
  19117. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19118. /**
  19119. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19120. * If the mesh has no geometry, it is simply returned as it is.
  19121. * The `data` are either a numeric array either a Float32Array.
  19122. * No new underlying VertexBuffer object is created.
  19123. * 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.
  19124. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19125. *
  19126. * Possible `kind` values :
  19127. * - VertexBuffer.PositionKind
  19128. * - VertexBuffer.UVKind
  19129. * - VertexBuffer.UV2Kind
  19130. * - VertexBuffer.UV3Kind
  19131. * - VertexBuffer.UV4Kind
  19132. * - VertexBuffer.UV5Kind
  19133. * - VertexBuffer.UV6Kind
  19134. * - VertexBuffer.ColorKind
  19135. * - VertexBuffer.MatricesIndicesKind
  19136. * - VertexBuffer.MatricesIndicesExtraKind
  19137. * - VertexBuffer.MatricesWeightsKind
  19138. * - VertexBuffer.MatricesWeightsExtraKind
  19139. *
  19140. * Returns the Mesh.
  19141. */
  19142. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19143. /**
  19144. * Sets the mesh indices.
  19145. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19146. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19147. * This method creates a new index buffer each call.
  19148. * Returns the Mesh.
  19149. */
  19150. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19151. /**
  19152. * Boolean : True if the mesh owns the requested kind of data.
  19153. */
  19154. isVerticesDataPresent(kind: string): boolean;
  19155. /**
  19156. * Returns an array of indices (IndicesArray).
  19157. */
  19158. getIndices(): Nullable<IndicesArray>;
  19159. readonly _positions: Nullable<Vector3[]>;
  19160. /**
  19161. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19162. * This means the mesh underlying bounding box and sphere are recomputed.
  19163. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19164. * @returns the current mesh
  19165. */
  19166. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19167. /** @hidden */
  19168. _preActivate(): InstancedMesh;
  19169. /** @hidden */
  19170. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19171. /** @hidden */
  19172. _postActivate(): void;
  19173. getWorldMatrix(): Matrix;
  19174. readonly isAnInstance: boolean;
  19175. /**
  19176. * Returns the current associated LOD AbstractMesh.
  19177. */
  19178. getLOD(camera: Camera): AbstractMesh;
  19179. /** @hidden */
  19180. _syncSubMeshes(): InstancedMesh;
  19181. /** @hidden */
  19182. _generatePointsArray(): boolean;
  19183. /**
  19184. * Creates a new InstancedMesh from the current mesh.
  19185. * - name (string) : the cloned mesh name
  19186. * - newParent (optional Node) : the optional Node to parent the clone to.
  19187. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19188. *
  19189. * Returns the clone.
  19190. */
  19191. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19192. /**
  19193. * Disposes the InstancedMesh.
  19194. * Returns nothing.
  19195. */
  19196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19197. }
  19198. }
  19199. declare module "babylonjs/Materials/shaderMaterial" {
  19200. import { Scene } from "babylonjs/scene";
  19201. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19203. import { Mesh } from "babylonjs/Meshes/mesh";
  19204. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19206. import { Texture } from "babylonjs/Materials/Textures/texture";
  19207. import { Material } from "babylonjs/Materials/material";
  19208. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19209. /**
  19210. * Defines the options associated with the creation of a shader material.
  19211. */
  19212. export interface IShaderMaterialOptions {
  19213. /**
  19214. * Does the material work in alpha blend mode
  19215. */
  19216. needAlphaBlending: boolean;
  19217. /**
  19218. * Does the material work in alpha test mode
  19219. */
  19220. needAlphaTesting: boolean;
  19221. /**
  19222. * The list of attribute names used in the shader
  19223. */
  19224. attributes: string[];
  19225. /**
  19226. * The list of unifrom names used in the shader
  19227. */
  19228. uniforms: string[];
  19229. /**
  19230. * The list of UBO names used in the shader
  19231. */
  19232. uniformBuffers: string[];
  19233. /**
  19234. * The list of sampler names used in the shader
  19235. */
  19236. samplers: string[];
  19237. /**
  19238. * The list of defines used in the shader
  19239. */
  19240. defines: string[];
  19241. }
  19242. /**
  19243. * 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.
  19244. *
  19245. * This returned material effects how the mesh will look based on the code in the shaders.
  19246. *
  19247. * @see http://doc.babylonjs.com/how_to/shader_material
  19248. */
  19249. export class ShaderMaterial extends Material {
  19250. private _shaderPath;
  19251. private _options;
  19252. private _textures;
  19253. private _textureArrays;
  19254. private _floats;
  19255. private _ints;
  19256. private _floatsArrays;
  19257. private _colors3;
  19258. private _colors3Arrays;
  19259. private _colors4;
  19260. private _colors4Arrays;
  19261. private _vectors2;
  19262. private _vectors3;
  19263. private _vectors4;
  19264. private _matrices;
  19265. private _matrices3x3;
  19266. private _matrices2x2;
  19267. private _vectors2Arrays;
  19268. private _vectors3Arrays;
  19269. private _vectors4Arrays;
  19270. private _cachedWorldViewMatrix;
  19271. private _cachedWorldViewProjectionMatrix;
  19272. private _renderId;
  19273. /**
  19274. * Instantiate a new shader material.
  19275. * 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.
  19276. * This returned material effects how the mesh will look based on the code in the shaders.
  19277. * @see http://doc.babylonjs.com/how_to/shader_material
  19278. * @param name Define the name of the material in the scene
  19279. * @param scene Define the scene the material belongs to
  19280. * @param shaderPath Defines the route to the shader code in one of three ways:
  19281. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19282. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19283. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19284. * @param options Define the options used to create the shader
  19285. */
  19286. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19287. /**
  19288. * Gets the options used to compile the shader.
  19289. * They can be modified to trigger a new compilation
  19290. */
  19291. readonly options: IShaderMaterialOptions;
  19292. /**
  19293. * Gets the current class name of the material e.g. "ShaderMaterial"
  19294. * Mainly use in serialization.
  19295. * @returns the class name
  19296. */
  19297. getClassName(): string;
  19298. /**
  19299. * Specifies if the material will require alpha blending
  19300. * @returns a boolean specifying if alpha blending is needed
  19301. */
  19302. needAlphaBlending(): boolean;
  19303. /**
  19304. * Specifies if this material should be rendered in alpha test mode
  19305. * @returns a boolean specifying if an alpha test is needed.
  19306. */
  19307. needAlphaTesting(): boolean;
  19308. private _checkUniform;
  19309. /**
  19310. * Set a texture in the shader.
  19311. * @param name Define the name of the uniform samplers as defined in the shader
  19312. * @param texture Define the texture to bind to this sampler
  19313. * @return the material itself allowing "fluent" like uniform updates
  19314. */
  19315. setTexture(name: string, texture: Texture): ShaderMaterial;
  19316. /**
  19317. * Set a texture array in the shader.
  19318. * @param name Define the name of the uniform sampler array as defined in the shader
  19319. * @param textures Define the list of textures to bind to this sampler
  19320. * @return the material itself allowing "fluent" like uniform updates
  19321. */
  19322. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19323. /**
  19324. * Set a float in the shader.
  19325. * @param name Define the name of the uniform as defined in the shader
  19326. * @param value Define the value to give to the uniform
  19327. * @return the material itself allowing "fluent" like uniform updates
  19328. */
  19329. setFloat(name: string, value: number): ShaderMaterial;
  19330. /**
  19331. * Set a int in the shader.
  19332. * @param name Define the name of the uniform as defined in the shader
  19333. * @param value Define the value to give to the uniform
  19334. * @return the material itself allowing "fluent" like uniform updates
  19335. */
  19336. setInt(name: string, value: number): ShaderMaterial;
  19337. /**
  19338. * Set an array of floats in the shader.
  19339. * @param name Define the name of the uniform as defined in the shader
  19340. * @param value Define the value to give to the uniform
  19341. * @return the material itself allowing "fluent" like uniform updates
  19342. */
  19343. setFloats(name: string, value: number[]): ShaderMaterial;
  19344. /**
  19345. * Set a vec3 in the shader from a Color3.
  19346. * @param name Define the name of the uniform as defined in the shader
  19347. * @param value Define the value to give to the uniform
  19348. * @return the material itself allowing "fluent" like uniform updates
  19349. */
  19350. setColor3(name: string, value: Color3): ShaderMaterial;
  19351. /**
  19352. * Set a vec3 array in the shader from a Color3 array.
  19353. * @param name Define the name of the uniform as defined in the shader
  19354. * @param value Define the value to give to the uniform
  19355. * @return the material itself allowing "fluent" like uniform updates
  19356. */
  19357. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19358. /**
  19359. * Set a vec4 in the shader from a Color4.
  19360. * @param name Define the name of the uniform as defined in the shader
  19361. * @param value Define the value to give to the uniform
  19362. * @return the material itself allowing "fluent" like uniform updates
  19363. */
  19364. setColor4(name: string, value: Color4): ShaderMaterial;
  19365. /**
  19366. * Set a vec4 array in the shader from a Color4 array.
  19367. * @param name Define the name of the uniform as defined in the shader
  19368. * @param value Define the value to give to the uniform
  19369. * @return the material itself allowing "fluent" like uniform updates
  19370. */
  19371. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19372. /**
  19373. * Set a vec2 in the shader from a Vector2.
  19374. * @param name Define the name of the uniform as defined in the shader
  19375. * @param value Define the value to give to the uniform
  19376. * @return the material itself allowing "fluent" like uniform updates
  19377. */
  19378. setVector2(name: string, value: Vector2): ShaderMaterial;
  19379. /**
  19380. * Set a vec3 in the shader from a Vector3.
  19381. * @param name Define the name of the uniform as defined in the shader
  19382. * @param value Define the value to give to the uniform
  19383. * @return the material itself allowing "fluent" like uniform updates
  19384. */
  19385. setVector3(name: string, value: Vector3): ShaderMaterial;
  19386. /**
  19387. * Set a vec4 in the shader from a Vector4.
  19388. * @param name Define the name of the uniform as defined in the shader
  19389. * @param value Define the value to give to the uniform
  19390. * @return the material itself allowing "fluent" like uniform updates
  19391. */
  19392. setVector4(name: string, value: Vector4): ShaderMaterial;
  19393. /**
  19394. * Set a mat4 in the shader from a Matrix.
  19395. * @param name Define the name of the uniform as defined in the shader
  19396. * @param value Define the value to give to the uniform
  19397. * @return the material itself allowing "fluent" like uniform updates
  19398. */
  19399. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19400. /**
  19401. * Set a mat3 in the shader from a Float32Array.
  19402. * @param name Define the name of the uniform as defined in the shader
  19403. * @param value Define the value to give to the uniform
  19404. * @return the material itself allowing "fluent" like uniform updates
  19405. */
  19406. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19407. /**
  19408. * Set a mat2 in the shader from a Float32Array.
  19409. * @param name Define the name of the uniform as defined in the shader
  19410. * @param value Define the value to give to the uniform
  19411. * @return the material itself allowing "fluent" like uniform updates
  19412. */
  19413. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19414. /**
  19415. * Set a vec2 array in the shader from a number array.
  19416. * @param name Define the name of the uniform as defined in the shader
  19417. * @param value Define the value to give to the uniform
  19418. * @return the material itself allowing "fluent" like uniform updates
  19419. */
  19420. setArray2(name: string, value: number[]): ShaderMaterial;
  19421. /**
  19422. * Set a vec3 array in the shader from a number array.
  19423. * @param name Define the name of the uniform as defined in the shader
  19424. * @param value Define the value to give to the uniform
  19425. * @return the material itself allowing "fluent" like uniform updates
  19426. */
  19427. setArray3(name: string, value: number[]): ShaderMaterial;
  19428. /**
  19429. * Set a vec4 array in the shader from a number array.
  19430. * @param name Define the name of the uniform as defined in the shader
  19431. * @param value Define the value to give to the uniform
  19432. * @return the material itself allowing "fluent" like uniform updates
  19433. */
  19434. setArray4(name: string, value: number[]): ShaderMaterial;
  19435. private _checkCache;
  19436. /**
  19437. * Specifies that the submesh is ready to be used
  19438. * @param mesh defines the mesh to check
  19439. * @param subMesh defines which submesh to check
  19440. * @param useInstances specifies that instances should be used
  19441. * @returns a boolean indicating that the submesh is ready or not
  19442. */
  19443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19444. /**
  19445. * Checks if the material is ready to render the requested mesh
  19446. * @param mesh Define the mesh to render
  19447. * @param useInstances Define whether or not the material is used with instances
  19448. * @returns true if ready, otherwise false
  19449. */
  19450. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19451. /**
  19452. * Binds the world matrix to the material
  19453. * @param world defines the world transformation matrix
  19454. */
  19455. bindOnlyWorldMatrix(world: Matrix): void;
  19456. /**
  19457. * Binds the material to the mesh
  19458. * @param world defines the world transformation matrix
  19459. * @param mesh defines the mesh to bind the material to
  19460. */
  19461. bind(world: Matrix, mesh?: Mesh): void;
  19462. /**
  19463. * Gets the active textures from the material
  19464. * @returns an array of textures
  19465. */
  19466. getActiveTextures(): BaseTexture[];
  19467. /**
  19468. * Specifies if the material uses a texture
  19469. * @param texture defines the texture to check against the material
  19470. * @returns a boolean specifying if the material uses the texture
  19471. */
  19472. hasTexture(texture: BaseTexture): boolean;
  19473. /**
  19474. * Makes a duplicate of the material, and gives it a new name
  19475. * @param name defines the new name for the duplicated material
  19476. * @returns the cloned material
  19477. */
  19478. clone(name: string): ShaderMaterial;
  19479. /**
  19480. * Disposes the material
  19481. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19482. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19483. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19484. */
  19485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19486. /**
  19487. * Serializes this material in a JSON representation
  19488. * @returns the serialized material object
  19489. */
  19490. serialize(): any;
  19491. /**
  19492. * Creates a shader material from parsed shader material data
  19493. * @param source defines the JSON represnetation of the material
  19494. * @param scene defines the hosting scene
  19495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19496. * @returns a new material
  19497. */
  19498. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19499. }
  19500. }
  19501. declare module "babylonjs/Shaders/color.fragment" {
  19502. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19504. /** @hidden */
  19505. export var colorPixelShader: {
  19506. name: string;
  19507. shader: string;
  19508. };
  19509. }
  19510. declare module "babylonjs/Shaders/color.vertex" {
  19511. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19514. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19515. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19516. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19517. /** @hidden */
  19518. export var colorVertexShader: {
  19519. name: string;
  19520. shader: string;
  19521. };
  19522. }
  19523. declare module "babylonjs/Meshes/linesMesh" {
  19524. import { Nullable } from "babylonjs/types";
  19525. import { Scene } from "babylonjs/scene";
  19526. import { Color3 } from "babylonjs/Maths/math.color";
  19527. import { Node } from "babylonjs/node";
  19528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19529. import { Mesh } from "babylonjs/Meshes/mesh";
  19530. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19531. import { Effect } from "babylonjs/Materials/effect";
  19532. import { Material } from "babylonjs/Materials/material";
  19533. import "babylonjs/Shaders/color.fragment";
  19534. import "babylonjs/Shaders/color.vertex";
  19535. /**
  19536. * Line mesh
  19537. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19538. */
  19539. export class LinesMesh extends Mesh {
  19540. /**
  19541. * If vertex color should be applied to the mesh
  19542. */
  19543. readonly useVertexColor?: boolean | undefined;
  19544. /**
  19545. * If vertex alpha should be applied to the mesh
  19546. */
  19547. readonly useVertexAlpha?: boolean | undefined;
  19548. /**
  19549. * Color of the line (Default: White)
  19550. */
  19551. color: Color3;
  19552. /**
  19553. * Alpha of the line (Default: 1)
  19554. */
  19555. alpha: number;
  19556. /**
  19557. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19558. * This margin is expressed in world space coordinates, so its value may vary.
  19559. * Default value is 0.1
  19560. */
  19561. intersectionThreshold: number;
  19562. private _colorShader;
  19563. private color4;
  19564. /**
  19565. * Creates a new LinesMesh
  19566. * @param name defines the name
  19567. * @param scene defines the hosting scene
  19568. * @param parent defines the parent mesh if any
  19569. * @param source defines the optional source LinesMesh used to clone data from
  19570. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19571. * When false, achieved by calling a clone(), also passing False.
  19572. * This will make creation of children, recursive.
  19573. * @param useVertexColor defines if this LinesMesh supports vertex color
  19574. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19575. */
  19576. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19577. /**
  19578. * If vertex color should be applied to the mesh
  19579. */
  19580. useVertexColor?: boolean | undefined,
  19581. /**
  19582. * If vertex alpha should be applied to the mesh
  19583. */
  19584. useVertexAlpha?: boolean | undefined);
  19585. private _addClipPlaneDefine;
  19586. private _removeClipPlaneDefine;
  19587. isReady(): boolean;
  19588. /**
  19589. * Returns the string "LineMesh"
  19590. */
  19591. getClassName(): string;
  19592. /**
  19593. * @hidden
  19594. */
  19595. /**
  19596. * @hidden
  19597. */
  19598. material: Material;
  19599. /**
  19600. * @hidden
  19601. */
  19602. readonly checkCollisions: boolean;
  19603. /** @hidden */
  19604. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19605. /** @hidden */
  19606. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19607. /**
  19608. * Disposes of the line mesh
  19609. * @param doNotRecurse If children should be disposed
  19610. */
  19611. dispose(doNotRecurse?: boolean): void;
  19612. /**
  19613. * Returns a new LineMesh object cloned from the current one.
  19614. */
  19615. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19616. /**
  19617. * Creates a new InstancedLinesMesh object from the mesh model.
  19618. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19619. * @param name defines the name of the new instance
  19620. * @returns a new InstancedLinesMesh
  19621. */
  19622. createInstance(name: string): InstancedLinesMesh;
  19623. }
  19624. /**
  19625. * Creates an instance based on a source LinesMesh
  19626. */
  19627. export class InstancedLinesMesh extends InstancedMesh {
  19628. /**
  19629. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19630. * This margin is expressed in world space coordinates, so its value may vary.
  19631. * Initilized with the intersectionThreshold value of the source LinesMesh
  19632. */
  19633. intersectionThreshold: number;
  19634. constructor(name: string, source: LinesMesh);
  19635. /**
  19636. * Returns the string "InstancedLinesMesh".
  19637. */
  19638. getClassName(): string;
  19639. }
  19640. }
  19641. declare module "babylonjs/Shaders/line.fragment" {
  19642. /** @hidden */
  19643. export var linePixelShader: {
  19644. name: string;
  19645. shader: string;
  19646. };
  19647. }
  19648. declare module "babylonjs/Shaders/line.vertex" {
  19649. /** @hidden */
  19650. export var lineVertexShader: {
  19651. name: string;
  19652. shader: string;
  19653. };
  19654. }
  19655. declare module "babylonjs/Rendering/edgesRenderer" {
  19656. import { Nullable } from "babylonjs/types";
  19657. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19659. import { Vector3 } from "babylonjs/Maths/math.vector";
  19660. import { IDisposable } from "babylonjs/scene";
  19661. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19662. import "babylonjs/Shaders/line.fragment";
  19663. import "babylonjs/Shaders/line.vertex";
  19664. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19665. module "babylonjs/Meshes/abstractMesh" {
  19666. interface AbstractMesh {
  19667. /**
  19668. * Gets the edgesRenderer associated with the mesh
  19669. */
  19670. edgesRenderer: Nullable<EdgesRenderer>;
  19671. }
  19672. }
  19673. module "babylonjs/Meshes/linesMesh" {
  19674. interface LinesMesh {
  19675. /**
  19676. * Enables the edge rendering mode on the mesh.
  19677. * This mode makes the mesh edges visible
  19678. * @param epsilon defines the maximal distance between two angles to detect a face
  19679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19680. * @returns the currentAbstractMesh
  19681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19682. */
  19683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19684. }
  19685. }
  19686. module "babylonjs/Meshes/linesMesh" {
  19687. interface InstancedLinesMesh {
  19688. /**
  19689. * Enables the edge rendering mode on the mesh.
  19690. * This mode makes the mesh edges visible
  19691. * @param epsilon defines the maximal distance between two angles to detect a face
  19692. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19693. * @returns the current InstancedLinesMesh
  19694. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19695. */
  19696. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19697. }
  19698. }
  19699. /**
  19700. * Defines the minimum contract an Edges renderer should follow.
  19701. */
  19702. export interface IEdgesRenderer extends IDisposable {
  19703. /**
  19704. * Gets or sets a boolean indicating if the edgesRenderer is active
  19705. */
  19706. isEnabled: boolean;
  19707. /**
  19708. * Renders the edges of the attached mesh,
  19709. */
  19710. render(): void;
  19711. /**
  19712. * Checks wether or not the edges renderer is ready to render.
  19713. * @return true if ready, otherwise false.
  19714. */
  19715. isReady(): boolean;
  19716. }
  19717. /**
  19718. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19719. */
  19720. export class EdgesRenderer implements IEdgesRenderer {
  19721. /**
  19722. * Define the size of the edges with an orthographic camera
  19723. */
  19724. edgesWidthScalerForOrthographic: number;
  19725. /**
  19726. * Define the size of the edges with a perspective camera
  19727. */
  19728. edgesWidthScalerForPerspective: number;
  19729. protected _source: AbstractMesh;
  19730. protected _linesPositions: number[];
  19731. protected _linesNormals: number[];
  19732. protected _linesIndices: number[];
  19733. protected _epsilon: number;
  19734. protected _indicesCount: number;
  19735. protected _lineShader: ShaderMaterial;
  19736. protected _ib: DataBuffer;
  19737. protected _buffers: {
  19738. [key: string]: Nullable<VertexBuffer>;
  19739. };
  19740. protected _checkVerticesInsteadOfIndices: boolean;
  19741. private _meshRebuildObserver;
  19742. private _meshDisposeObserver;
  19743. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19744. isEnabled: boolean;
  19745. /**
  19746. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19747. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19748. * @param source Mesh used to create edges
  19749. * @param epsilon sum of angles in adjacency to check for edge
  19750. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19751. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19752. */
  19753. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19754. protected _prepareRessources(): void;
  19755. /** @hidden */
  19756. _rebuild(): void;
  19757. /**
  19758. * Releases the required resources for the edges renderer
  19759. */
  19760. dispose(): void;
  19761. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19762. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19763. /**
  19764. * Checks if the pair of p0 and p1 is en edge
  19765. * @param faceIndex
  19766. * @param edge
  19767. * @param faceNormals
  19768. * @param p0
  19769. * @param p1
  19770. * @private
  19771. */
  19772. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19773. /**
  19774. * push line into the position, normal and index buffer
  19775. * @protected
  19776. */
  19777. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19778. /**
  19779. * Generates lines edges from adjacencjes
  19780. * @private
  19781. */
  19782. _generateEdgesLines(): void;
  19783. /**
  19784. * Checks wether or not the edges renderer is ready to render.
  19785. * @return true if ready, otherwise false.
  19786. */
  19787. isReady(): boolean;
  19788. /**
  19789. * Renders the edges of the attached mesh,
  19790. */
  19791. render(): void;
  19792. }
  19793. /**
  19794. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19795. */
  19796. export class LineEdgesRenderer extends EdgesRenderer {
  19797. /**
  19798. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19799. * @param source LineMesh used to generate edges
  19800. * @param epsilon not important (specified angle for edge detection)
  19801. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19802. */
  19803. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19804. /**
  19805. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19806. */
  19807. _generateEdgesLines(): void;
  19808. }
  19809. }
  19810. declare module "babylonjs/Rendering/renderingGroup" {
  19811. import { SmartArray } from "babylonjs/Misc/smartArray";
  19812. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Nullable } from "babylonjs/types";
  19815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19816. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19817. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19818. import { Material } from "babylonjs/Materials/material";
  19819. import { Scene } from "babylonjs/scene";
  19820. /**
  19821. * This represents the object necessary to create a rendering group.
  19822. * This is exclusively used and created by the rendering manager.
  19823. * To modify the behavior, you use the available helpers in your scene or meshes.
  19824. * @hidden
  19825. */
  19826. export class RenderingGroup {
  19827. index: number;
  19828. private static _zeroVector;
  19829. private _scene;
  19830. private _opaqueSubMeshes;
  19831. private _transparentSubMeshes;
  19832. private _alphaTestSubMeshes;
  19833. private _depthOnlySubMeshes;
  19834. private _particleSystems;
  19835. private _spriteManagers;
  19836. private _opaqueSortCompareFn;
  19837. private _alphaTestSortCompareFn;
  19838. private _transparentSortCompareFn;
  19839. private _renderOpaque;
  19840. private _renderAlphaTest;
  19841. private _renderTransparent;
  19842. /** @hidden */
  19843. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19844. onBeforeTransparentRendering: () => void;
  19845. /**
  19846. * Set the opaque sort comparison function.
  19847. * If null the sub meshes will be render in the order they were created
  19848. */
  19849. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19850. /**
  19851. * Set the alpha test sort comparison function.
  19852. * If null the sub meshes will be render in the order they were created
  19853. */
  19854. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19855. /**
  19856. * Set the transparent sort comparison function.
  19857. * If null the sub meshes will be render in the order they were created
  19858. */
  19859. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19860. /**
  19861. * Creates a new rendering group.
  19862. * @param index The rendering group index
  19863. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19864. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19865. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19866. */
  19867. 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>);
  19868. /**
  19869. * Render all the sub meshes contained in the group.
  19870. * @param customRenderFunction Used to override the default render behaviour of the group.
  19871. * @returns true if rendered some submeshes.
  19872. */
  19873. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19874. /**
  19875. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19876. * @param subMeshes The submeshes to render
  19877. */
  19878. private renderOpaqueSorted;
  19879. /**
  19880. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19881. * @param subMeshes The submeshes to render
  19882. */
  19883. private renderAlphaTestSorted;
  19884. /**
  19885. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19886. * @param subMeshes The submeshes to render
  19887. */
  19888. private renderTransparentSorted;
  19889. /**
  19890. * Renders the submeshes in a specified order.
  19891. * @param subMeshes The submeshes to sort before render
  19892. * @param sortCompareFn The comparison function use to sort
  19893. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19894. * @param transparent Specifies to activate blending if true
  19895. */
  19896. private static renderSorted;
  19897. /**
  19898. * Renders the submeshes in the order they were dispatched (no sort applied).
  19899. * @param subMeshes The submeshes to render
  19900. */
  19901. private static renderUnsorted;
  19902. /**
  19903. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19904. * are rendered back to front if in the same alpha index.
  19905. *
  19906. * @param a The first submesh
  19907. * @param b The second submesh
  19908. * @returns The result of the comparison
  19909. */
  19910. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19911. /**
  19912. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19913. * are rendered back to front.
  19914. *
  19915. * @param a The first submesh
  19916. * @param b The second submesh
  19917. * @returns The result of the comparison
  19918. */
  19919. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19920. /**
  19921. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19922. * are rendered front to back (prevent overdraw).
  19923. *
  19924. * @param a The first submesh
  19925. * @param b The second submesh
  19926. * @returns The result of the comparison
  19927. */
  19928. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19929. /**
  19930. * Resets the different lists of submeshes to prepare a new frame.
  19931. */
  19932. prepare(): void;
  19933. dispose(): void;
  19934. /**
  19935. * Inserts the submesh in its correct queue depending on its material.
  19936. * @param subMesh The submesh to dispatch
  19937. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19938. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19939. */
  19940. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19941. dispatchSprites(spriteManager: ISpriteManager): void;
  19942. dispatchParticles(particleSystem: IParticleSystem): void;
  19943. private _renderParticles;
  19944. private _renderSprites;
  19945. }
  19946. }
  19947. declare module "babylonjs/Rendering/renderingManager" {
  19948. import { Nullable } from "babylonjs/types";
  19949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19951. import { SmartArray } from "babylonjs/Misc/smartArray";
  19952. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19953. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19954. import { Material } from "babylonjs/Materials/material";
  19955. import { Scene } from "babylonjs/scene";
  19956. import { Camera } from "babylonjs/Cameras/camera";
  19957. /**
  19958. * Interface describing the different options available in the rendering manager
  19959. * regarding Auto Clear between groups.
  19960. */
  19961. export interface IRenderingManagerAutoClearSetup {
  19962. /**
  19963. * Defines whether or not autoclear is enable.
  19964. */
  19965. autoClear: boolean;
  19966. /**
  19967. * Defines whether or not to autoclear the depth buffer.
  19968. */
  19969. depth: boolean;
  19970. /**
  19971. * Defines whether or not to autoclear the stencil buffer.
  19972. */
  19973. stencil: boolean;
  19974. }
  19975. /**
  19976. * This class is used by the onRenderingGroupObservable
  19977. */
  19978. export class RenderingGroupInfo {
  19979. /**
  19980. * The Scene that being rendered
  19981. */
  19982. scene: Scene;
  19983. /**
  19984. * The camera currently used for the rendering pass
  19985. */
  19986. camera: Nullable<Camera>;
  19987. /**
  19988. * The ID of the renderingGroup being processed
  19989. */
  19990. renderingGroupId: number;
  19991. }
  19992. /**
  19993. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19994. * It is enable to manage the different groups as well as the different necessary sort functions.
  19995. * This should not be used directly aside of the few static configurations
  19996. */
  19997. export class RenderingManager {
  19998. /**
  19999. * The max id used for rendering groups (not included)
  20000. */
  20001. static MAX_RENDERINGGROUPS: number;
  20002. /**
  20003. * The min id used for rendering groups (included)
  20004. */
  20005. static MIN_RENDERINGGROUPS: number;
  20006. /**
  20007. * Used to globally prevent autoclearing scenes.
  20008. */
  20009. static AUTOCLEAR: boolean;
  20010. /**
  20011. * @hidden
  20012. */
  20013. _useSceneAutoClearSetup: boolean;
  20014. private _scene;
  20015. private _renderingGroups;
  20016. private _depthStencilBufferAlreadyCleaned;
  20017. private _autoClearDepthStencil;
  20018. private _customOpaqueSortCompareFn;
  20019. private _customAlphaTestSortCompareFn;
  20020. private _customTransparentSortCompareFn;
  20021. private _renderingGroupInfo;
  20022. /**
  20023. * Instantiates a new rendering group for a particular scene
  20024. * @param scene Defines the scene the groups belongs to
  20025. */
  20026. constructor(scene: Scene);
  20027. private _clearDepthStencilBuffer;
  20028. /**
  20029. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20030. * @hidden
  20031. */
  20032. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20033. /**
  20034. * Resets the different information of the group to prepare a new frame
  20035. * @hidden
  20036. */
  20037. reset(): void;
  20038. /**
  20039. * Dispose and release the group and its associated resources.
  20040. * @hidden
  20041. */
  20042. dispose(): void;
  20043. /**
  20044. * Clear the info related to rendering groups preventing retention points during dispose.
  20045. */
  20046. freeRenderingGroups(): void;
  20047. private _prepareRenderingGroup;
  20048. /**
  20049. * Add a sprite manager to the rendering manager in order to render it this frame.
  20050. * @param spriteManager Define the sprite manager to render
  20051. */
  20052. dispatchSprites(spriteManager: ISpriteManager): void;
  20053. /**
  20054. * Add a particle system to the rendering manager in order to render it this frame.
  20055. * @param particleSystem Define the particle system to render
  20056. */
  20057. dispatchParticles(particleSystem: IParticleSystem): void;
  20058. /**
  20059. * Add a submesh to the manager in order to render it this frame
  20060. * @param subMesh The submesh to dispatch
  20061. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20062. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20063. */
  20064. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20065. /**
  20066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20067. * This allowed control for front to back rendering or reversly depending of the special needs.
  20068. *
  20069. * @param renderingGroupId The rendering group id corresponding to its index
  20070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20073. */
  20074. 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;
  20075. /**
  20076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20077. *
  20078. * @param renderingGroupId The rendering group id corresponding to its index
  20079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20080. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20081. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20082. */
  20083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20084. /**
  20085. * Gets the current auto clear configuration for one rendering group of the rendering
  20086. * manager.
  20087. * @param index the rendering group index to get the information for
  20088. * @returns The auto clear setup for the requested rendering group
  20089. */
  20090. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20091. }
  20092. }
  20093. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20094. import { Observable } from "babylonjs/Misc/observable";
  20095. import { SmartArray } from "babylonjs/Misc/smartArray";
  20096. import { Nullable } from "babylonjs/types";
  20097. import { Camera } from "babylonjs/Cameras/camera";
  20098. import { Scene } from "babylonjs/scene";
  20099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20100. import { Color4 } from "babylonjs/Maths/math.color";
  20101. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20104. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20105. import { Texture } from "babylonjs/Materials/Textures/texture";
  20106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20107. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20108. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20109. import { Engine } from "babylonjs/Engines/engine";
  20110. /**
  20111. * This Helps creating a texture that will be created from a camera in your scene.
  20112. * It is basically a dynamic texture that could be used to create special effects for instance.
  20113. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20114. */
  20115. export class RenderTargetTexture extends Texture {
  20116. isCube: boolean;
  20117. /**
  20118. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20119. */
  20120. static readonly REFRESHRATE_RENDER_ONCE: number;
  20121. /**
  20122. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20123. */
  20124. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20125. /**
  20126. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20127. * the central point of your effect and can save a lot of performances.
  20128. */
  20129. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20130. /**
  20131. * Use this predicate to dynamically define the list of mesh you want to render.
  20132. * If set, the renderList property will be overwritten.
  20133. */
  20134. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20135. private _renderList;
  20136. /**
  20137. * Use this list to define the list of mesh you want to render.
  20138. */
  20139. renderList: Nullable<Array<AbstractMesh>>;
  20140. private _hookArray;
  20141. /**
  20142. * Define if particles should be rendered in your texture.
  20143. */
  20144. renderParticles: boolean;
  20145. /**
  20146. * Define if sprites should be rendered in your texture.
  20147. */
  20148. renderSprites: boolean;
  20149. /**
  20150. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20151. */
  20152. coordinatesMode: number;
  20153. /**
  20154. * Define the camera used to render the texture.
  20155. */
  20156. activeCamera: Nullable<Camera>;
  20157. /**
  20158. * Override the render function of the texture with your own one.
  20159. */
  20160. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20161. /**
  20162. * Define if camera post processes should be use while rendering the texture.
  20163. */
  20164. useCameraPostProcesses: boolean;
  20165. /**
  20166. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20167. */
  20168. ignoreCameraViewport: boolean;
  20169. private _postProcessManager;
  20170. private _postProcesses;
  20171. private _resizeObserver;
  20172. /**
  20173. * An event triggered when the texture is unbind.
  20174. */
  20175. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20176. /**
  20177. * An event triggered when the texture is unbind.
  20178. */
  20179. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20180. private _onAfterUnbindObserver;
  20181. /**
  20182. * Set a after unbind callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20184. */
  20185. onAfterUnbind: () => void;
  20186. /**
  20187. * An event triggered before rendering the texture
  20188. */
  20189. onBeforeRenderObservable: Observable<number>;
  20190. private _onBeforeRenderObserver;
  20191. /**
  20192. * Set a before render callback in the texture.
  20193. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20194. */
  20195. onBeforeRender: (faceIndex: number) => void;
  20196. /**
  20197. * An event triggered after rendering the texture
  20198. */
  20199. onAfterRenderObservable: Observable<number>;
  20200. private _onAfterRenderObserver;
  20201. /**
  20202. * Set a after render callback in the texture.
  20203. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20204. */
  20205. onAfterRender: (faceIndex: number) => void;
  20206. /**
  20207. * An event triggered after the texture clear
  20208. */
  20209. onClearObservable: Observable<Engine>;
  20210. private _onClearObserver;
  20211. /**
  20212. * Set a clear callback in the texture.
  20213. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20214. */
  20215. onClear: (Engine: Engine) => void;
  20216. /**
  20217. * An event triggered when the texture is resized.
  20218. */
  20219. onResizeObservable: Observable<RenderTargetTexture>;
  20220. /**
  20221. * Define the clear color of the Render Target if it should be different from the scene.
  20222. */
  20223. clearColor: Color4;
  20224. protected _size: number | {
  20225. width: number;
  20226. height: number;
  20227. };
  20228. protected _initialSizeParameter: number | {
  20229. width: number;
  20230. height: number;
  20231. } | {
  20232. ratio: number;
  20233. };
  20234. protected _sizeRatio: Nullable<number>;
  20235. /** @hidden */
  20236. _generateMipMaps: boolean;
  20237. protected _renderingManager: RenderingManager;
  20238. /** @hidden */
  20239. _waitingRenderList: string[];
  20240. protected _doNotChangeAspectRatio: boolean;
  20241. protected _currentRefreshId: number;
  20242. protected _refreshRate: number;
  20243. protected _textureMatrix: Matrix;
  20244. protected _samples: number;
  20245. protected _renderTargetOptions: RenderTargetCreationOptions;
  20246. /**
  20247. * Gets render target creation options that were used.
  20248. */
  20249. readonly renderTargetOptions: RenderTargetCreationOptions;
  20250. protected _engine: Engine;
  20251. protected _onRatioRescale(): void;
  20252. /**
  20253. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20254. * It must define where the camera used to render the texture is set
  20255. */
  20256. boundingBoxPosition: Vector3;
  20257. private _boundingBoxSize;
  20258. /**
  20259. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20260. * When defined, the cubemap will switch to local mode
  20261. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20262. * @example https://www.babylonjs-playground.com/#RNASML
  20263. */
  20264. boundingBoxSize: Vector3;
  20265. /**
  20266. * In case the RTT has been created with a depth texture, get the associated
  20267. * depth texture.
  20268. * Otherwise, return null.
  20269. */
  20270. depthStencilTexture: Nullable<InternalTexture>;
  20271. /**
  20272. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20273. * or used a shadow, depth texture...
  20274. * @param name The friendly name of the texture
  20275. * @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)
  20276. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20277. * @param generateMipMaps True if mip maps need to be generated after render.
  20278. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20279. * @param type The type of the buffer in the RTT (int, half float, float...)
  20280. * @param isCube True if a cube texture needs to be created
  20281. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20282. * @param generateDepthBuffer True to generate a depth buffer
  20283. * @param generateStencilBuffer True to generate a stencil buffer
  20284. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20285. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20286. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20287. */
  20288. constructor(name: string, size: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20294. /**
  20295. * Creates a depth stencil texture.
  20296. * This is only available in WebGL 2 or with the depth texture extension available.
  20297. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20298. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20299. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20300. */
  20301. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20302. private _processSizeParameter;
  20303. /**
  20304. * Define the number of samples to use in case of MSAA.
  20305. * It defaults to one meaning no MSAA has been enabled.
  20306. */
  20307. samples: number;
  20308. /**
  20309. * Resets the refresh counter of the texture and start bak from scratch.
  20310. * Could be useful to regenerate the texture if it is setup to render only once.
  20311. */
  20312. resetRefreshCounter(): void;
  20313. /**
  20314. * Define the refresh rate of the texture or the rendering frequency.
  20315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20316. */
  20317. refreshRate: number;
  20318. /**
  20319. * Adds a post process to the render target rendering passes.
  20320. * @param postProcess define the post process to add
  20321. */
  20322. addPostProcess(postProcess: PostProcess): void;
  20323. /**
  20324. * Clear all the post processes attached to the render target
  20325. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20326. */
  20327. clearPostProcesses(dispose?: boolean): void;
  20328. /**
  20329. * Remove one of the post process from the list of attached post processes to the texture
  20330. * @param postProcess define the post process to remove from the list
  20331. */
  20332. removePostProcess(postProcess: PostProcess): void;
  20333. /** @hidden */
  20334. _shouldRender(): boolean;
  20335. /**
  20336. * Gets the actual render size of the texture.
  20337. * @returns the width of the render size
  20338. */
  20339. getRenderSize(): number;
  20340. /**
  20341. * Gets the actual render width of the texture.
  20342. * @returns the width of the render size
  20343. */
  20344. getRenderWidth(): number;
  20345. /**
  20346. * Gets the actual render height of the texture.
  20347. * @returns the height of the render size
  20348. */
  20349. getRenderHeight(): number;
  20350. /**
  20351. * Get if the texture can be rescaled or not.
  20352. */
  20353. readonly canRescale: boolean;
  20354. /**
  20355. * Resize the texture using a ratio.
  20356. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20357. */
  20358. scale(ratio: number): void;
  20359. /**
  20360. * Get the texture reflection matrix used to rotate/transform the reflection.
  20361. * @returns the reflection matrix
  20362. */
  20363. getReflectionTextureMatrix(): Matrix;
  20364. /**
  20365. * Resize the texture to a new desired size.
  20366. * Be carrefull as it will recreate all the data in the new texture.
  20367. * @param size Define the new size. It can be:
  20368. * - a number for squared texture,
  20369. * - an object containing { width: number, height: number }
  20370. * - or an object containing a ratio { ratio: number }
  20371. */
  20372. resize(size: number | {
  20373. width: number;
  20374. height: number;
  20375. } | {
  20376. ratio: number;
  20377. }): void;
  20378. /**
  20379. * Renders all the objects from the render list into the texture.
  20380. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20381. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20382. */
  20383. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20384. private _bestReflectionRenderTargetDimension;
  20385. /**
  20386. * @hidden
  20387. * @param faceIndex face index to bind to if this is a cubetexture
  20388. */
  20389. _bindFrameBuffer(faceIndex?: number): void;
  20390. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20391. private renderToTarget;
  20392. /**
  20393. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20394. * This allowed control for front to back rendering or reversly depending of the special needs.
  20395. *
  20396. * @param renderingGroupId The rendering group id corresponding to its index
  20397. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20398. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20399. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20400. */
  20401. 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;
  20402. /**
  20403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20404. *
  20405. * @param renderingGroupId The rendering group id corresponding to its index
  20406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20407. */
  20408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20409. /**
  20410. * Clones the texture.
  20411. * @returns the cloned texture
  20412. */
  20413. clone(): RenderTargetTexture;
  20414. /**
  20415. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20416. * @returns The JSON representation of the texture
  20417. */
  20418. serialize(): any;
  20419. /**
  20420. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20421. */
  20422. disposeFramebufferObjects(): void;
  20423. /**
  20424. * Dispose the texture and release its associated resources.
  20425. */
  20426. dispose(): void;
  20427. /** @hidden */
  20428. _rebuild(): void;
  20429. /**
  20430. * Clear the info related to rendering groups preventing retention point in material dispose.
  20431. */
  20432. freeRenderingGroups(): void;
  20433. /**
  20434. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20435. * @returns the view count
  20436. */
  20437. getViewCount(): number;
  20438. }
  20439. }
  20440. declare module "babylonjs/Materials/material" {
  20441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20442. import { SmartArray } from "babylonjs/Misc/smartArray";
  20443. import { Observable } from "babylonjs/Misc/observable";
  20444. import { Nullable } from "babylonjs/types";
  20445. import { Scene } from "babylonjs/scene";
  20446. import { Matrix } from "babylonjs/Maths/math.vector";
  20447. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20449. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20450. import { Effect } from "babylonjs/Materials/effect";
  20451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20453. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20454. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20455. import { Mesh } from "babylonjs/Meshes/mesh";
  20456. import { Animation } from "babylonjs/Animations/animation";
  20457. /**
  20458. * Base class for the main features of a material in Babylon.js
  20459. */
  20460. export class Material implements IAnimatable {
  20461. /**
  20462. * Returns the triangle fill mode
  20463. */
  20464. static readonly TriangleFillMode: number;
  20465. /**
  20466. * Returns the wireframe mode
  20467. */
  20468. static readonly WireFrameFillMode: number;
  20469. /**
  20470. * Returns the point fill mode
  20471. */
  20472. static readonly PointFillMode: number;
  20473. /**
  20474. * Returns the point list draw mode
  20475. */
  20476. static readonly PointListDrawMode: number;
  20477. /**
  20478. * Returns the line list draw mode
  20479. */
  20480. static readonly LineListDrawMode: number;
  20481. /**
  20482. * Returns the line loop draw mode
  20483. */
  20484. static readonly LineLoopDrawMode: number;
  20485. /**
  20486. * Returns the line strip draw mode
  20487. */
  20488. static readonly LineStripDrawMode: number;
  20489. /**
  20490. * Returns the triangle strip draw mode
  20491. */
  20492. static readonly TriangleStripDrawMode: number;
  20493. /**
  20494. * Returns the triangle fan draw mode
  20495. */
  20496. static readonly TriangleFanDrawMode: number;
  20497. /**
  20498. * Stores the clock-wise side orientation
  20499. */
  20500. static readonly ClockWiseSideOrientation: number;
  20501. /**
  20502. * Stores the counter clock-wise side orientation
  20503. */
  20504. static readonly CounterClockWiseSideOrientation: number;
  20505. /**
  20506. * The dirty texture flag value
  20507. */
  20508. static readonly TextureDirtyFlag: number;
  20509. /**
  20510. * The dirty light flag value
  20511. */
  20512. static readonly LightDirtyFlag: number;
  20513. /**
  20514. * The dirty fresnel flag value
  20515. */
  20516. static readonly FresnelDirtyFlag: number;
  20517. /**
  20518. * The dirty attribute flag value
  20519. */
  20520. static readonly AttributesDirtyFlag: number;
  20521. /**
  20522. * The dirty misc flag value
  20523. */
  20524. static readonly MiscDirtyFlag: number;
  20525. /**
  20526. * The all dirty flag value
  20527. */
  20528. static readonly AllDirtyFlag: number;
  20529. /**
  20530. * The ID of the material
  20531. */
  20532. id: string;
  20533. /**
  20534. * Gets or sets the unique id of the material
  20535. */
  20536. uniqueId: number;
  20537. /**
  20538. * The name of the material
  20539. */
  20540. name: string;
  20541. /**
  20542. * Gets or sets user defined metadata
  20543. */
  20544. metadata: any;
  20545. /**
  20546. * For internal use only. Please do not use.
  20547. */
  20548. reservedDataStore: any;
  20549. /**
  20550. * Specifies if the ready state should be checked on each call
  20551. */
  20552. checkReadyOnEveryCall: boolean;
  20553. /**
  20554. * Specifies if the ready state should be checked once
  20555. */
  20556. checkReadyOnlyOnce: boolean;
  20557. /**
  20558. * The state of the material
  20559. */
  20560. state: string;
  20561. /**
  20562. * The alpha value of the material
  20563. */
  20564. protected _alpha: number;
  20565. /**
  20566. * List of inspectable custom properties (used by the Inspector)
  20567. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20568. */
  20569. inspectableCustomProperties: IInspectable[];
  20570. /**
  20571. * Sets the alpha value of the material
  20572. */
  20573. /**
  20574. * Gets the alpha value of the material
  20575. */
  20576. alpha: number;
  20577. /**
  20578. * Specifies if back face culling is enabled
  20579. */
  20580. protected _backFaceCulling: boolean;
  20581. /**
  20582. * Sets the back-face culling state
  20583. */
  20584. /**
  20585. * Gets the back-face culling state
  20586. */
  20587. backFaceCulling: boolean;
  20588. /**
  20589. * Stores the value for side orientation
  20590. */
  20591. sideOrientation: number;
  20592. /**
  20593. * Callback triggered when the material is compiled
  20594. */
  20595. onCompiled: Nullable<(effect: Effect) => void>;
  20596. /**
  20597. * Callback triggered when an error occurs
  20598. */
  20599. onError: Nullable<(effect: Effect, errors: string) => void>;
  20600. /**
  20601. * Callback triggered to get the render target textures
  20602. */
  20603. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20604. /**
  20605. * Gets a boolean indicating that current material needs to register RTT
  20606. */
  20607. readonly hasRenderTargetTextures: boolean;
  20608. /**
  20609. * Specifies if the material should be serialized
  20610. */
  20611. doNotSerialize: boolean;
  20612. /**
  20613. * @hidden
  20614. */
  20615. _storeEffectOnSubMeshes: boolean;
  20616. /**
  20617. * Stores the animations for the material
  20618. */
  20619. animations: Nullable<Array<Animation>>;
  20620. /**
  20621. * An event triggered when the material is disposed
  20622. */
  20623. onDisposeObservable: Observable<Material>;
  20624. /**
  20625. * An observer which watches for dispose events
  20626. */
  20627. private _onDisposeObserver;
  20628. private _onUnBindObservable;
  20629. /**
  20630. * Called during a dispose event
  20631. */
  20632. onDispose: () => void;
  20633. private _onBindObservable;
  20634. /**
  20635. * An event triggered when the material is bound
  20636. */
  20637. readonly onBindObservable: Observable<AbstractMesh>;
  20638. /**
  20639. * An observer which watches for bind events
  20640. */
  20641. private _onBindObserver;
  20642. /**
  20643. * Called during a bind event
  20644. */
  20645. onBind: (Mesh: AbstractMesh) => void;
  20646. /**
  20647. * An event triggered when the material is unbound
  20648. */
  20649. readonly onUnBindObservable: Observable<Material>;
  20650. /**
  20651. * Stores the value of the alpha mode
  20652. */
  20653. private _alphaMode;
  20654. /**
  20655. * Sets the value of the alpha mode.
  20656. *
  20657. * | Value | Type | Description |
  20658. * | --- | --- | --- |
  20659. * | 0 | ALPHA_DISABLE | |
  20660. * | 1 | ALPHA_ADD | |
  20661. * | 2 | ALPHA_COMBINE | |
  20662. * | 3 | ALPHA_SUBTRACT | |
  20663. * | 4 | ALPHA_MULTIPLY | |
  20664. * | 5 | ALPHA_MAXIMIZED | |
  20665. * | 6 | ALPHA_ONEONE | |
  20666. * | 7 | ALPHA_PREMULTIPLIED | |
  20667. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20668. * | 9 | ALPHA_INTERPOLATE | |
  20669. * | 10 | ALPHA_SCREENMODE | |
  20670. *
  20671. */
  20672. /**
  20673. * Gets the value of the alpha mode
  20674. */
  20675. alphaMode: number;
  20676. /**
  20677. * Stores the state of the need depth pre-pass value
  20678. */
  20679. private _needDepthPrePass;
  20680. /**
  20681. * Sets the need depth pre-pass value
  20682. */
  20683. /**
  20684. * Gets the depth pre-pass value
  20685. */
  20686. needDepthPrePass: boolean;
  20687. /**
  20688. * Specifies if depth writing should be disabled
  20689. */
  20690. disableDepthWrite: boolean;
  20691. /**
  20692. * Specifies if depth writing should be forced
  20693. */
  20694. forceDepthWrite: boolean;
  20695. /**
  20696. * Specifies if there should be a separate pass for culling
  20697. */
  20698. separateCullingPass: boolean;
  20699. /**
  20700. * Stores the state specifing if fog should be enabled
  20701. */
  20702. private _fogEnabled;
  20703. /**
  20704. * Sets the state for enabling fog
  20705. */
  20706. /**
  20707. * Gets the value of the fog enabled state
  20708. */
  20709. fogEnabled: boolean;
  20710. /**
  20711. * Stores the size of points
  20712. */
  20713. pointSize: number;
  20714. /**
  20715. * Stores the z offset value
  20716. */
  20717. zOffset: number;
  20718. /**
  20719. * Gets a value specifying if wireframe mode is enabled
  20720. */
  20721. /**
  20722. * Sets the state of wireframe mode
  20723. */
  20724. wireframe: boolean;
  20725. /**
  20726. * Gets the value specifying if point clouds are enabled
  20727. */
  20728. /**
  20729. * Sets the state of point cloud mode
  20730. */
  20731. pointsCloud: boolean;
  20732. /**
  20733. * Gets the material fill mode
  20734. */
  20735. /**
  20736. * Sets the material fill mode
  20737. */
  20738. fillMode: number;
  20739. /**
  20740. * @hidden
  20741. * Stores the effects for the material
  20742. */
  20743. _effect: Nullable<Effect>;
  20744. /**
  20745. * @hidden
  20746. * Specifies if the material was previously ready
  20747. */
  20748. _wasPreviouslyReady: boolean;
  20749. /**
  20750. * Specifies if uniform buffers should be used
  20751. */
  20752. private _useUBO;
  20753. /**
  20754. * Stores a reference to the scene
  20755. */
  20756. private _scene;
  20757. /**
  20758. * Stores the fill mode state
  20759. */
  20760. private _fillMode;
  20761. /**
  20762. * Specifies if the depth write state should be cached
  20763. */
  20764. private _cachedDepthWriteState;
  20765. /**
  20766. * Stores the uniform buffer
  20767. */
  20768. protected _uniformBuffer: UniformBuffer;
  20769. /** @hidden */
  20770. _indexInSceneMaterialArray: number;
  20771. /** @hidden */
  20772. meshMap: Nullable<{
  20773. [id: string]: AbstractMesh | undefined;
  20774. }>;
  20775. /**
  20776. * Creates a material instance
  20777. * @param name defines the name of the material
  20778. * @param scene defines the scene to reference
  20779. * @param doNotAdd specifies if the material should be added to the scene
  20780. */
  20781. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20782. /**
  20783. * Returns a string representation of the current material
  20784. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20785. * @returns a string with material information
  20786. */
  20787. toString(fullDetails?: boolean): string;
  20788. /**
  20789. * Gets the class name of the material
  20790. * @returns a string with the class name of the material
  20791. */
  20792. getClassName(): string;
  20793. /**
  20794. * Specifies if updates for the material been locked
  20795. */
  20796. readonly isFrozen: boolean;
  20797. /**
  20798. * Locks updates for the material
  20799. */
  20800. freeze(): void;
  20801. /**
  20802. * Unlocks updates for the material
  20803. */
  20804. unfreeze(): void;
  20805. /**
  20806. * Specifies if the material is ready to be used
  20807. * @param mesh defines the mesh to check
  20808. * @param useInstances specifies if instances should be used
  20809. * @returns a boolean indicating if the material is ready to be used
  20810. */
  20811. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20812. /**
  20813. * Specifies that the submesh is ready to be used
  20814. * @param mesh defines the mesh to check
  20815. * @param subMesh defines which submesh to check
  20816. * @param useInstances specifies that instances should be used
  20817. * @returns a boolean indicating that the submesh is ready or not
  20818. */
  20819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20820. /**
  20821. * Returns the material effect
  20822. * @returns the effect associated with the material
  20823. */
  20824. getEffect(): Nullable<Effect>;
  20825. /**
  20826. * Returns the current scene
  20827. * @returns a Scene
  20828. */
  20829. getScene(): Scene;
  20830. /**
  20831. * Specifies if the material will require alpha blending
  20832. * @returns a boolean specifying if alpha blending is needed
  20833. */
  20834. needAlphaBlending(): boolean;
  20835. /**
  20836. * Specifies if the mesh will require alpha blending
  20837. * @param mesh defines the mesh to check
  20838. * @returns a boolean specifying if alpha blending is needed for the mesh
  20839. */
  20840. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20841. /**
  20842. * Specifies if this material should be rendered in alpha test mode
  20843. * @returns a boolean specifying if an alpha test is needed.
  20844. */
  20845. needAlphaTesting(): boolean;
  20846. /**
  20847. * Gets the texture used for the alpha test
  20848. * @returns the texture to use for alpha testing
  20849. */
  20850. getAlphaTestTexture(): Nullable<BaseTexture>;
  20851. /**
  20852. * Marks the material to indicate that it needs to be re-calculated
  20853. */
  20854. markDirty(): void;
  20855. /** @hidden */
  20856. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20857. /**
  20858. * Binds the material to the mesh
  20859. * @param world defines the world transformation matrix
  20860. * @param mesh defines the mesh to bind the material to
  20861. */
  20862. bind(world: Matrix, mesh?: Mesh): void;
  20863. /**
  20864. * Binds the submesh to the material
  20865. * @param world defines the world transformation matrix
  20866. * @param mesh defines the mesh containing the submesh
  20867. * @param subMesh defines the submesh to bind the material to
  20868. */
  20869. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20870. /**
  20871. * Binds the world matrix to the material
  20872. * @param world defines the world transformation matrix
  20873. */
  20874. bindOnlyWorldMatrix(world: Matrix): void;
  20875. /**
  20876. * Binds the scene's uniform buffer to the effect.
  20877. * @param effect defines the effect to bind to the scene uniform buffer
  20878. * @param sceneUbo defines the uniform buffer storing scene data
  20879. */
  20880. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20881. /**
  20882. * Binds the view matrix to the effect
  20883. * @param effect defines the effect to bind the view matrix to
  20884. */
  20885. bindView(effect: Effect): void;
  20886. /**
  20887. * Binds the view projection matrix to the effect
  20888. * @param effect defines the effect to bind the view projection matrix to
  20889. */
  20890. bindViewProjection(effect: Effect): void;
  20891. /**
  20892. * Specifies if material alpha testing should be turned on for the mesh
  20893. * @param mesh defines the mesh to check
  20894. */
  20895. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20896. /**
  20897. * Processes to execute after binding the material to a mesh
  20898. * @param mesh defines the rendered mesh
  20899. */
  20900. protected _afterBind(mesh?: Mesh): void;
  20901. /**
  20902. * Unbinds the material from the mesh
  20903. */
  20904. unbind(): void;
  20905. /**
  20906. * Gets the active textures from the material
  20907. * @returns an array of textures
  20908. */
  20909. getActiveTextures(): BaseTexture[];
  20910. /**
  20911. * Specifies if the material uses a texture
  20912. * @param texture defines the texture to check against the material
  20913. * @returns a boolean specifying if the material uses the texture
  20914. */
  20915. hasTexture(texture: BaseTexture): boolean;
  20916. /**
  20917. * Makes a duplicate of the material, and gives it a new name
  20918. * @param name defines the new name for the duplicated material
  20919. * @returns the cloned material
  20920. */
  20921. clone(name: string): Nullable<Material>;
  20922. /**
  20923. * Gets the meshes bound to the material
  20924. * @returns an array of meshes bound to the material
  20925. */
  20926. getBindedMeshes(): AbstractMesh[];
  20927. /**
  20928. * Force shader compilation
  20929. * @param mesh defines the mesh associated with this material
  20930. * @param onCompiled defines a function to execute once the material is compiled
  20931. * @param options defines the options to configure the compilation
  20932. */
  20933. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20934. clipPlane: boolean;
  20935. }>): void;
  20936. /**
  20937. * Force shader compilation
  20938. * @param mesh defines the mesh that will use this material
  20939. * @param options defines additional options for compiling the shaders
  20940. * @returns a promise that resolves when the compilation completes
  20941. */
  20942. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20943. clipPlane: boolean;
  20944. }>): Promise<void>;
  20945. private static readonly _AllDirtyCallBack;
  20946. private static readonly _ImageProcessingDirtyCallBack;
  20947. private static readonly _TextureDirtyCallBack;
  20948. private static readonly _FresnelDirtyCallBack;
  20949. private static readonly _MiscDirtyCallBack;
  20950. private static readonly _LightsDirtyCallBack;
  20951. private static readonly _AttributeDirtyCallBack;
  20952. private static _FresnelAndMiscDirtyCallBack;
  20953. private static _TextureAndMiscDirtyCallBack;
  20954. private static readonly _DirtyCallbackArray;
  20955. private static readonly _RunDirtyCallBacks;
  20956. /**
  20957. * Marks a define in the material to indicate that it needs to be re-computed
  20958. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20959. */
  20960. markAsDirty(flag: number): void;
  20961. /**
  20962. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20963. * @param func defines a function which checks material defines against the submeshes
  20964. */
  20965. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20966. /**
  20967. * Indicates that we need to re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsAllDirty(): void;
  20970. /**
  20971. * Indicates that image processing needs to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20974. /**
  20975. * Indicates that textures need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsTexturesDirty(): void;
  20978. /**
  20979. * Indicates that fresnel needs to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsFresnelDirty(): void;
  20982. /**
  20983. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20986. /**
  20987. * Indicates that lights need to be re-calculated for all submeshes
  20988. */
  20989. protected _markAllSubMeshesAsLightsDirty(): void;
  20990. /**
  20991. * Indicates that attributes need to be re-calculated for all submeshes
  20992. */
  20993. protected _markAllSubMeshesAsAttributesDirty(): void;
  20994. /**
  20995. * Indicates that misc needs to be re-calculated for all submeshes
  20996. */
  20997. protected _markAllSubMeshesAsMiscDirty(): void;
  20998. /**
  20999. * Indicates that textures and misc need to be re-calculated for all submeshes
  21000. */
  21001. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21002. /**
  21003. * Disposes the material
  21004. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21005. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21006. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21007. */
  21008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21009. /** @hidden */
  21010. private releaseVertexArrayObject;
  21011. /**
  21012. * Serializes this material
  21013. * @returns the serialized material object
  21014. */
  21015. serialize(): any;
  21016. /**
  21017. * Creates a material from parsed material data
  21018. * @param parsedMaterial defines parsed material data
  21019. * @param scene defines the hosting scene
  21020. * @param rootUrl defines the root URL to use to load textures
  21021. * @returns a new material
  21022. */
  21023. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21024. }
  21025. }
  21026. declare module "babylonjs/Materials/multiMaterial" {
  21027. import { Nullable } from "babylonjs/types";
  21028. import { Scene } from "babylonjs/scene";
  21029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21030. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21032. import { Material } from "babylonjs/Materials/material";
  21033. /**
  21034. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21035. * separate meshes. This can be use to improve performances.
  21036. * @see http://doc.babylonjs.com/how_to/multi_materials
  21037. */
  21038. export class MultiMaterial extends Material {
  21039. private _subMaterials;
  21040. /**
  21041. * Gets or Sets the list of Materials used within the multi material.
  21042. * They need to be ordered according to the submeshes order in the associated mesh
  21043. */
  21044. subMaterials: Nullable<Material>[];
  21045. /**
  21046. * Function used to align with Node.getChildren()
  21047. * @returns the list of Materials used within the multi material
  21048. */
  21049. getChildren(): Nullable<Material>[];
  21050. /**
  21051. * Instantiates a new Multi Material
  21052. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21053. * separate meshes. This can be use to improve performances.
  21054. * @see http://doc.babylonjs.com/how_to/multi_materials
  21055. * @param name Define the name in the scene
  21056. * @param scene Define the scene the material belongs to
  21057. */
  21058. constructor(name: string, scene: Scene);
  21059. private _hookArray;
  21060. /**
  21061. * Get one of the submaterial by its index in the submaterials array
  21062. * @param index The index to look the sub material at
  21063. * @returns The Material if the index has been defined
  21064. */
  21065. getSubMaterial(index: number): Nullable<Material>;
  21066. /**
  21067. * Get the list of active textures for the whole sub materials list.
  21068. * @returns All the textures that will be used during the rendering
  21069. */
  21070. getActiveTextures(): BaseTexture[];
  21071. /**
  21072. * Gets the current class name of the material e.g. "MultiMaterial"
  21073. * Mainly use in serialization.
  21074. * @returns the class name
  21075. */
  21076. getClassName(): string;
  21077. /**
  21078. * Checks if the material is ready to render the requested sub mesh
  21079. * @param mesh Define the mesh the submesh belongs to
  21080. * @param subMesh Define the sub mesh to look readyness for
  21081. * @param useInstances Define whether or not the material is used with instances
  21082. * @returns true if ready, otherwise false
  21083. */
  21084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21085. /**
  21086. * Clones the current material and its related sub materials
  21087. * @param name Define the name of the newly cloned material
  21088. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21089. * @returns the cloned material
  21090. */
  21091. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21092. /**
  21093. * Serializes the materials into a JSON representation.
  21094. * @returns the JSON representation
  21095. */
  21096. serialize(): any;
  21097. /**
  21098. * Dispose the material and release its associated resources
  21099. * @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)
  21100. * @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)
  21101. * @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)
  21102. */
  21103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21104. /**
  21105. * Creates a MultiMaterial from parsed MultiMaterial data.
  21106. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21107. * @param scene defines the hosting scene
  21108. * @returns a new MultiMaterial
  21109. */
  21110. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21111. }
  21112. }
  21113. declare module "babylonjs/Meshes/subMesh" {
  21114. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21115. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21116. import { Engine } from "babylonjs/Engines/engine";
  21117. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21118. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21119. import { Effect } from "babylonjs/Materials/effect";
  21120. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21121. import { Plane } from "babylonjs/Maths/math.plane";
  21122. import { Collider } from "babylonjs/Collisions/collider";
  21123. import { Material } from "babylonjs/Materials/material";
  21124. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21126. import { Mesh } from "babylonjs/Meshes/mesh";
  21127. import { Ray } from "babylonjs/Culling/ray";
  21128. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21129. /**
  21130. * Base class for submeshes
  21131. */
  21132. export class BaseSubMesh {
  21133. /** @hidden */
  21134. _materialDefines: Nullable<MaterialDefines>;
  21135. /** @hidden */
  21136. _materialEffect: Nullable<Effect>;
  21137. /**
  21138. * Gets associated effect
  21139. */
  21140. readonly effect: Nullable<Effect>;
  21141. /**
  21142. * Sets associated effect (effect used to render this submesh)
  21143. * @param effect defines the effect to associate with
  21144. * @param defines defines the set of defines used to compile this effect
  21145. */
  21146. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21147. }
  21148. /**
  21149. * Defines a subdivision inside a mesh
  21150. */
  21151. export class SubMesh extends BaseSubMesh implements ICullable {
  21152. /** the material index to use */
  21153. materialIndex: number;
  21154. /** vertex index start */
  21155. verticesStart: number;
  21156. /** vertices count */
  21157. verticesCount: number;
  21158. /** index start */
  21159. indexStart: number;
  21160. /** indices count */
  21161. indexCount: number;
  21162. /** @hidden */
  21163. _linesIndexCount: number;
  21164. private _mesh;
  21165. private _renderingMesh;
  21166. private _boundingInfo;
  21167. private _linesIndexBuffer;
  21168. /** @hidden */
  21169. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21170. /** @hidden */
  21171. _trianglePlanes: Plane[];
  21172. /** @hidden */
  21173. _lastColliderTransformMatrix: Nullable<Matrix>;
  21174. /** @hidden */
  21175. _renderId: number;
  21176. /** @hidden */
  21177. _alphaIndex: number;
  21178. /** @hidden */
  21179. _distanceToCamera: number;
  21180. /** @hidden */
  21181. _id: number;
  21182. private _currentMaterial;
  21183. /**
  21184. * Add a new submesh to a mesh
  21185. * @param materialIndex defines the material index to use
  21186. * @param verticesStart defines vertex index start
  21187. * @param verticesCount defines vertices count
  21188. * @param indexStart defines index start
  21189. * @param indexCount defines indices count
  21190. * @param mesh defines the parent mesh
  21191. * @param renderingMesh defines an optional rendering mesh
  21192. * @param createBoundingBox defines if bounding box should be created for this submesh
  21193. * @returns the new submesh
  21194. */
  21195. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21196. /**
  21197. * Creates a new submesh
  21198. * @param materialIndex defines the material index to use
  21199. * @param verticesStart defines vertex index start
  21200. * @param verticesCount defines vertices count
  21201. * @param indexStart defines index start
  21202. * @param indexCount defines indices count
  21203. * @param mesh defines the parent mesh
  21204. * @param renderingMesh defines an optional rendering mesh
  21205. * @param createBoundingBox defines if bounding box should be created for this submesh
  21206. */
  21207. constructor(
  21208. /** the material index to use */
  21209. materialIndex: number,
  21210. /** vertex index start */
  21211. verticesStart: number,
  21212. /** vertices count */
  21213. verticesCount: number,
  21214. /** index start */
  21215. indexStart: number,
  21216. /** indices count */
  21217. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21218. /**
  21219. * Returns true if this submesh covers the entire parent mesh
  21220. * @ignorenaming
  21221. */
  21222. readonly IsGlobal: boolean;
  21223. /**
  21224. * Returns the submesh BoudingInfo object
  21225. * @returns current bounding info (or mesh's one if the submesh is global)
  21226. */
  21227. getBoundingInfo(): BoundingInfo;
  21228. /**
  21229. * Sets the submesh BoundingInfo
  21230. * @param boundingInfo defines the new bounding info to use
  21231. * @returns the SubMesh
  21232. */
  21233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21234. /**
  21235. * Returns the mesh of the current submesh
  21236. * @return the parent mesh
  21237. */
  21238. getMesh(): AbstractMesh;
  21239. /**
  21240. * Returns the rendering mesh of the submesh
  21241. * @returns the rendering mesh (could be different from parent mesh)
  21242. */
  21243. getRenderingMesh(): Mesh;
  21244. /**
  21245. * Returns the submesh material
  21246. * @returns null or the current material
  21247. */
  21248. getMaterial(): Nullable<Material>;
  21249. /**
  21250. * Sets a new updated BoundingInfo object to the submesh
  21251. * @param data defines an optional position array to use to determine the bounding info
  21252. * @returns the SubMesh
  21253. */
  21254. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21255. /** @hidden */
  21256. _checkCollision(collider: Collider): boolean;
  21257. /**
  21258. * Updates the submesh BoundingInfo
  21259. * @param world defines the world matrix to use to update the bounding info
  21260. * @returns the submesh
  21261. */
  21262. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21263. /**
  21264. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21265. * @param frustumPlanes defines the frustum planes
  21266. * @returns true if the submesh is intersecting with the frustum
  21267. */
  21268. isInFrustum(frustumPlanes: Plane[]): boolean;
  21269. /**
  21270. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21271. * @param frustumPlanes defines the frustum planes
  21272. * @returns true if the submesh is inside the frustum
  21273. */
  21274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21275. /**
  21276. * Renders the submesh
  21277. * @param enableAlphaMode defines if alpha needs to be used
  21278. * @returns the submesh
  21279. */
  21280. render(enableAlphaMode: boolean): SubMesh;
  21281. /**
  21282. * @hidden
  21283. */
  21284. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21285. /**
  21286. * Checks if the submesh intersects with a ray
  21287. * @param ray defines the ray to test
  21288. * @returns true is the passed ray intersects the submesh bounding box
  21289. */
  21290. canIntersects(ray: Ray): boolean;
  21291. /**
  21292. * Intersects current submesh with a ray
  21293. * @param ray defines the ray to test
  21294. * @param positions defines mesh's positions array
  21295. * @param indices defines mesh's indices array
  21296. * @param fastCheck defines if only bounding info should be used
  21297. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21298. * @returns intersection info or null if no intersection
  21299. */
  21300. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21301. /** @hidden */
  21302. private _intersectLines;
  21303. /** @hidden */
  21304. private _intersectUnIndexedLines;
  21305. /** @hidden */
  21306. private _intersectTriangles;
  21307. /** @hidden */
  21308. private _intersectUnIndexedTriangles;
  21309. /** @hidden */
  21310. _rebuild(): void;
  21311. /**
  21312. * Creates a new submesh from the passed mesh
  21313. * @param newMesh defines the new hosting mesh
  21314. * @param newRenderingMesh defines an optional rendering mesh
  21315. * @returns the new submesh
  21316. */
  21317. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21318. /**
  21319. * Release associated resources
  21320. */
  21321. dispose(): void;
  21322. /**
  21323. * Gets the class name
  21324. * @returns the string "SubMesh".
  21325. */
  21326. getClassName(): string;
  21327. /**
  21328. * Creates a new submesh from indices data
  21329. * @param materialIndex the index of the main mesh material
  21330. * @param startIndex the index where to start the copy in the mesh indices array
  21331. * @param indexCount the number of indices to copy then from the startIndex
  21332. * @param mesh the main mesh to create the submesh from
  21333. * @param renderingMesh the optional rendering mesh
  21334. * @returns a new submesh
  21335. */
  21336. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21337. }
  21338. }
  21339. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21340. /**
  21341. * Class used to represent data loading progression
  21342. */
  21343. export class SceneLoaderFlags {
  21344. private static _ForceFullSceneLoadingForIncremental;
  21345. private static _ShowLoadingScreen;
  21346. private static _CleanBoneMatrixWeights;
  21347. private static _loggingLevel;
  21348. /**
  21349. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21350. */
  21351. static ForceFullSceneLoadingForIncremental: boolean;
  21352. /**
  21353. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21354. */
  21355. static ShowLoadingScreen: boolean;
  21356. /**
  21357. * Defines the current logging level (while loading the scene)
  21358. * @ignorenaming
  21359. */
  21360. static loggingLevel: number;
  21361. /**
  21362. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21363. */
  21364. static CleanBoneMatrixWeights: boolean;
  21365. }
  21366. }
  21367. declare module "babylonjs/Meshes/geometry" {
  21368. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21371. import { Engine } from "babylonjs/Engines/engine";
  21372. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21373. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21374. import { Effect } from "babylonjs/Materials/effect";
  21375. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21377. import { Mesh } from "babylonjs/Meshes/mesh";
  21378. /**
  21379. * Class used to store geometry data (vertex buffers + index buffer)
  21380. */
  21381. export class Geometry implements IGetSetVerticesData {
  21382. /**
  21383. * Gets or sets the ID of the geometry
  21384. */
  21385. id: string;
  21386. /**
  21387. * Gets or sets the unique ID of the geometry
  21388. */
  21389. uniqueId: number;
  21390. /**
  21391. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21392. */
  21393. delayLoadState: number;
  21394. /**
  21395. * Gets the file containing the data to load when running in delay load state
  21396. */
  21397. delayLoadingFile: Nullable<string>;
  21398. /**
  21399. * Callback called when the geometry is updated
  21400. */
  21401. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21402. private _scene;
  21403. private _engine;
  21404. private _meshes;
  21405. private _totalVertices;
  21406. /** @hidden */
  21407. _indices: IndicesArray;
  21408. /** @hidden */
  21409. _vertexBuffers: {
  21410. [key: string]: VertexBuffer;
  21411. };
  21412. private _isDisposed;
  21413. private _extend;
  21414. private _boundingBias;
  21415. /** @hidden */
  21416. _delayInfo: Array<string>;
  21417. private _indexBuffer;
  21418. private _indexBufferIsUpdatable;
  21419. /** @hidden */
  21420. _boundingInfo: Nullable<BoundingInfo>;
  21421. /** @hidden */
  21422. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21423. /** @hidden */
  21424. _softwareSkinningFrameId: number;
  21425. private _vertexArrayObjects;
  21426. private _updatable;
  21427. /** @hidden */
  21428. _positions: Nullable<Vector3[]>;
  21429. /**
  21430. * 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
  21431. */
  21432. /**
  21433. * 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
  21434. */
  21435. boundingBias: Vector2;
  21436. /**
  21437. * Static function used to attach a new empty geometry to a mesh
  21438. * @param mesh defines the mesh to attach the geometry to
  21439. * @returns the new Geometry
  21440. */
  21441. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21442. /**
  21443. * Creates a new geometry
  21444. * @param id defines the unique ID
  21445. * @param scene defines the hosting scene
  21446. * @param vertexData defines the VertexData used to get geometry data
  21447. * @param updatable defines if geometry must be updatable (false by default)
  21448. * @param mesh defines the mesh that will be associated with the geometry
  21449. */
  21450. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21451. /**
  21452. * Gets the current extend of the geometry
  21453. */
  21454. readonly extend: {
  21455. minimum: Vector3;
  21456. maximum: Vector3;
  21457. };
  21458. /**
  21459. * Gets the hosting scene
  21460. * @returns the hosting Scene
  21461. */
  21462. getScene(): Scene;
  21463. /**
  21464. * Gets the hosting engine
  21465. * @returns the hosting Engine
  21466. */
  21467. getEngine(): Engine;
  21468. /**
  21469. * Defines if the geometry is ready to use
  21470. * @returns true if the geometry is ready to be used
  21471. */
  21472. isReady(): boolean;
  21473. /**
  21474. * Gets a value indicating that the geometry should not be serialized
  21475. */
  21476. readonly doNotSerialize: boolean;
  21477. /** @hidden */
  21478. _rebuild(): void;
  21479. /**
  21480. * Affects all geometry data in one call
  21481. * @param vertexData defines the geometry data
  21482. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21483. */
  21484. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21485. /**
  21486. * Set specific vertex data
  21487. * @param kind defines the data kind (Position, normal, etc...)
  21488. * @param data defines the vertex data to use
  21489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21491. */
  21492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21493. /**
  21494. * Removes a specific vertex data
  21495. * @param kind defines the data kind (Position, normal, etc...)
  21496. */
  21497. removeVerticesData(kind: string): void;
  21498. /**
  21499. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21500. * @param buffer defines the vertex buffer to use
  21501. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21502. */
  21503. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21504. /**
  21505. * Update a specific vertex buffer
  21506. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21507. * It will do nothing if the buffer is not updatable
  21508. * @param kind defines the data kind (Position, normal, etc...)
  21509. * @param data defines the data to use
  21510. * @param offset defines the offset in the target buffer where to store the data
  21511. * @param useBytes set to true if the offset is in bytes
  21512. */
  21513. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21514. /**
  21515. * Update a specific vertex buffer
  21516. * This function will create a new buffer if the current one is not updatable
  21517. * @param kind defines the data kind (Position, normal, etc...)
  21518. * @param data defines the data to use
  21519. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21520. */
  21521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21522. private _updateBoundingInfo;
  21523. /** @hidden */
  21524. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21525. /**
  21526. * Gets total number of vertices
  21527. * @returns the total number of vertices
  21528. */
  21529. getTotalVertices(): number;
  21530. /**
  21531. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21532. * @param kind defines the data kind (Position, normal, etc...)
  21533. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21535. * @returns a float array containing vertex data
  21536. */
  21537. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21538. /**
  21539. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21540. * @param kind defines the data kind (Position, normal, etc...)
  21541. * @returns true if the vertex buffer with the specified kind is updatable
  21542. */
  21543. isVertexBufferUpdatable(kind: string): boolean;
  21544. /**
  21545. * Gets a specific vertex buffer
  21546. * @param kind defines the data kind (Position, normal, etc...)
  21547. * @returns a VertexBuffer
  21548. */
  21549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21550. /**
  21551. * Returns all vertex buffers
  21552. * @return an object holding all vertex buffers indexed by kind
  21553. */
  21554. getVertexBuffers(): Nullable<{
  21555. [key: string]: VertexBuffer;
  21556. }>;
  21557. /**
  21558. * Gets a boolean indicating if specific vertex buffer is present
  21559. * @param kind defines the data kind (Position, normal, etc...)
  21560. * @returns true if data is present
  21561. */
  21562. isVerticesDataPresent(kind: string): boolean;
  21563. /**
  21564. * Gets a list of all attached data kinds (Position, normal, etc...)
  21565. * @returns a list of string containing all kinds
  21566. */
  21567. getVerticesDataKinds(): string[];
  21568. /**
  21569. * Update index buffer
  21570. * @param indices defines the indices to store in the index buffer
  21571. * @param offset defines the offset in the target buffer where to store the data
  21572. * @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)
  21573. */
  21574. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21575. /**
  21576. * Creates a new index buffer
  21577. * @param indices defines the indices to store in the index buffer
  21578. * @param totalVertices defines the total number of vertices (could be null)
  21579. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21580. */
  21581. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21582. /**
  21583. * Return the total number of indices
  21584. * @returns the total number of indices
  21585. */
  21586. getTotalIndices(): number;
  21587. /**
  21588. * Gets the index buffer array
  21589. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21591. * @returns the index buffer array
  21592. */
  21593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21594. /**
  21595. * Gets the index buffer
  21596. * @return the index buffer
  21597. */
  21598. getIndexBuffer(): Nullable<DataBuffer>;
  21599. /** @hidden */
  21600. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21601. /**
  21602. * Release the associated resources for a specific mesh
  21603. * @param mesh defines the source mesh
  21604. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21605. */
  21606. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21607. /**
  21608. * Apply current geometry to a given mesh
  21609. * @param mesh defines the mesh to apply geometry to
  21610. */
  21611. applyToMesh(mesh: Mesh): void;
  21612. private _updateExtend;
  21613. private _applyToMesh;
  21614. private notifyUpdate;
  21615. /**
  21616. * Load the geometry if it was flagged as delay loaded
  21617. * @param scene defines the hosting scene
  21618. * @param onLoaded defines a callback called when the geometry is loaded
  21619. */
  21620. load(scene: Scene, onLoaded?: () => void): void;
  21621. private _queueLoad;
  21622. /**
  21623. * Invert the geometry to move from a right handed system to a left handed one.
  21624. */
  21625. toLeftHanded(): void;
  21626. /** @hidden */
  21627. _resetPointsArrayCache(): void;
  21628. /** @hidden */
  21629. _generatePointsArray(): boolean;
  21630. /**
  21631. * Gets a value indicating if the geometry is disposed
  21632. * @returns true if the geometry was disposed
  21633. */
  21634. isDisposed(): boolean;
  21635. private _disposeVertexArrayObjects;
  21636. /**
  21637. * Free all associated resources
  21638. */
  21639. dispose(): void;
  21640. /**
  21641. * Clone the current geometry into a new geometry
  21642. * @param id defines the unique ID of the new geometry
  21643. * @returns a new geometry object
  21644. */
  21645. copy(id: string): Geometry;
  21646. /**
  21647. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21648. * @return a JSON representation of the current geometry data (without the vertices data)
  21649. */
  21650. serialize(): any;
  21651. private toNumberArray;
  21652. /**
  21653. * Serialize all vertices data into a JSON oject
  21654. * @returns a JSON representation of the current geometry data
  21655. */
  21656. serializeVerticeData(): any;
  21657. /**
  21658. * Extracts a clone of a mesh geometry
  21659. * @param mesh defines the source mesh
  21660. * @param id defines the unique ID of the new geometry object
  21661. * @returns the new geometry object
  21662. */
  21663. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21664. /**
  21665. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21666. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21667. * Be aware Math.random() could cause collisions, but:
  21668. * "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"
  21669. * @returns a string containing a new GUID
  21670. */
  21671. static RandomId(): string;
  21672. /** @hidden */
  21673. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21674. private static _CleanMatricesWeights;
  21675. /**
  21676. * Create a new geometry from persisted data (Using .babylon file format)
  21677. * @param parsedVertexData defines the persisted data
  21678. * @param scene defines the hosting scene
  21679. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21680. * @returns the new geometry object
  21681. */
  21682. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21683. }
  21684. }
  21685. declare module "babylonjs/Meshes/mesh.vertexData" {
  21686. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21687. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21688. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21689. import { Geometry } from "babylonjs/Meshes/geometry";
  21690. import { Mesh } from "babylonjs/Meshes/mesh";
  21691. /**
  21692. * Define an interface for all classes that will get and set the data on vertices
  21693. */
  21694. export interface IGetSetVerticesData {
  21695. /**
  21696. * Gets a boolean indicating if specific vertex data is present
  21697. * @param kind defines the vertex data kind to use
  21698. * @returns true is data kind is present
  21699. */
  21700. isVerticesDataPresent(kind: string): boolean;
  21701. /**
  21702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21703. * @param kind defines the data kind (Position, normal, etc...)
  21704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21706. * @returns a float array containing vertex data
  21707. */
  21708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21709. /**
  21710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21711. * @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.
  21712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21713. * @returns the indices array or an empty array if the mesh has no geometry
  21714. */
  21715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21716. /**
  21717. * Set specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. * @param data defines the vertex data to use
  21720. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21721. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21722. */
  21723. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21724. /**
  21725. * Update a specific associated vertex buffer
  21726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21727. * - VertexBuffer.PositionKind
  21728. * - VertexBuffer.UVKind
  21729. * - VertexBuffer.UV2Kind
  21730. * - VertexBuffer.UV3Kind
  21731. * - VertexBuffer.UV4Kind
  21732. * - VertexBuffer.UV5Kind
  21733. * - VertexBuffer.UV6Kind
  21734. * - VertexBuffer.ColorKind
  21735. * - VertexBuffer.MatricesIndicesKind
  21736. * - VertexBuffer.MatricesIndicesExtraKind
  21737. * - VertexBuffer.MatricesWeightsKind
  21738. * - VertexBuffer.MatricesWeightsExtraKind
  21739. * @param data defines the data source
  21740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21741. * @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)
  21742. */
  21743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21744. /**
  21745. * Creates a new index buffer
  21746. * @param indices defines the indices to store in the index buffer
  21747. * @param totalVertices defines the total number of vertices (could be null)
  21748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21749. */
  21750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21751. }
  21752. /**
  21753. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21754. */
  21755. export class VertexData {
  21756. /**
  21757. * Mesh side orientation : usually the external or front surface
  21758. */
  21759. static readonly FRONTSIDE: number;
  21760. /**
  21761. * Mesh side orientation : usually the internal or back surface
  21762. */
  21763. static readonly BACKSIDE: number;
  21764. /**
  21765. * Mesh side orientation : both internal and external or front and back surfaces
  21766. */
  21767. static readonly DOUBLESIDE: number;
  21768. /**
  21769. * Mesh side orientation : by default, `FRONTSIDE`
  21770. */
  21771. static readonly DEFAULTSIDE: number;
  21772. /**
  21773. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21774. */
  21775. positions: Nullable<FloatArray>;
  21776. /**
  21777. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21778. */
  21779. normals: Nullable<FloatArray>;
  21780. /**
  21781. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21782. */
  21783. tangents: Nullable<FloatArray>;
  21784. /**
  21785. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs: Nullable<FloatArray>;
  21788. /**
  21789. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21790. */
  21791. uvs2: Nullable<FloatArray>;
  21792. /**
  21793. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21794. */
  21795. uvs3: Nullable<FloatArray>;
  21796. /**
  21797. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21798. */
  21799. uvs4: Nullable<FloatArray>;
  21800. /**
  21801. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21802. */
  21803. uvs5: Nullable<FloatArray>;
  21804. /**
  21805. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21806. */
  21807. uvs6: Nullable<FloatArray>;
  21808. /**
  21809. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21810. */
  21811. colors: Nullable<FloatArray>;
  21812. /**
  21813. * 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).
  21814. */
  21815. matricesIndices: Nullable<FloatArray>;
  21816. /**
  21817. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21818. */
  21819. matricesWeights: Nullable<FloatArray>;
  21820. /**
  21821. * An array extending the number of possible indices
  21822. */
  21823. matricesIndicesExtra: Nullable<FloatArray>;
  21824. /**
  21825. * An array extending the number of possible weights when the number of indices is extended
  21826. */
  21827. matricesWeightsExtra: Nullable<FloatArray>;
  21828. /**
  21829. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21830. */
  21831. indices: Nullable<IndicesArray>;
  21832. /**
  21833. * Uses the passed data array to set the set the values for the specified kind of data
  21834. * @param data a linear array of floating numbers
  21835. * @param kind the type of data that is being set, eg positions, colors etc
  21836. */
  21837. set(data: FloatArray, kind: string): void;
  21838. /**
  21839. * Associates the vertexData to the passed Mesh.
  21840. * Sets it as updatable or not (default `false`)
  21841. * @param mesh the mesh the vertexData is applied to
  21842. * @param updatable when used and having the value true allows new data to update the vertexData
  21843. * @returns the VertexData
  21844. */
  21845. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21846. /**
  21847. * Associates the vertexData to the passed Geometry.
  21848. * Sets it as updatable or not (default `false`)
  21849. * @param geometry the geometry the vertexData is applied to
  21850. * @param updatable when used and having the value true allows new data to update the vertexData
  21851. * @returns VertexData
  21852. */
  21853. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21854. /**
  21855. * Updates the associated mesh
  21856. * @param mesh the mesh to be updated
  21857. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21858. * @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
  21859. * @returns VertexData
  21860. */
  21861. updateMesh(mesh: Mesh): VertexData;
  21862. /**
  21863. * Updates the associated geometry
  21864. * @param geometry the geometry to be updated
  21865. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21866. * @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
  21867. * @returns VertexData.
  21868. */
  21869. updateGeometry(geometry: Geometry): VertexData;
  21870. private _applyTo;
  21871. private _update;
  21872. /**
  21873. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21874. * @param matrix the transforming matrix
  21875. * @returns the VertexData
  21876. */
  21877. transform(matrix: Matrix): VertexData;
  21878. /**
  21879. * Merges the passed VertexData into the current one
  21880. * @param other the VertexData to be merged into the current one
  21881. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21882. * @returns the modified VertexData
  21883. */
  21884. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21885. private _mergeElement;
  21886. private _validate;
  21887. /**
  21888. * Serializes the VertexData
  21889. * @returns a serialized object
  21890. */
  21891. serialize(): any;
  21892. /**
  21893. * Extracts the vertexData from a mesh
  21894. * @param mesh the mesh from which to extract the VertexData
  21895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21897. * @returns the object VertexData associated to the passed mesh
  21898. */
  21899. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21900. /**
  21901. * Extracts the vertexData from the geometry
  21902. * @param geometry the geometry from which to extract the VertexData
  21903. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21905. * @returns the object VertexData associated to the passed mesh
  21906. */
  21907. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21908. private static _ExtractFrom;
  21909. /**
  21910. * Creates the VertexData for a Ribbon
  21911. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21912. * * pathArray array of paths, each of which an array of successive Vector3
  21913. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21914. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21915. * * 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
  21916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21917. * * 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)
  21918. * * 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)
  21919. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21920. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21921. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21922. * @returns the VertexData of the ribbon
  21923. */
  21924. static CreateRibbon(options: {
  21925. pathArray: Vector3[][];
  21926. closeArray?: boolean;
  21927. closePath?: boolean;
  21928. offset?: number;
  21929. sideOrientation?: number;
  21930. frontUVs?: Vector4;
  21931. backUVs?: Vector4;
  21932. invertUV?: boolean;
  21933. uvs?: Vector2[];
  21934. colors?: Color4[];
  21935. }): VertexData;
  21936. /**
  21937. * Creates the VertexData for a box
  21938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21939. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21940. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21941. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21942. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21943. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21944. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21946. * * 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)
  21947. * * 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)
  21948. * @returns the VertexData of the box
  21949. */
  21950. static CreateBox(options: {
  21951. size?: number;
  21952. width?: number;
  21953. height?: number;
  21954. depth?: number;
  21955. faceUV?: Vector4[];
  21956. faceColors?: Color4[];
  21957. sideOrientation?: number;
  21958. frontUVs?: Vector4;
  21959. backUVs?: Vector4;
  21960. }): VertexData;
  21961. /**
  21962. * Creates the VertexData for a tiled box
  21963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * @returns the VertexData of the box
  21969. */
  21970. static CreateTiledBox(options: {
  21971. pattern?: number;
  21972. width?: number;
  21973. height?: number;
  21974. depth?: number;
  21975. tileSize?: number;
  21976. tileWidth?: number;
  21977. tileHeight?: number;
  21978. alignHorizontal?: number;
  21979. alignVertical?: number;
  21980. faceUV?: Vector4[];
  21981. faceColors?: Color4[];
  21982. sideOrientation?: number;
  21983. }): VertexData;
  21984. /**
  21985. * Creates the VertexData for a tiled plane
  21986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21987. * * pattern a limited pattern arrangement depending on the number
  21988. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21989. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21990. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21992. * * 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)
  21993. * * 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)
  21994. * @returns the VertexData of the tiled plane
  21995. */
  21996. static CreateTiledPlane(options: {
  21997. pattern?: number;
  21998. tileSize?: number;
  21999. tileWidth?: number;
  22000. tileHeight?: number;
  22001. size?: number;
  22002. width?: number;
  22003. height?: number;
  22004. alignHorizontal?: number;
  22005. alignVertical?: number;
  22006. sideOrientation?: number;
  22007. frontUVs?: Vector4;
  22008. backUVs?: Vector4;
  22009. }): VertexData;
  22010. /**
  22011. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22013. * * segments sets the number of horizontal strips optional, default 32
  22014. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22015. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22016. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22017. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22018. * * 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
  22019. * * 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
  22020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22021. * * 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)
  22022. * * 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)
  22023. * @returns the VertexData of the ellipsoid
  22024. */
  22025. static CreateSphere(options: {
  22026. segments?: number;
  22027. diameter?: number;
  22028. diameterX?: number;
  22029. diameterY?: number;
  22030. diameterZ?: number;
  22031. arc?: number;
  22032. slice?: number;
  22033. sideOrientation?: number;
  22034. frontUVs?: Vector4;
  22035. backUVs?: Vector4;
  22036. }): VertexData;
  22037. /**
  22038. * Creates the VertexData for a cylinder, cone or prism
  22039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22040. * * height sets the height (y direction) of the cylinder, optional, default 2
  22041. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22042. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22043. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22044. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22045. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22046. * * 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
  22047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22049. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22050. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22052. * * 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)
  22053. * * 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)
  22054. * @returns the VertexData of the cylinder, cone or prism
  22055. */
  22056. static CreateCylinder(options: {
  22057. height?: number;
  22058. diameterTop?: number;
  22059. diameterBottom?: number;
  22060. diameter?: number;
  22061. tessellation?: number;
  22062. subdivisions?: number;
  22063. arc?: number;
  22064. faceColors?: Color4[];
  22065. faceUV?: Vector4[];
  22066. hasRings?: boolean;
  22067. enclose?: boolean;
  22068. sideOrientation?: number;
  22069. frontUVs?: Vector4;
  22070. backUVs?: Vector4;
  22071. }): VertexData;
  22072. /**
  22073. * Creates the VertexData for a torus
  22074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22075. * * diameter the diameter of the torus, optional default 1
  22076. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22079. * * 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)
  22080. * * 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)
  22081. * @returns the VertexData of the torus
  22082. */
  22083. static CreateTorus(options: {
  22084. diameter?: number;
  22085. thickness?: number;
  22086. tessellation?: number;
  22087. sideOrientation?: number;
  22088. frontUVs?: Vector4;
  22089. backUVs?: Vector4;
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData of the LineSystem
  22093. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22094. * - lines an array of lines, each line being an array of successive Vector3
  22095. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22096. * @returns the VertexData of the LineSystem
  22097. */
  22098. static CreateLineSystem(options: {
  22099. lines: Vector3[][];
  22100. colors?: Nullable<Color4[][]>;
  22101. }): VertexData;
  22102. /**
  22103. * Create the VertexData for a DashedLines
  22104. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22105. * - points an array successive Vector3
  22106. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22107. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22108. * - dashNb the intended total number of dashes, optional, default 200
  22109. * @returns the VertexData for the DashedLines
  22110. */
  22111. static CreateDashedLines(options: {
  22112. points: Vector3[];
  22113. dashSize?: number;
  22114. gapSize?: number;
  22115. dashNb?: number;
  22116. }): VertexData;
  22117. /**
  22118. * Creates the VertexData for a Ground
  22119. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22120. * - width the width (x direction) of the ground, optional, default 1
  22121. * - height the height (z direction) of the ground, optional, default 1
  22122. * - subdivisions the number of subdivisions per side, optional, default 1
  22123. * @returns the VertexData of the Ground
  22124. */
  22125. static CreateGround(options: {
  22126. width?: number;
  22127. height?: number;
  22128. subdivisions?: number;
  22129. subdivisionsX?: number;
  22130. subdivisionsY?: number;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22135. * * xmin the ground minimum X coordinate, optional, default -1
  22136. * * zmin the ground minimum Z coordinate, optional, default -1
  22137. * * xmax the ground maximum X coordinate, optional, default 1
  22138. * * zmax the ground maximum Z coordinate, optional, default 1
  22139. * * 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}
  22140. * * 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}
  22141. * @returns the VertexData of the TiledGround
  22142. */
  22143. static CreateTiledGround(options: {
  22144. xmin: number;
  22145. zmin: number;
  22146. xmax: number;
  22147. zmax: number;
  22148. subdivisions?: {
  22149. w: number;
  22150. h: number;
  22151. };
  22152. precision?: {
  22153. w: number;
  22154. h: number;
  22155. };
  22156. }): VertexData;
  22157. /**
  22158. * Creates the VertexData of the Ground designed from a heightmap
  22159. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22160. * * width the width (x direction) of the ground
  22161. * * height the height (z direction) of the ground
  22162. * * subdivisions the number of subdivisions per side
  22163. * * minHeight the minimum altitude on the ground, optional, default 0
  22164. * * maxHeight the maximum altitude on the ground, optional default 1
  22165. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22166. * * buffer the array holding the image color data
  22167. * * bufferWidth the width of image
  22168. * * bufferHeight the height of image
  22169. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22170. * @returns the VertexData of the Ground designed from a heightmap
  22171. */
  22172. static CreateGroundFromHeightMap(options: {
  22173. width: number;
  22174. height: number;
  22175. subdivisions: number;
  22176. minHeight: number;
  22177. maxHeight: number;
  22178. colorFilter: Color3;
  22179. buffer: Uint8Array;
  22180. bufferWidth: number;
  22181. bufferHeight: number;
  22182. alphaFilter: number;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a Plane
  22186. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22187. * * size sets the width and height of the plane to the value of size, optional default 1
  22188. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22189. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * * 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)
  22192. * * 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)
  22193. * @returns the VertexData of the box
  22194. */
  22195. static CreatePlane(options: {
  22196. size?: number;
  22197. width?: number;
  22198. height?: number;
  22199. sideOrientation?: number;
  22200. frontUVs?: Vector4;
  22201. backUVs?: Vector4;
  22202. }): VertexData;
  22203. /**
  22204. * Creates the VertexData of the Disc or regular Polygon
  22205. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22206. * * radius the radius of the disc, optional default 0.5
  22207. * * tessellation the number of polygon sides, optional, default 64
  22208. * * 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
  22209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22210. * * 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)
  22211. * * 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)
  22212. * @returns the VertexData of the box
  22213. */
  22214. static CreateDisc(options: {
  22215. radius?: number;
  22216. tessellation?: number;
  22217. arc?: number;
  22218. sideOrientation?: number;
  22219. frontUVs?: Vector4;
  22220. backUVs?: Vector4;
  22221. }): VertexData;
  22222. /**
  22223. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22224. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22225. * @param polygon a mesh built from polygonTriangulation.build()
  22226. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22227. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22228. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22229. * @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)
  22230. * @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)
  22231. * @returns the VertexData of the Polygon
  22232. */
  22233. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22234. /**
  22235. * Creates the VertexData of the IcoSphere
  22236. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22237. * * radius the radius of the IcoSphere, optional default 1
  22238. * * radiusX allows stretching in the x direction, optional, default radius
  22239. * * radiusY allows stretching in the y direction, optional, default radius
  22240. * * radiusZ allows stretching in the z direction, optional, default radius
  22241. * * flat when true creates a flat shaded mesh, optional, default true
  22242. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * 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)
  22245. * * 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)
  22246. * @returns the VertexData of the IcoSphere
  22247. */
  22248. static CreateIcoSphere(options: {
  22249. radius?: number;
  22250. radiusX?: number;
  22251. radiusY?: number;
  22252. radiusZ?: number;
  22253. flat?: boolean;
  22254. subdivisions?: number;
  22255. sideOrientation?: number;
  22256. frontUVs?: Vector4;
  22257. backUVs?: Vector4;
  22258. }): VertexData;
  22259. /**
  22260. * Creates the VertexData for a Polyhedron
  22261. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22262. * * type provided types are:
  22263. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22264. * * 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)
  22265. * * size the size of the IcoSphere, optional default 1
  22266. * * sizeX allows stretching in the x direction, optional, default size
  22267. * * sizeY allows stretching in the y direction, optional, default size
  22268. * * sizeZ allows stretching in the z direction, optional, default size
  22269. * * 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
  22270. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22271. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22272. * * flat when true creates a flat shaded mesh, optional, default true
  22273. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the Polyhedron
  22278. */
  22279. static CreatePolyhedron(options: {
  22280. type?: number;
  22281. size?: number;
  22282. sizeX?: number;
  22283. sizeY?: number;
  22284. sizeZ?: number;
  22285. custom?: any;
  22286. faceUV?: Vector4[];
  22287. faceColors?: Color4[];
  22288. flat?: boolean;
  22289. sideOrientation?: number;
  22290. frontUVs?: Vector4;
  22291. backUVs?: Vector4;
  22292. }): VertexData;
  22293. /**
  22294. * Creates the VertexData for a TorusKnot
  22295. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22296. * * radius the radius of the torus knot, optional, default 2
  22297. * * tube the thickness of the tube, optional, default 0.5
  22298. * * radialSegments the number of sides on each tube segments, optional, default 32
  22299. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22300. * * p the number of windings around the z axis, optional, default 2
  22301. * * q the number of windings around the x axis, optional, default 3
  22302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22303. * * 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)
  22304. * * 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)
  22305. * @returns the VertexData of the Torus Knot
  22306. */
  22307. static CreateTorusKnot(options: {
  22308. radius?: number;
  22309. tube?: number;
  22310. radialSegments?: number;
  22311. tubularSegments?: number;
  22312. p?: number;
  22313. q?: number;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Compute normals for given positions and indices
  22320. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22321. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22322. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22323. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22324. * * facetNormals : optional array of facet normals (vector3)
  22325. * * facetPositions : optional array of facet positions (vector3)
  22326. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22327. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22328. * * bInfo : optional bounding info, required for facetPartitioning computation
  22329. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22330. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22331. * * useRightHandedSystem: optional boolean to for right handed system computation
  22332. * * depthSort : optional boolean to enable the facet depth sort computation
  22333. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22334. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22335. */
  22336. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22337. facetNormals?: any;
  22338. facetPositions?: any;
  22339. facetPartitioning?: any;
  22340. ratio?: number;
  22341. bInfo?: any;
  22342. bbSize?: Vector3;
  22343. subDiv?: any;
  22344. useRightHandedSystem?: boolean;
  22345. depthSort?: boolean;
  22346. distanceTo?: Vector3;
  22347. depthSortedFacets?: any;
  22348. }): void;
  22349. /** @hidden */
  22350. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22351. /**
  22352. * Applies VertexData created from the imported parameters to the geometry
  22353. * @param parsedVertexData the parsed data from an imported file
  22354. * @param geometry the geometry to apply the VertexData to
  22355. */
  22356. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22357. }
  22358. }
  22359. declare module "babylonjs/Morph/morphTarget" {
  22360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22361. import { Observable } from "babylonjs/Misc/observable";
  22362. import { Nullable, FloatArray } from "babylonjs/types";
  22363. import { Scene } from "babylonjs/scene";
  22364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22365. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22366. /**
  22367. * Defines a target to use with MorphTargetManager
  22368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22369. */
  22370. export class MorphTarget implements IAnimatable {
  22371. /** defines the name of the target */
  22372. name: string;
  22373. /**
  22374. * Gets or sets the list of animations
  22375. */
  22376. animations: import("babylonjs/Animations/animation").Animation[];
  22377. private _scene;
  22378. private _positions;
  22379. private _normals;
  22380. private _tangents;
  22381. private _uvs;
  22382. private _influence;
  22383. /**
  22384. * Observable raised when the influence changes
  22385. */
  22386. onInfluenceChanged: Observable<boolean>;
  22387. /** @hidden */
  22388. _onDataLayoutChanged: Observable<void>;
  22389. /**
  22390. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22391. */
  22392. influence: number;
  22393. /**
  22394. * Gets or sets the id of the morph Target
  22395. */
  22396. id: string;
  22397. private _animationPropertiesOverride;
  22398. /**
  22399. * Gets or sets the animation properties override
  22400. */
  22401. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22402. /**
  22403. * Creates a new MorphTarget
  22404. * @param name defines the name of the target
  22405. * @param influence defines the influence to use
  22406. * @param scene defines the scene the morphtarget belongs to
  22407. */
  22408. constructor(
  22409. /** defines the name of the target */
  22410. name: string, influence?: number, scene?: Nullable<Scene>);
  22411. /**
  22412. * Gets a boolean defining if the target contains position data
  22413. */
  22414. readonly hasPositions: boolean;
  22415. /**
  22416. * Gets a boolean defining if the target contains normal data
  22417. */
  22418. readonly hasNormals: boolean;
  22419. /**
  22420. * Gets a boolean defining if the target contains tangent data
  22421. */
  22422. readonly hasTangents: boolean;
  22423. /**
  22424. * Gets a boolean defining if the target contains texture coordinates data
  22425. */
  22426. readonly hasUVs: boolean;
  22427. /**
  22428. * Affects position data to this target
  22429. * @param data defines the position data to use
  22430. */
  22431. setPositions(data: Nullable<FloatArray>): void;
  22432. /**
  22433. * Gets the position data stored in this target
  22434. * @returns a FloatArray containing the position data (or null if not present)
  22435. */
  22436. getPositions(): Nullable<FloatArray>;
  22437. /**
  22438. * Affects normal data to this target
  22439. * @param data defines the normal data to use
  22440. */
  22441. setNormals(data: Nullable<FloatArray>): void;
  22442. /**
  22443. * Gets the normal data stored in this target
  22444. * @returns a FloatArray containing the normal data (or null if not present)
  22445. */
  22446. getNormals(): Nullable<FloatArray>;
  22447. /**
  22448. * Affects tangent data to this target
  22449. * @param data defines the tangent data to use
  22450. */
  22451. setTangents(data: Nullable<FloatArray>): void;
  22452. /**
  22453. * Gets the tangent data stored in this target
  22454. * @returns a FloatArray containing the tangent data (or null if not present)
  22455. */
  22456. getTangents(): Nullable<FloatArray>;
  22457. /**
  22458. * Affects texture coordinates data to this target
  22459. * @param data defines the texture coordinates data to use
  22460. */
  22461. setUVs(data: Nullable<FloatArray>): void;
  22462. /**
  22463. * Gets the texture coordinates data stored in this target
  22464. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22465. */
  22466. getUVs(): Nullable<FloatArray>;
  22467. /**
  22468. * Serializes the current target into a Serialization object
  22469. * @returns the serialized object
  22470. */
  22471. serialize(): any;
  22472. /**
  22473. * Returns the string "MorphTarget"
  22474. * @returns "MorphTarget"
  22475. */
  22476. getClassName(): string;
  22477. /**
  22478. * Creates a new target from serialized data
  22479. * @param serializationObject defines the serialized data to use
  22480. * @returns a new MorphTarget
  22481. */
  22482. static Parse(serializationObject: any): MorphTarget;
  22483. /**
  22484. * Creates a MorphTarget from mesh data
  22485. * @param mesh defines the source mesh
  22486. * @param name defines the name to use for the new target
  22487. * @param influence defines the influence to attach to the target
  22488. * @returns a new MorphTarget
  22489. */
  22490. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22491. }
  22492. }
  22493. declare module "babylonjs/Morph/morphTargetManager" {
  22494. import { Nullable } from "babylonjs/types";
  22495. import { Scene } from "babylonjs/scene";
  22496. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22497. /**
  22498. * This class is used to deform meshes using morphing between different targets
  22499. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22500. */
  22501. export class MorphTargetManager {
  22502. private _targets;
  22503. private _targetInfluenceChangedObservers;
  22504. private _targetDataLayoutChangedObservers;
  22505. private _activeTargets;
  22506. private _scene;
  22507. private _influences;
  22508. private _supportsNormals;
  22509. private _supportsTangents;
  22510. private _supportsUVs;
  22511. private _vertexCount;
  22512. private _uniqueId;
  22513. private _tempInfluences;
  22514. /**
  22515. * Gets or sets a boolean indicating if normals must be morphed
  22516. */
  22517. enableNormalMorphing: boolean;
  22518. /**
  22519. * Gets or sets a boolean indicating if tangents must be morphed
  22520. */
  22521. enableTangentMorphing: boolean;
  22522. /**
  22523. * Gets or sets a boolean indicating if UV must be morphed
  22524. */
  22525. enableUVMorphing: boolean;
  22526. /**
  22527. * Creates a new MorphTargetManager
  22528. * @param scene defines the current scene
  22529. */
  22530. constructor(scene?: Nullable<Scene>);
  22531. /**
  22532. * Gets the unique ID of this manager
  22533. */
  22534. readonly uniqueId: number;
  22535. /**
  22536. * Gets the number of vertices handled by this manager
  22537. */
  22538. readonly vertexCount: number;
  22539. /**
  22540. * Gets a boolean indicating if this manager supports morphing of normals
  22541. */
  22542. readonly supportsNormals: boolean;
  22543. /**
  22544. * Gets a boolean indicating if this manager supports morphing of tangents
  22545. */
  22546. readonly supportsTangents: boolean;
  22547. /**
  22548. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22549. */
  22550. readonly supportsUVs: boolean;
  22551. /**
  22552. * Gets the number of targets stored in this manager
  22553. */
  22554. readonly numTargets: number;
  22555. /**
  22556. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22557. */
  22558. readonly numInfluencers: number;
  22559. /**
  22560. * Gets the list of influences (one per target)
  22561. */
  22562. readonly influences: Float32Array;
  22563. /**
  22564. * Gets the active target at specified index. An active target is a target with an influence > 0
  22565. * @param index defines the index to check
  22566. * @returns the requested target
  22567. */
  22568. getActiveTarget(index: number): MorphTarget;
  22569. /**
  22570. * Gets the target at specified index
  22571. * @param index defines the index to check
  22572. * @returns the requested target
  22573. */
  22574. getTarget(index: number): MorphTarget;
  22575. /**
  22576. * Add a new target to this manager
  22577. * @param target defines the target to add
  22578. */
  22579. addTarget(target: MorphTarget): void;
  22580. /**
  22581. * Removes a target from the manager
  22582. * @param target defines the target to remove
  22583. */
  22584. removeTarget(target: MorphTarget): void;
  22585. /**
  22586. * Serializes the current manager into a Serialization object
  22587. * @returns the serialized object
  22588. */
  22589. serialize(): any;
  22590. private _syncActiveTargets;
  22591. /**
  22592. * Syncrhonize the targets with all the meshes using this morph target manager
  22593. */
  22594. synchronize(): void;
  22595. /**
  22596. * Creates a new MorphTargetManager from serialized data
  22597. * @param serializationObject defines the serialized data
  22598. * @param scene defines the hosting scene
  22599. * @returns the new MorphTargetManager
  22600. */
  22601. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22602. }
  22603. }
  22604. declare module "babylonjs/Meshes/meshLODLevel" {
  22605. import { Mesh } from "babylonjs/Meshes/mesh";
  22606. import { Nullable } from "babylonjs/types";
  22607. /**
  22608. * Class used to represent a specific level of detail of a mesh
  22609. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22610. */
  22611. export class MeshLODLevel {
  22612. /** Defines the distance where this level should star being displayed */
  22613. distance: number;
  22614. /** Defines the mesh to use to render this level */
  22615. mesh: Nullable<Mesh>;
  22616. /**
  22617. * Creates a new LOD level
  22618. * @param distance defines the distance where this level should star being displayed
  22619. * @param mesh defines the mesh to use to render this level
  22620. */
  22621. constructor(
  22622. /** Defines the distance where this level should star being displayed */
  22623. distance: number,
  22624. /** Defines the mesh to use to render this level */
  22625. mesh: Nullable<Mesh>);
  22626. }
  22627. }
  22628. declare module "babylonjs/Meshes/groundMesh" {
  22629. import { Scene } from "babylonjs/scene";
  22630. import { Vector3 } from "babylonjs/Maths/math.vector";
  22631. import { Mesh } from "babylonjs/Meshes/mesh";
  22632. /**
  22633. * Mesh representing the gorund
  22634. */
  22635. export class GroundMesh extends Mesh {
  22636. /** If octree should be generated */
  22637. generateOctree: boolean;
  22638. private _heightQuads;
  22639. /** @hidden */
  22640. _subdivisionsX: number;
  22641. /** @hidden */
  22642. _subdivisionsY: number;
  22643. /** @hidden */
  22644. _width: number;
  22645. /** @hidden */
  22646. _height: number;
  22647. /** @hidden */
  22648. _minX: number;
  22649. /** @hidden */
  22650. _maxX: number;
  22651. /** @hidden */
  22652. _minZ: number;
  22653. /** @hidden */
  22654. _maxZ: number;
  22655. constructor(name: string, scene: Scene);
  22656. /**
  22657. * "GroundMesh"
  22658. * @returns "GroundMesh"
  22659. */
  22660. getClassName(): string;
  22661. /**
  22662. * The minimum of x and y subdivisions
  22663. */
  22664. readonly subdivisions: number;
  22665. /**
  22666. * X subdivisions
  22667. */
  22668. readonly subdivisionsX: number;
  22669. /**
  22670. * Y subdivisions
  22671. */
  22672. readonly subdivisionsY: number;
  22673. /**
  22674. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22675. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22676. * @param chunksCount the number of subdivisions for x and y
  22677. * @param octreeBlocksSize (Default: 32)
  22678. */
  22679. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22680. /**
  22681. * Returns a height (y) value in the Worl system :
  22682. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22683. * @param x x coordinate
  22684. * @param z z coordinate
  22685. * @returns the ground y position if (x, z) are outside the ground surface.
  22686. */
  22687. getHeightAtCoordinates(x: number, z: number): number;
  22688. /**
  22689. * Returns a normalized vector (Vector3) orthogonal to the ground
  22690. * at the ground coordinates (x, z) expressed in the World system.
  22691. * @param x x coordinate
  22692. * @param z z coordinate
  22693. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22694. */
  22695. getNormalAtCoordinates(x: number, z: number): Vector3;
  22696. /**
  22697. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22698. * at the ground coordinates (x, z) expressed in the World system.
  22699. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22700. * @param x x coordinate
  22701. * @param z z coordinate
  22702. * @param ref vector to store the result
  22703. * @returns the GroundMesh.
  22704. */
  22705. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22706. /**
  22707. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22708. * if the ground has been updated.
  22709. * This can be used in the render loop.
  22710. * @returns the GroundMesh.
  22711. */
  22712. updateCoordinateHeights(): GroundMesh;
  22713. private _getFacetAt;
  22714. private _initHeightQuads;
  22715. private _computeHeightQuads;
  22716. /**
  22717. * Serializes this ground mesh
  22718. * @param serializationObject object to write serialization to
  22719. */
  22720. serialize(serializationObject: any): void;
  22721. /**
  22722. * Parses a serialized ground mesh
  22723. * @param parsedMesh the serialized mesh
  22724. * @param scene the scene to create the ground mesh in
  22725. * @returns the created ground mesh
  22726. */
  22727. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22728. }
  22729. }
  22730. declare module "babylonjs/Physics/physicsJoint" {
  22731. import { Vector3 } from "babylonjs/Maths/math.vector";
  22732. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22733. /**
  22734. * Interface for Physics-Joint data
  22735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22736. */
  22737. export interface PhysicsJointData {
  22738. /**
  22739. * The main pivot of the joint
  22740. */
  22741. mainPivot?: Vector3;
  22742. /**
  22743. * The connected pivot of the joint
  22744. */
  22745. connectedPivot?: Vector3;
  22746. /**
  22747. * The main axis of the joint
  22748. */
  22749. mainAxis?: Vector3;
  22750. /**
  22751. * The connected axis of the joint
  22752. */
  22753. connectedAxis?: Vector3;
  22754. /**
  22755. * The collision of the joint
  22756. */
  22757. collision?: boolean;
  22758. /**
  22759. * Native Oimo/Cannon/Energy data
  22760. */
  22761. nativeParams?: any;
  22762. }
  22763. /**
  22764. * This is a holder class for the physics joint created by the physics plugin
  22765. * It holds a set of functions to control the underlying joint
  22766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22767. */
  22768. export class PhysicsJoint {
  22769. /**
  22770. * The type of the physics joint
  22771. */
  22772. type: number;
  22773. /**
  22774. * The data for the physics joint
  22775. */
  22776. jointData: PhysicsJointData;
  22777. private _physicsJoint;
  22778. protected _physicsPlugin: IPhysicsEnginePlugin;
  22779. /**
  22780. * Initializes the physics joint
  22781. * @param type The type of the physics joint
  22782. * @param jointData The data for the physics joint
  22783. */
  22784. constructor(
  22785. /**
  22786. * The type of the physics joint
  22787. */
  22788. type: number,
  22789. /**
  22790. * The data for the physics joint
  22791. */
  22792. jointData: PhysicsJointData);
  22793. /**
  22794. * Gets the physics joint
  22795. */
  22796. /**
  22797. * Sets the physics joint
  22798. */
  22799. physicsJoint: any;
  22800. /**
  22801. * Sets the physics plugin
  22802. */
  22803. physicsPlugin: IPhysicsEnginePlugin;
  22804. /**
  22805. * Execute a function that is physics-plugin specific.
  22806. * @param {Function} func the function that will be executed.
  22807. * It accepts two parameters: the physics world and the physics joint
  22808. */
  22809. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22810. /**
  22811. * Distance-Joint type
  22812. */
  22813. static DistanceJoint: number;
  22814. /**
  22815. * Hinge-Joint type
  22816. */
  22817. static HingeJoint: number;
  22818. /**
  22819. * Ball-and-Socket joint type
  22820. */
  22821. static BallAndSocketJoint: number;
  22822. /**
  22823. * Wheel-Joint type
  22824. */
  22825. static WheelJoint: number;
  22826. /**
  22827. * Slider-Joint type
  22828. */
  22829. static SliderJoint: number;
  22830. /**
  22831. * Prismatic-Joint type
  22832. */
  22833. static PrismaticJoint: number;
  22834. /**
  22835. * Universal-Joint type
  22836. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22837. */
  22838. static UniversalJoint: number;
  22839. /**
  22840. * Hinge-Joint 2 type
  22841. */
  22842. static Hinge2Joint: number;
  22843. /**
  22844. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22845. */
  22846. static PointToPointJoint: number;
  22847. /**
  22848. * Spring-Joint type
  22849. */
  22850. static SpringJoint: number;
  22851. /**
  22852. * Lock-Joint type
  22853. */
  22854. static LockJoint: number;
  22855. }
  22856. /**
  22857. * A class representing a physics distance joint
  22858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22859. */
  22860. export class DistanceJoint extends PhysicsJoint {
  22861. /**
  22862. *
  22863. * @param jointData The data for the Distance-Joint
  22864. */
  22865. constructor(jointData: DistanceJointData);
  22866. /**
  22867. * Update the predefined distance.
  22868. * @param maxDistance The maximum preferred distance
  22869. * @param minDistance The minimum preferred distance
  22870. */
  22871. updateDistance(maxDistance: number, minDistance?: number): void;
  22872. }
  22873. /**
  22874. * Represents a Motor-Enabled Joint
  22875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22876. */
  22877. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22878. /**
  22879. * Initializes the Motor-Enabled Joint
  22880. * @param type The type of the joint
  22881. * @param jointData The physica joint data for the joint
  22882. */
  22883. constructor(type: number, jointData: PhysicsJointData);
  22884. /**
  22885. * Set the motor values.
  22886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22887. * @param force the force to apply
  22888. * @param maxForce max force for this motor.
  22889. */
  22890. setMotor(force?: number, maxForce?: number): void;
  22891. /**
  22892. * Set the motor's limits.
  22893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22894. * @param upperLimit The upper limit of the motor
  22895. * @param lowerLimit The lower limit of the motor
  22896. */
  22897. setLimit(upperLimit: number, lowerLimit?: number): void;
  22898. }
  22899. /**
  22900. * This class represents a single physics Hinge-Joint
  22901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22902. */
  22903. export class HingeJoint extends MotorEnabledJoint {
  22904. /**
  22905. * Initializes the Hinge-Joint
  22906. * @param jointData The joint data for the Hinge-Joint
  22907. */
  22908. constructor(jointData: PhysicsJointData);
  22909. /**
  22910. * Set the motor values.
  22911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22912. * @param {number} force the force to apply
  22913. * @param {number} maxForce max force for this motor.
  22914. */
  22915. setMotor(force?: number, maxForce?: number): void;
  22916. /**
  22917. * Set the motor's limits.
  22918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22919. * @param upperLimit The upper limit of the motor
  22920. * @param lowerLimit The lower limit of the motor
  22921. */
  22922. setLimit(upperLimit: number, lowerLimit?: number): void;
  22923. }
  22924. /**
  22925. * This class represents a dual hinge physics joint (same as wheel joint)
  22926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22927. */
  22928. export class Hinge2Joint extends MotorEnabledJoint {
  22929. /**
  22930. * Initializes the Hinge2-Joint
  22931. * @param jointData The joint data for the Hinge2-Joint
  22932. */
  22933. constructor(jointData: PhysicsJointData);
  22934. /**
  22935. * Set the motor values.
  22936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22937. * @param {number} targetSpeed the speed the motor is to reach
  22938. * @param {number} maxForce max force for this motor.
  22939. * @param {motorIndex} the motor's index, 0 or 1.
  22940. */
  22941. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22942. /**
  22943. * Set the motor limits.
  22944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22945. * @param {number} upperLimit the upper limit
  22946. * @param {number} lowerLimit lower limit
  22947. * @param {motorIndex} the motor's index, 0 or 1.
  22948. */
  22949. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22950. }
  22951. /**
  22952. * Interface for a motor enabled joint
  22953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22954. */
  22955. export interface IMotorEnabledJoint {
  22956. /**
  22957. * Physics joint
  22958. */
  22959. physicsJoint: any;
  22960. /**
  22961. * Sets the motor of the motor-enabled joint
  22962. * @param force The force of the motor
  22963. * @param maxForce The maximum force of the motor
  22964. * @param motorIndex The index of the motor
  22965. */
  22966. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22967. /**
  22968. * Sets the limit of the motor
  22969. * @param upperLimit The upper limit of the motor
  22970. * @param lowerLimit The lower limit of the motor
  22971. * @param motorIndex The index of the motor
  22972. */
  22973. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22974. }
  22975. /**
  22976. * Joint data for a Distance-Joint
  22977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22978. */
  22979. export interface DistanceJointData extends PhysicsJointData {
  22980. /**
  22981. * Max distance the 2 joint objects can be apart
  22982. */
  22983. maxDistance: number;
  22984. }
  22985. /**
  22986. * Joint data from a spring joint
  22987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22988. */
  22989. export interface SpringJointData extends PhysicsJointData {
  22990. /**
  22991. * Length of the spring
  22992. */
  22993. length: number;
  22994. /**
  22995. * Stiffness of the spring
  22996. */
  22997. stiffness: number;
  22998. /**
  22999. * Damping of the spring
  23000. */
  23001. damping: number;
  23002. /** this callback will be called when applying the force to the impostors. */
  23003. forceApplicationCallback: () => void;
  23004. }
  23005. }
  23006. declare module "babylonjs/Physics/physicsRaycastResult" {
  23007. import { Vector3 } from "babylonjs/Maths/math.vector";
  23008. /**
  23009. * Holds the data for the raycast result
  23010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23011. */
  23012. export class PhysicsRaycastResult {
  23013. private _hasHit;
  23014. private _hitDistance;
  23015. private _hitNormalWorld;
  23016. private _hitPointWorld;
  23017. private _rayFromWorld;
  23018. private _rayToWorld;
  23019. /**
  23020. * Gets if there was a hit
  23021. */
  23022. readonly hasHit: boolean;
  23023. /**
  23024. * Gets the distance from the hit
  23025. */
  23026. readonly hitDistance: number;
  23027. /**
  23028. * Gets the hit normal/direction in the world
  23029. */
  23030. readonly hitNormalWorld: Vector3;
  23031. /**
  23032. * Gets the hit point in the world
  23033. */
  23034. readonly hitPointWorld: Vector3;
  23035. /**
  23036. * Gets the ray "start point" of the ray in the world
  23037. */
  23038. readonly rayFromWorld: Vector3;
  23039. /**
  23040. * Gets the ray "end point" of the ray in the world
  23041. */
  23042. readonly rayToWorld: Vector3;
  23043. /**
  23044. * Sets the hit data (normal & point in world space)
  23045. * @param hitNormalWorld defines the normal in world space
  23046. * @param hitPointWorld defines the point in world space
  23047. */
  23048. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23049. /**
  23050. * Sets the distance from the start point to the hit point
  23051. * @param distance
  23052. */
  23053. setHitDistance(distance: number): void;
  23054. /**
  23055. * Calculates the distance manually
  23056. */
  23057. calculateHitDistance(): void;
  23058. /**
  23059. * Resets all the values to default
  23060. * @param from The from point on world space
  23061. * @param to The to point on world space
  23062. */
  23063. reset(from?: Vector3, to?: Vector3): void;
  23064. }
  23065. /**
  23066. * Interface for the size containing width and height
  23067. */
  23068. interface IXYZ {
  23069. /**
  23070. * X
  23071. */
  23072. x: number;
  23073. /**
  23074. * Y
  23075. */
  23076. y: number;
  23077. /**
  23078. * Z
  23079. */
  23080. z: number;
  23081. }
  23082. }
  23083. declare module "babylonjs/Physics/IPhysicsEngine" {
  23084. import { Nullable } from "babylonjs/types";
  23085. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23087. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23088. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23089. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23090. /**
  23091. * Interface used to describe a physics joint
  23092. */
  23093. export interface PhysicsImpostorJoint {
  23094. /** Defines the main impostor to which the joint is linked */
  23095. mainImpostor: PhysicsImpostor;
  23096. /** Defines the impostor that is connected to the main impostor using this joint */
  23097. connectedImpostor: PhysicsImpostor;
  23098. /** Defines the joint itself */
  23099. joint: PhysicsJoint;
  23100. }
  23101. /** @hidden */
  23102. export interface IPhysicsEnginePlugin {
  23103. world: any;
  23104. name: string;
  23105. setGravity(gravity: Vector3): void;
  23106. setTimeStep(timeStep: number): void;
  23107. getTimeStep(): number;
  23108. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23109. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23111. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23112. removePhysicsBody(impostor: PhysicsImpostor): void;
  23113. generateJoint(joint: PhysicsImpostorJoint): void;
  23114. removeJoint(joint: PhysicsImpostorJoint): void;
  23115. isSupported(): boolean;
  23116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23117. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23118. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23119. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23120. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23121. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23122. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23123. getBodyMass(impostor: PhysicsImpostor): number;
  23124. getBodyFriction(impostor: PhysicsImpostor): number;
  23125. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23126. getBodyRestitution(impostor: PhysicsImpostor): number;
  23127. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23128. getBodyPressure?(impostor: PhysicsImpostor): number;
  23129. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23130. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23131. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23132. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23133. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23134. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23135. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23136. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23137. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23138. sleepBody(impostor: PhysicsImpostor): void;
  23139. wakeUpBody(impostor: PhysicsImpostor): void;
  23140. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23142. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23143. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23144. getRadius(impostor: PhysicsImpostor): number;
  23145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23147. dispose(): void;
  23148. }
  23149. /**
  23150. * Interface used to define a physics engine
  23151. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23152. */
  23153. export interface IPhysicsEngine {
  23154. /**
  23155. * Gets the gravity vector used by the simulation
  23156. */
  23157. gravity: Vector3;
  23158. /**
  23159. * Sets the gravity vector used by the simulation
  23160. * @param gravity defines the gravity vector to use
  23161. */
  23162. setGravity(gravity: Vector3): void;
  23163. /**
  23164. * Set the time step of the physics engine.
  23165. * Default is 1/60.
  23166. * To slow it down, enter 1/600 for example.
  23167. * To speed it up, 1/30
  23168. * @param newTimeStep the new timestep to apply to this world.
  23169. */
  23170. setTimeStep(newTimeStep: number): void;
  23171. /**
  23172. * Get the time step of the physics engine.
  23173. * @returns the current time step
  23174. */
  23175. getTimeStep(): number;
  23176. /**
  23177. * Release all resources
  23178. */
  23179. dispose(): void;
  23180. /**
  23181. * Gets the name of the current physics plugin
  23182. * @returns the name of the plugin
  23183. */
  23184. getPhysicsPluginName(): string;
  23185. /**
  23186. * Adding a new impostor for the impostor tracking.
  23187. * This will be done by the impostor itself.
  23188. * @param impostor the impostor to add
  23189. */
  23190. addImpostor(impostor: PhysicsImpostor): void;
  23191. /**
  23192. * Remove an impostor from the engine.
  23193. * This impostor and its mesh will not longer be updated by the physics engine.
  23194. * @param impostor the impostor to remove
  23195. */
  23196. removeImpostor(impostor: PhysicsImpostor): void;
  23197. /**
  23198. * Add a joint to the physics engine
  23199. * @param mainImpostor defines the main impostor to which the joint is added.
  23200. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23201. * @param joint defines the joint that will connect both impostors.
  23202. */
  23203. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23204. /**
  23205. * Removes a joint from the simulation
  23206. * @param mainImpostor defines the impostor used with the joint
  23207. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23208. * @param joint defines the joint to remove
  23209. */
  23210. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23211. /**
  23212. * Gets the current plugin used to run the simulation
  23213. * @returns current plugin
  23214. */
  23215. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23216. /**
  23217. * Gets the list of physic impostors
  23218. * @returns an array of PhysicsImpostor
  23219. */
  23220. getImpostors(): Array<PhysicsImpostor>;
  23221. /**
  23222. * Gets the impostor for a physics enabled object
  23223. * @param object defines the object impersonated by the impostor
  23224. * @returns the PhysicsImpostor or null if not found
  23225. */
  23226. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23227. /**
  23228. * Gets the impostor for a physics body object
  23229. * @param body defines physics body used by the impostor
  23230. * @returns the PhysicsImpostor or null if not found
  23231. */
  23232. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23233. /**
  23234. * Does a raycast in the physics world
  23235. * @param from when should the ray start?
  23236. * @param to when should the ray end?
  23237. * @returns PhysicsRaycastResult
  23238. */
  23239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23240. /**
  23241. * Called by the scene. No need to call it.
  23242. * @param delta defines the timespam between frames
  23243. */
  23244. _step(delta: number): void;
  23245. }
  23246. }
  23247. declare module "babylonjs/Physics/physicsImpostor" {
  23248. import { Nullable, IndicesArray } from "babylonjs/types";
  23249. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23252. import { Scene } from "babylonjs/scene";
  23253. import { Bone } from "babylonjs/Bones/bone";
  23254. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23255. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23256. import { Space } from "babylonjs/Maths/math.axis";
  23257. /**
  23258. * The interface for the physics imposter parameters
  23259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23260. */
  23261. export interface PhysicsImpostorParameters {
  23262. /**
  23263. * The mass of the physics imposter
  23264. */
  23265. mass: number;
  23266. /**
  23267. * The friction of the physics imposter
  23268. */
  23269. friction?: number;
  23270. /**
  23271. * The coefficient of restitution of the physics imposter
  23272. */
  23273. restitution?: number;
  23274. /**
  23275. * The native options of the physics imposter
  23276. */
  23277. nativeOptions?: any;
  23278. /**
  23279. * Specifies if the parent should be ignored
  23280. */
  23281. ignoreParent?: boolean;
  23282. /**
  23283. * Specifies if bi-directional transformations should be disabled
  23284. */
  23285. disableBidirectionalTransformation?: boolean;
  23286. /**
  23287. * The pressure inside the physics imposter, soft object only
  23288. */
  23289. pressure?: number;
  23290. /**
  23291. * The stiffness the physics imposter, soft object only
  23292. */
  23293. stiffness?: number;
  23294. /**
  23295. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23296. */
  23297. velocityIterations?: number;
  23298. /**
  23299. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23300. */
  23301. positionIterations?: number;
  23302. /**
  23303. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23304. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23305. * Add to fix multiple points
  23306. */
  23307. fixedPoints?: number;
  23308. /**
  23309. * The collision margin around a soft object
  23310. */
  23311. margin?: number;
  23312. /**
  23313. * The collision margin around a soft object
  23314. */
  23315. damping?: number;
  23316. /**
  23317. * The path for a rope based on an extrusion
  23318. */
  23319. path?: any;
  23320. /**
  23321. * The shape of an extrusion used for a rope based on an extrusion
  23322. */
  23323. shape?: any;
  23324. }
  23325. /**
  23326. * Interface for a physics-enabled object
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface IPhysicsEnabledObject {
  23330. /**
  23331. * The position of the physics-enabled object
  23332. */
  23333. position: Vector3;
  23334. /**
  23335. * The rotation of the physics-enabled object
  23336. */
  23337. rotationQuaternion: Nullable<Quaternion>;
  23338. /**
  23339. * The scale of the physics-enabled object
  23340. */
  23341. scaling: Vector3;
  23342. /**
  23343. * The rotation of the physics-enabled object
  23344. */
  23345. rotation?: Vector3;
  23346. /**
  23347. * The parent of the physics-enabled object
  23348. */
  23349. parent?: any;
  23350. /**
  23351. * The bounding info of the physics-enabled object
  23352. * @returns The bounding info of the physics-enabled object
  23353. */
  23354. getBoundingInfo(): BoundingInfo;
  23355. /**
  23356. * Computes the world matrix
  23357. * @param force Specifies if the world matrix should be computed by force
  23358. * @returns A world matrix
  23359. */
  23360. computeWorldMatrix(force: boolean): Matrix;
  23361. /**
  23362. * Gets the world matrix
  23363. * @returns A world matrix
  23364. */
  23365. getWorldMatrix?(): Matrix;
  23366. /**
  23367. * Gets the child meshes
  23368. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23369. * @returns An array of abstract meshes
  23370. */
  23371. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23372. /**
  23373. * Gets the vertex data
  23374. * @param kind The type of vertex data
  23375. * @returns A nullable array of numbers, or a float32 array
  23376. */
  23377. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23378. /**
  23379. * Gets the indices from the mesh
  23380. * @returns A nullable array of index arrays
  23381. */
  23382. getIndices?(): Nullable<IndicesArray>;
  23383. /**
  23384. * Gets the scene from the mesh
  23385. * @returns the indices array or null
  23386. */
  23387. getScene?(): Scene;
  23388. /**
  23389. * Gets the absolute position from the mesh
  23390. * @returns the absolute position
  23391. */
  23392. getAbsolutePosition(): Vector3;
  23393. /**
  23394. * Gets the absolute pivot point from the mesh
  23395. * @returns the absolute pivot point
  23396. */
  23397. getAbsolutePivotPoint(): Vector3;
  23398. /**
  23399. * Rotates the mesh
  23400. * @param axis The axis of rotation
  23401. * @param amount The amount of rotation
  23402. * @param space The space of the rotation
  23403. * @returns The rotation transform node
  23404. */
  23405. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23406. /**
  23407. * Translates the mesh
  23408. * @param axis The axis of translation
  23409. * @param distance The distance of translation
  23410. * @param space The space of the translation
  23411. * @returns The transform node
  23412. */
  23413. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23414. /**
  23415. * Sets the absolute position of the mesh
  23416. * @param absolutePosition The absolute position of the mesh
  23417. * @returns The transform node
  23418. */
  23419. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23420. /**
  23421. * Gets the class name of the mesh
  23422. * @returns The class name
  23423. */
  23424. getClassName(): string;
  23425. }
  23426. /**
  23427. * Represents a physics imposter
  23428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23429. */
  23430. export class PhysicsImpostor {
  23431. /**
  23432. * The physics-enabled object used as the physics imposter
  23433. */
  23434. object: IPhysicsEnabledObject;
  23435. /**
  23436. * The type of the physics imposter
  23437. */
  23438. type: number;
  23439. private _options;
  23440. private _scene?;
  23441. /**
  23442. * The default object size of the imposter
  23443. */
  23444. static DEFAULT_OBJECT_SIZE: Vector3;
  23445. /**
  23446. * The identity quaternion of the imposter
  23447. */
  23448. static IDENTITY_QUATERNION: Quaternion;
  23449. /** @hidden */
  23450. _pluginData: any;
  23451. private _physicsEngine;
  23452. private _physicsBody;
  23453. private _bodyUpdateRequired;
  23454. private _onBeforePhysicsStepCallbacks;
  23455. private _onAfterPhysicsStepCallbacks;
  23456. /** @hidden */
  23457. _onPhysicsCollideCallbacks: Array<{
  23458. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23459. otherImpostors: Array<PhysicsImpostor>;
  23460. }>;
  23461. private _deltaPosition;
  23462. private _deltaRotation;
  23463. private _deltaRotationConjugated;
  23464. /** @hidden */
  23465. _isFromLine: boolean;
  23466. private _parent;
  23467. private _isDisposed;
  23468. private static _tmpVecs;
  23469. private static _tmpQuat;
  23470. /**
  23471. * Specifies if the physics imposter is disposed
  23472. */
  23473. readonly isDisposed: boolean;
  23474. /**
  23475. * Gets the mass of the physics imposter
  23476. */
  23477. mass: number;
  23478. /**
  23479. * Gets the coefficient of friction
  23480. */
  23481. /**
  23482. * Sets the coefficient of friction
  23483. */
  23484. friction: number;
  23485. /**
  23486. * Gets the coefficient of restitution
  23487. */
  23488. /**
  23489. * Sets the coefficient of restitution
  23490. */
  23491. restitution: number;
  23492. /**
  23493. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23494. */
  23495. /**
  23496. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23497. */
  23498. pressure: number;
  23499. /**
  23500. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23501. */
  23502. /**
  23503. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23504. */
  23505. stiffness: number;
  23506. /**
  23507. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23508. */
  23509. /**
  23510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23511. */
  23512. velocityIterations: number;
  23513. /**
  23514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23515. */
  23516. /**
  23517. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23518. */
  23519. positionIterations: number;
  23520. /**
  23521. * The unique id of the physics imposter
  23522. * set by the physics engine when adding this impostor to the array
  23523. */
  23524. uniqueId: number;
  23525. /**
  23526. * @hidden
  23527. */
  23528. soft: boolean;
  23529. /**
  23530. * @hidden
  23531. */
  23532. segments: number;
  23533. private _joints;
  23534. /**
  23535. * Initializes the physics imposter
  23536. * @param object The physics-enabled object used as the physics imposter
  23537. * @param type The type of the physics imposter
  23538. * @param _options The options for the physics imposter
  23539. * @param _scene The Babylon scene
  23540. */
  23541. constructor(
  23542. /**
  23543. * The physics-enabled object used as the physics imposter
  23544. */
  23545. object: IPhysicsEnabledObject,
  23546. /**
  23547. * The type of the physics imposter
  23548. */
  23549. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23550. /**
  23551. * This function will completly initialize this impostor.
  23552. * It will create a new body - but only if this mesh has no parent.
  23553. * If it has, this impostor will not be used other than to define the impostor
  23554. * of the child mesh.
  23555. * @hidden
  23556. */
  23557. _init(): void;
  23558. private _getPhysicsParent;
  23559. /**
  23560. * Should a new body be generated.
  23561. * @returns boolean specifying if body initialization is required
  23562. */
  23563. isBodyInitRequired(): boolean;
  23564. /**
  23565. * Sets the updated scaling
  23566. * @param updated Specifies if the scaling is updated
  23567. */
  23568. setScalingUpdated(): void;
  23569. /**
  23570. * Force a regeneration of this or the parent's impostor's body.
  23571. * Use under cautious - This will remove all joints already implemented.
  23572. */
  23573. forceUpdate(): void;
  23574. /**
  23575. * Gets the body that holds this impostor. Either its own, or its parent.
  23576. */
  23577. /**
  23578. * Set the physics body. Used mainly by the physics engine/plugin
  23579. */
  23580. physicsBody: any;
  23581. /**
  23582. * Get the parent of the physics imposter
  23583. * @returns Physics imposter or null
  23584. */
  23585. /**
  23586. * Sets the parent of the physics imposter
  23587. */
  23588. parent: Nullable<PhysicsImpostor>;
  23589. /**
  23590. * Resets the update flags
  23591. */
  23592. resetUpdateFlags(): void;
  23593. /**
  23594. * Gets the object extend size
  23595. * @returns the object extend size
  23596. */
  23597. getObjectExtendSize(): Vector3;
  23598. /**
  23599. * Gets the object center
  23600. * @returns The object center
  23601. */
  23602. getObjectCenter(): Vector3;
  23603. /**
  23604. * Get a specific parametes from the options parameter
  23605. * @param paramName The object parameter name
  23606. * @returns The object parameter
  23607. */
  23608. getParam(paramName: string): any;
  23609. /**
  23610. * Sets a specific parameter in the options given to the physics plugin
  23611. * @param paramName The parameter name
  23612. * @param value The value of the parameter
  23613. */
  23614. setParam(paramName: string, value: number): void;
  23615. /**
  23616. * Specifically change the body's mass option. Won't recreate the physics body object
  23617. * @param mass The mass of the physics imposter
  23618. */
  23619. setMass(mass: number): void;
  23620. /**
  23621. * Gets the linear velocity
  23622. * @returns linear velocity or null
  23623. */
  23624. getLinearVelocity(): Nullable<Vector3>;
  23625. /**
  23626. * Sets the linear velocity
  23627. * @param velocity linear velocity or null
  23628. */
  23629. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23630. /**
  23631. * Gets the angular velocity
  23632. * @returns angular velocity or null
  23633. */
  23634. getAngularVelocity(): Nullable<Vector3>;
  23635. /**
  23636. * Sets the angular velocity
  23637. * @param velocity The velocity or null
  23638. */
  23639. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23640. /**
  23641. * Execute a function with the physics plugin native code
  23642. * Provide a function the will have two variables - the world object and the physics body object
  23643. * @param func The function to execute with the physics plugin native code
  23644. */
  23645. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23646. /**
  23647. * Register a function that will be executed before the physics world is stepping forward
  23648. * @param func The function to execute before the physics world is stepped forward
  23649. */
  23650. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23651. /**
  23652. * Unregister a function that will be executed before the physics world is stepping forward
  23653. * @param func The function to execute before the physics world is stepped forward
  23654. */
  23655. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23656. /**
  23657. * Register a function that will be executed after the physics step
  23658. * @param func The function to execute after physics step
  23659. */
  23660. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23661. /**
  23662. * Unregisters a function that will be executed after the physics step
  23663. * @param func The function to execute after physics step
  23664. */
  23665. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23666. /**
  23667. * register a function that will be executed when this impostor collides against a different body
  23668. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23669. * @param func Callback that is executed on collision
  23670. */
  23671. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23672. /**
  23673. * Unregisters the physics imposter on contact
  23674. * @param collideAgainst The physics object to collide against
  23675. * @param func Callback to execute on collision
  23676. */
  23677. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23678. private _tmpQuat;
  23679. private _tmpQuat2;
  23680. /**
  23681. * Get the parent rotation
  23682. * @returns The parent rotation
  23683. */
  23684. getParentsRotation(): Quaternion;
  23685. /**
  23686. * this function is executed by the physics engine.
  23687. */
  23688. beforeStep: () => void;
  23689. /**
  23690. * this function is executed by the physics engine
  23691. */
  23692. afterStep: () => void;
  23693. /**
  23694. * Legacy collision detection event support
  23695. */
  23696. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23697. /**
  23698. * event and body object due to cannon's event-based architecture.
  23699. */
  23700. onCollide: (e: {
  23701. body: any;
  23702. }) => void;
  23703. /**
  23704. * Apply a force
  23705. * @param force The force to apply
  23706. * @param contactPoint The contact point for the force
  23707. * @returns The physics imposter
  23708. */
  23709. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23710. /**
  23711. * Apply an impulse
  23712. * @param force The impulse force
  23713. * @param contactPoint The contact point for the impulse force
  23714. * @returns The physics imposter
  23715. */
  23716. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23717. /**
  23718. * A help function to create a joint
  23719. * @param otherImpostor A physics imposter used to create a joint
  23720. * @param jointType The type of joint
  23721. * @param jointData The data for the joint
  23722. * @returns The physics imposter
  23723. */
  23724. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23725. /**
  23726. * Add a joint to this impostor with a different impostor
  23727. * @param otherImpostor A physics imposter used to add a joint
  23728. * @param joint The joint to add
  23729. * @returns The physics imposter
  23730. */
  23731. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23732. /**
  23733. * Add an anchor to a cloth impostor
  23734. * @param otherImpostor rigid impostor to anchor to
  23735. * @param width ratio across width from 0 to 1
  23736. * @param height ratio up height from 0 to 1
  23737. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23738. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23739. * @returns impostor the soft imposter
  23740. */
  23741. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23742. /**
  23743. * Add a hook to a rope impostor
  23744. * @param otherImpostor rigid impostor to anchor to
  23745. * @param length ratio across rope from 0 to 1
  23746. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23748. * @returns impostor the rope imposter
  23749. */
  23750. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23751. /**
  23752. * Will keep this body still, in a sleep mode.
  23753. * @returns the physics imposter
  23754. */
  23755. sleep(): PhysicsImpostor;
  23756. /**
  23757. * Wake the body up.
  23758. * @returns The physics imposter
  23759. */
  23760. wakeUp(): PhysicsImpostor;
  23761. /**
  23762. * Clones the physics imposter
  23763. * @param newObject The physics imposter clones to this physics-enabled object
  23764. * @returns A nullable physics imposter
  23765. */
  23766. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23767. /**
  23768. * Disposes the physics imposter
  23769. */
  23770. dispose(): void;
  23771. /**
  23772. * Sets the delta position
  23773. * @param position The delta position amount
  23774. */
  23775. setDeltaPosition(position: Vector3): void;
  23776. /**
  23777. * Sets the delta rotation
  23778. * @param rotation The delta rotation amount
  23779. */
  23780. setDeltaRotation(rotation: Quaternion): void;
  23781. /**
  23782. * Gets the box size of the physics imposter and stores the result in the input parameter
  23783. * @param result Stores the box size
  23784. * @returns The physics imposter
  23785. */
  23786. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23787. /**
  23788. * Gets the radius of the physics imposter
  23789. * @returns Radius of the physics imposter
  23790. */
  23791. getRadius(): number;
  23792. /**
  23793. * Sync a bone with this impostor
  23794. * @param bone The bone to sync to the impostor.
  23795. * @param boneMesh The mesh that the bone is influencing.
  23796. * @param jointPivot The pivot of the joint / bone in local space.
  23797. * @param distToJoint Optional distance from the impostor to the joint.
  23798. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23799. */
  23800. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23801. /**
  23802. * Sync impostor to a bone
  23803. * @param bone The bone that the impostor will be synced to.
  23804. * @param boneMesh The mesh that the bone is influencing.
  23805. * @param jointPivot The pivot of the joint / bone in local space.
  23806. * @param distToJoint Optional distance from the impostor to the joint.
  23807. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23808. * @param boneAxis Optional vector3 axis the bone is aligned with
  23809. */
  23810. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23811. /**
  23812. * No-Imposter type
  23813. */
  23814. static NoImpostor: number;
  23815. /**
  23816. * Sphere-Imposter type
  23817. */
  23818. static SphereImpostor: number;
  23819. /**
  23820. * Box-Imposter type
  23821. */
  23822. static BoxImpostor: number;
  23823. /**
  23824. * Plane-Imposter type
  23825. */
  23826. static PlaneImpostor: number;
  23827. /**
  23828. * Mesh-imposter type
  23829. */
  23830. static MeshImpostor: number;
  23831. /**
  23832. * Capsule-Impostor type (Ammo.js plugin only)
  23833. */
  23834. static CapsuleImpostor: number;
  23835. /**
  23836. * Cylinder-Imposter type
  23837. */
  23838. static CylinderImpostor: number;
  23839. /**
  23840. * Particle-Imposter type
  23841. */
  23842. static ParticleImpostor: number;
  23843. /**
  23844. * Heightmap-Imposter type
  23845. */
  23846. static HeightmapImpostor: number;
  23847. /**
  23848. * ConvexHull-Impostor type (Ammo.js plugin only)
  23849. */
  23850. static ConvexHullImpostor: number;
  23851. /**
  23852. * Rope-Imposter type
  23853. */
  23854. static RopeImpostor: number;
  23855. /**
  23856. * Cloth-Imposter type
  23857. */
  23858. static ClothImpostor: number;
  23859. /**
  23860. * Softbody-Imposter type
  23861. */
  23862. static SoftbodyImpostor: number;
  23863. }
  23864. }
  23865. declare module "babylonjs/Meshes/mesh" {
  23866. import { Observable } from "babylonjs/Misc/observable";
  23867. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23868. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23869. import { Camera } from "babylonjs/Cameras/camera";
  23870. import { Scene } from "babylonjs/scene";
  23871. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23872. import { Color4 } from "babylonjs/Maths/math.color";
  23873. import { Engine } from "babylonjs/Engines/engine";
  23874. import { Node } from "babylonjs/node";
  23875. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23876. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23877. import { Buffer } from "babylonjs/Meshes/buffer";
  23878. import { Geometry } from "babylonjs/Meshes/geometry";
  23879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23882. import { Effect } from "babylonjs/Materials/effect";
  23883. import { Material } from "babylonjs/Materials/material";
  23884. import { Skeleton } from "babylonjs/Bones/skeleton";
  23885. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23886. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23887. import { Path3D } from "babylonjs/Maths/math.path";
  23888. import { Plane } from "babylonjs/Maths/math.plane";
  23889. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23890. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23891. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23892. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23893. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23894. /**
  23895. * @hidden
  23896. **/
  23897. export class _CreationDataStorage {
  23898. closePath?: boolean;
  23899. closeArray?: boolean;
  23900. idx: number[];
  23901. dashSize: number;
  23902. gapSize: number;
  23903. path3D: Path3D;
  23904. pathArray: Vector3[][];
  23905. arc: number;
  23906. radius: number;
  23907. cap: number;
  23908. tessellation: number;
  23909. }
  23910. /**
  23911. * @hidden
  23912. **/
  23913. class _InstanceDataStorage {
  23914. visibleInstances: any;
  23915. batchCache: _InstancesBatch;
  23916. instancesBufferSize: number;
  23917. instancesBuffer: Nullable<Buffer>;
  23918. instancesData: Float32Array;
  23919. overridenInstanceCount: number;
  23920. isFrozen: boolean;
  23921. previousBatch: Nullable<_InstancesBatch>;
  23922. hardwareInstancedRendering: boolean;
  23923. sideOrientation: number;
  23924. }
  23925. /**
  23926. * @hidden
  23927. **/
  23928. export class _InstancesBatch {
  23929. mustReturn: boolean;
  23930. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23931. renderSelf: boolean[];
  23932. hardwareInstancedRendering: boolean[];
  23933. }
  23934. /**
  23935. * Class used to represent renderable models
  23936. */
  23937. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23938. /**
  23939. * Mesh side orientation : usually the external or front surface
  23940. */
  23941. static readonly FRONTSIDE: number;
  23942. /**
  23943. * Mesh side orientation : usually the internal or back surface
  23944. */
  23945. static readonly BACKSIDE: number;
  23946. /**
  23947. * Mesh side orientation : both internal and external or front and back surfaces
  23948. */
  23949. static readonly DOUBLESIDE: number;
  23950. /**
  23951. * Mesh side orientation : by default, `FRONTSIDE`
  23952. */
  23953. static readonly DEFAULTSIDE: number;
  23954. /**
  23955. * Mesh cap setting : no cap
  23956. */
  23957. static readonly NO_CAP: number;
  23958. /**
  23959. * Mesh cap setting : one cap at the beginning of the mesh
  23960. */
  23961. static readonly CAP_START: number;
  23962. /**
  23963. * Mesh cap setting : one cap at the end of the mesh
  23964. */
  23965. static readonly CAP_END: number;
  23966. /**
  23967. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23968. */
  23969. static readonly CAP_ALL: number;
  23970. /**
  23971. * Mesh pattern setting : no flip or rotate
  23972. */
  23973. static readonly NO_FLIP: number;
  23974. /**
  23975. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23976. */
  23977. static readonly FLIP_TILE: number;
  23978. /**
  23979. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23980. */
  23981. static readonly ROTATE_TILE: number;
  23982. /**
  23983. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23984. */
  23985. static readonly FLIP_ROW: number;
  23986. /**
  23987. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23988. */
  23989. static readonly ROTATE_ROW: number;
  23990. /**
  23991. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23992. */
  23993. static readonly FLIP_N_ROTATE_TILE: number;
  23994. /**
  23995. * Mesh pattern setting : rotate pattern and rotate
  23996. */
  23997. static readonly FLIP_N_ROTATE_ROW: number;
  23998. /**
  23999. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24000. */
  24001. static readonly CENTER: number;
  24002. /**
  24003. * Mesh tile positioning : part tiles on left
  24004. */
  24005. static readonly LEFT: number;
  24006. /**
  24007. * Mesh tile positioning : part tiles on right
  24008. */
  24009. static readonly RIGHT: number;
  24010. /**
  24011. * Mesh tile positioning : part tiles on top
  24012. */
  24013. static readonly TOP: number;
  24014. /**
  24015. * Mesh tile positioning : part tiles on bottom
  24016. */
  24017. static readonly BOTTOM: number;
  24018. /**
  24019. * Gets the default side orientation.
  24020. * @param orientation the orientation to value to attempt to get
  24021. * @returns the default orientation
  24022. * @hidden
  24023. */
  24024. static _GetDefaultSideOrientation(orientation?: number): number;
  24025. private _internalMeshDataInfo;
  24026. /**
  24027. * An event triggered before rendering the mesh
  24028. */
  24029. readonly onBeforeRenderObservable: Observable<Mesh>;
  24030. /**
  24031. * An event triggered before binding the mesh
  24032. */
  24033. readonly onBeforeBindObservable: Observable<Mesh>;
  24034. /**
  24035. * An event triggered after rendering the mesh
  24036. */
  24037. readonly onAfterRenderObservable: Observable<Mesh>;
  24038. /**
  24039. * An event triggered before drawing the mesh
  24040. */
  24041. readonly onBeforeDrawObservable: Observable<Mesh>;
  24042. private _onBeforeDrawObserver;
  24043. /**
  24044. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24045. */
  24046. onBeforeDraw: () => void;
  24047. readonly hasInstances: boolean;
  24048. /**
  24049. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24050. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24051. */
  24052. delayLoadState: number;
  24053. /**
  24054. * Gets the list of instances created from this mesh
  24055. * it is not supposed to be modified manually.
  24056. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24057. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24058. */
  24059. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24060. /**
  24061. * Gets the file containing delay loading data for this mesh
  24062. */
  24063. delayLoadingFile: string;
  24064. /** @hidden */
  24065. _binaryInfo: any;
  24066. /**
  24067. * User defined function used to change how LOD level selection is done
  24068. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24069. */
  24070. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24071. /**
  24072. * Gets or sets the morph target manager
  24073. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24074. */
  24075. morphTargetManager: Nullable<MorphTargetManager>;
  24076. /** @hidden */
  24077. _creationDataStorage: Nullable<_CreationDataStorage>;
  24078. /** @hidden */
  24079. _geometry: Nullable<Geometry>;
  24080. /** @hidden */
  24081. _delayInfo: Array<string>;
  24082. /** @hidden */
  24083. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24084. /** @hidden */
  24085. _instanceDataStorage: _InstanceDataStorage;
  24086. private _effectiveMaterial;
  24087. /** @hidden */
  24088. _shouldGenerateFlatShading: boolean;
  24089. /** @hidden */
  24090. _originalBuilderSideOrientation: number;
  24091. /**
  24092. * Use this property to change the original side orientation defined at construction time
  24093. */
  24094. overrideMaterialSideOrientation: Nullable<number>;
  24095. /**
  24096. * Gets the source mesh (the one used to clone this one from)
  24097. */
  24098. readonly source: Nullable<Mesh>;
  24099. /**
  24100. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24101. */
  24102. isUnIndexed: boolean;
  24103. /**
  24104. * @constructor
  24105. * @param name The value used by scene.getMeshByName() to do a lookup.
  24106. * @param scene The scene to add this mesh to.
  24107. * @param parent The parent of this mesh, if it has one
  24108. * @param source An optional Mesh from which geometry is shared, cloned.
  24109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24110. * When false, achieved by calling a clone(), also passing False.
  24111. * This will make creation of children, recursive.
  24112. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24113. */
  24114. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24115. /**
  24116. * Gets the class name
  24117. * @returns the string "Mesh".
  24118. */
  24119. getClassName(): string;
  24120. /** @hidden */
  24121. readonly _isMesh: boolean;
  24122. /**
  24123. * Returns a description of this mesh
  24124. * @param fullDetails define if full details about this mesh must be used
  24125. * @returns a descriptive string representing this mesh
  24126. */
  24127. toString(fullDetails?: boolean): string;
  24128. /** @hidden */
  24129. _unBindEffect(): void;
  24130. /**
  24131. * Gets a boolean indicating if this mesh has LOD
  24132. */
  24133. readonly hasLODLevels: boolean;
  24134. /**
  24135. * Gets the list of MeshLODLevel associated with the current mesh
  24136. * @returns an array of MeshLODLevel
  24137. */
  24138. getLODLevels(): MeshLODLevel[];
  24139. private _sortLODLevels;
  24140. /**
  24141. * Add a mesh as LOD level triggered at the given distance.
  24142. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24143. * @param distance The distance from the center of the object to show this level
  24144. * @param mesh The mesh to be added as LOD level (can be null)
  24145. * @return This mesh (for chaining)
  24146. */
  24147. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24148. /**
  24149. * Returns the LOD level mesh at the passed distance or null if not found.
  24150. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24151. * @param distance The distance from the center of the object to show this level
  24152. * @returns a Mesh or `null`
  24153. */
  24154. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24155. /**
  24156. * Remove a mesh from the LOD array
  24157. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24158. * @param mesh defines the mesh to be removed
  24159. * @return This mesh (for chaining)
  24160. */
  24161. removeLODLevel(mesh: Mesh): Mesh;
  24162. /**
  24163. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24165. * @param camera defines the camera to use to compute distance
  24166. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24167. * @return This mesh (for chaining)
  24168. */
  24169. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24170. /**
  24171. * Gets the mesh internal Geometry object
  24172. */
  24173. readonly geometry: Nullable<Geometry>;
  24174. /**
  24175. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24176. * @returns the total number of vertices
  24177. */
  24178. getTotalVertices(): number;
  24179. /**
  24180. * Returns the content of an associated vertex buffer
  24181. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24182. * - VertexBuffer.PositionKind
  24183. * - VertexBuffer.UVKind
  24184. * - VertexBuffer.UV2Kind
  24185. * - VertexBuffer.UV3Kind
  24186. * - VertexBuffer.UV4Kind
  24187. * - VertexBuffer.UV5Kind
  24188. * - VertexBuffer.UV6Kind
  24189. * - VertexBuffer.ColorKind
  24190. * - VertexBuffer.MatricesIndicesKind
  24191. * - VertexBuffer.MatricesIndicesExtraKind
  24192. * - VertexBuffer.MatricesWeightsKind
  24193. * - VertexBuffer.MatricesWeightsExtraKind
  24194. * @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
  24195. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24196. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24197. */
  24198. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24199. /**
  24200. * Returns the mesh VertexBuffer object from the requested `kind`
  24201. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24202. * - VertexBuffer.PositionKind
  24203. * - VertexBuffer.NormalKind
  24204. * - VertexBuffer.UVKind
  24205. * - VertexBuffer.UV2Kind
  24206. * - VertexBuffer.UV3Kind
  24207. * - VertexBuffer.UV4Kind
  24208. * - VertexBuffer.UV5Kind
  24209. * - VertexBuffer.UV6Kind
  24210. * - VertexBuffer.ColorKind
  24211. * - VertexBuffer.MatricesIndicesKind
  24212. * - VertexBuffer.MatricesIndicesExtraKind
  24213. * - VertexBuffer.MatricesWeightsKind
  24214. * - VertexBuffer.MatricesWeightsExtraKind
  24215. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24216. */
  24217. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24218. /**
  24219. * Tests if a specific vertex buffer is associated with this mesh
  24220. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24221. * - VertexBuffer.PositionKind
  24222. * - VertexBuffer.NormalKind
  24223. * - VertexBuffer.UVKind
  24224. * - VertexBuffer.UV2Kind
  24225. * - VertexBuffer.UV3Kind
  24226. * - VertexBuffer.UV4Kind
  24227. * - VertexBuffer.UV5Kind
  24228. * - VertexBuffer.UV6Kind
  24229. * - VertexBuffer.ColorKind
  24230. * - VertexBuffer.MatricesIndicesKind
  24231. * - VertexBuffer.MatricesIndicesExtraKind
  24232. * - VertexBuffer.MatricesWeightsKind
  24233. * - VertexBuffer.MatricesWeightsExtraKind
  24234. * @returns a boolean
  24235. */
  24236. isVerticesDataPresent(kind: string): boolean;
  24237. /**
  24238. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24240. * - VertexBuffer.PositionKind
  24241. * - VertexBuffer.UVKind
  24242. * - VertexBuffer.UV2Kind
  24243. * - VertexBuffer.UV3Kind
  24244. * - VertexBuffer.UV4Kind
  24245. * - VertexBuffer.UV5Kind
  24246. * - VertexBuffer.UV6Kind
  24247. * - VertexBuffer.ColorKind
  24248. * - VertexBuffer.MatricesIndicesKind
  24249. * - VertexBuffer.MatricesIndicesExtraKind
  24250. * - VertexBuffer.MatricesWeightsKind
  24251. * - VertexBuffer.MatricesWeightsExtraKind
  24252. * @returns a boolean
  24253. */
  24254. isVertexBufferUpdatable(kind: string): boolean;
  24255. /**
  24256. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24257. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24258. * - VertexBuffer.PositionKind
  24259. * - VertexBuffer.NormalKind
  24260. * - VertexBuffer.UVKind
  24261. * - VertexBuffer.UV2Kind
  24262. * - VertexBuffer.UV3Kind
  24263. * - VertexBuffer.UV4Kind
  24264. * - VertexBuffer.UV5Kind
  24265. * - VertexBuffer.UV6Kind
  24266. * - VertexBuffer.ColorKind
  24267. * - VertexBuffer.MatricesIndicesKind
  24268. * - VertexBuffer.MatricesIndicesExtraKind
  24269. * - VertexBuffer.MatricesWeightsKind
  24270. * - VertexBuffer.MatricesWeightsExtraKind
  24271. * @returns an array of strings
  24272. */
  24273. getVerticesDataKinds(): string[];
  24274. /**
  24275. * Returns a positive integer : the total number of indices in this mesh geometry.
  24276. * @returns the numner of indices or zero if the mesh has no geometry.
  24277. */
  24278. getTotalIndices(): number;
  24279. /**
  24280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24281. * @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.
  24282. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24283. * @returns the indices array or an empty array if the mesh has no geometry
  24284. */
  24285. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24286. readonly isBlocked: boolean;
  24287. /**
  24288. * Determine if the current mesh is ready to be rendered
  24289. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24290. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24291. * @returns true if all associated assets are ready (material, textures, shaders)
  24292. */
  24293. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24294. /**
  24295. * 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.
  24296. */
  24297. readonly areNormalsFrozen: boolean;
  24298. /**
  24299. * 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.
  24300. * @returns the current mesh
  24301. */
  24302. freezeNormals(): Mesh;
  24303. /**
  24304. * 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
  24305. * @returns the current mesh
  24306. */
  24307. unfreezeNormals(): Mesh;
  24308. /**
  24309. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24310. */
  24311. overridenInstanceCount: number;
  24312. /** @hidden */
  24313. _preActivate(): Mesh;
  24314. /** @hidden */
  24315. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24316. /** @hidden */
  24317. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24318. /**
  24319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24320. * This means the mesh underlying bounding box and sphere are recomputed.
  24321. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24322. * @returns the current mesh
  24323. */
  24324. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24325. /** @hidden */
  24326. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24327. /**
  24328. * This function will subdivide the mesh into multiple submeshes
  24329. * @param count defines the expected number of submeshes
  24330. */
  24331. subdivide(count: number): void;
  24332. /**
  24333. * Copy a FloatArray into a specific associated vertex buffer
  24334. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24335. * - VertexBuffer.PositionKind
  24336. * - VertexBuffer.UVKind
  24337. * - VertexBuffer.UV2Kind
  24338. * - VertexBuffer.UV3Kind
  24339. * - VertexBuffer.UV4Kind
  24340. * - VertexBuffer.UV5Kind
  24341. * - VertexBuffer.UV6Kind
  24342. * - VertexBuffer.ColorKind
  24343. * - VertexBuffer.MatricesIndicesKind
  24344. * - VertexBuffer.MatricesIndicesExtraKind
  24345. * - VertexBuffer.MatricesWeightsKind
  24346. * - VertexBuffer.MatricesWeightsExtraKind
  24347. * @param data defines the data source
  24348. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24349. * @param stride defines the data stride size (can be null)
  24350. * @returns the current mesh
  24351. */
  24352. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24353. /**
  24354. * Flags an associated vertex buffer as updatable
  24355. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24356. * - VertexBuffer.PositionKind
  24357. * - VertexBuffer.UVKind
  24358. * - VertexBuffer.UV2Kind
  24359. * - VertexBuffer.UV3Kind
  24360. * - VertexBuffer.UV4Kind
  24361. * - VertexBuffer.UV5Kind
  24362. * - VertexBuffer.UV6Kind
  24363. * - VertexBuffer.ColorKind
  24364. * - VertexBuffer.MatricesIndicesKind
  24365. * - VertexBuffer.MatricesIndicesExtraKind
  24366. * - VertexBuffer.MatricesWeightsKind
  24367. * - VertexBuffer.MatricesWeightsExtraKind
  24368. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24369. */
  24370. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24371. /**
  24372. * Sets the mesh global Vertex Buffer
  24373. * @param buffer defines the buffer to use
  24374. * @returns the current mesh
  24375. */
  24376. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24377. /**
  24378. * Update a specific associated vertex buffer
  24379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24380. * - VertexBuffer.PositionKind
  24381. * - VertexBuffer.UVKind
  24382. * - VertexBuffer.UV2Kind
  24383. * - VertexBuffer.UV3Kind
  24384. * - VertexBuffer.UV4Kind
  24385. * - VertexBuffer.UV5Kind
  24386. * - VertexBuffer.UV6Kind
  24387. * - VertexBuffer.ColorKind
  24388. * - VertexBuffer.MatricesIndicesKind
  24389. * - VertexBuffer.MatricesIndicesExtraKind
  24390. * - VertexBuffer.MatricesWeightsKind
  24391. * - VertexBuffer.MatricesWeightsExtraKind
  24392. * @param data defines the data source
  24393. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24394. * @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)
  24395. * @returns the current mesh
  24396. */
  24397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24398. /**
  24399. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24400. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24401. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24402. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24403. * @returns the current mesh
  24404. */
  24405. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24406. /**
  24407. * Creates a un-shared specific occurence of the geometry for the mesh.
  24408. * @returns the current mesh
  24409. */
  24410. makeGeometryUnique(): Mesh;
  24411. /**
  24412. * Set the index buffer of this mesh
  24413. * @param indices defines the source data
  24414. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24415. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24416. * @returns the current mesh
  24417. */
  24418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24419. /**
  24420. * Update the current index buffer
  24421. * @param indices defines the source data
  24422. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24423. * @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)
  24424. * @returns the current mesh
  24425. */
  24426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24427. /**
  24428. * Invert the geometry to move from a right handed system to a left handed one.
  24429. * @returns the current mesh
  24430. */
  24431. toLeftHanded(): Mesh;
  24432. /** @hidden */
  24433. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24434. /** @hidden */
  24435. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24436. /**
  24437. * Registers for this mesh a javascript function called just before the rendering process
  24438. * @param func defines the function to call before rendering this mesh
  24439. * @returns the current mesh
  24440. */
  24441. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24442. /**
  24443. * Disposes a previously registered javascript function called before the rendering
  24444. * @param func defines the function to remove
  24445. * @returns the current mesh
  24446. */
  24447. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24448. /**
  24449. * Registers for this mesh a javascript function called just after the rendering is complete
  24450. * @param func defines the function to call after rendering this mesh
  24451. * @returns the current mesh
  24452. */
  24453. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24454. /**
  24455. * Disposes a previously registered javascript function called after the rendering.
  24456. * @param func defines the function to remove
  24457. * @returns the current mesh
  24458. */
  24459. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24460. /** @hidden */
  24461. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24462. /** @hidden */
  24463. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24464. /** @hidden */
  24465. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24466. /** @hidden */
  24467. _rebuild(): void;
  24468. /** @hidden */
  24469. _freeze(): void;
  24470. /** @hidden */
  24471. _unFreeze(): void;
  24472. /**
  24473. * 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
  24474. * @param subMesh defines the subMesh to render
  24475. * @param enableAlphaMode defines if alpha mode can be changed
  24476. * @returns the current mesh
  24477. */
  24478. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24479. private _onBeforeDraw;
  24480. /**
  24481. * Renormalize the mesh and patch it up if there are no weights
  24482. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24483. * However in the case of zero weights then we set just a single influence to 1.
  24484. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24485. */
  24486. cleanMatrixWeights(): void;
  24487. private normalizeSkinFourWeights;
  24488. private normalizeSkinWeightsAndExtra;
  24489. /**
  24490. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24491. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24492. * the user know there was an issue with importing the mesh
  24493. * @returns a validation object with skinned, valid and report string
  24494. */
  24495. validateSkinning(): {
  24496. skinned: boolean;
  24497. valid: boolean;
  24498. report: string;
  24499. };
  24500. /** @hidden */
  24501. _checkDelayState(): Mesh;
  24502. private _queueLoad;
  24503. /**
  24504. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24505. * A mesh is in the frustum if its bounding box intersects the frustum
  24506. * @param frustumPlanes defines the frustum to test
  24507. * @returns true if the mesh is in the frustum planes
  24508. */
  24509. isInFrustum(frustumPlanes: Plane[]): boolean;
  24510. /**
  24511. * Sets the mesh material by the material or multiMaterial `id` property
  24512. * @param id is a string identifying the material or the multiMaterial
  24513. * @returns the current mesh
  24514. */
  24515. setMaterialByID(id: string): Mesh;
  24516. /**
  24517. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24518. * @returns an array of IAnimatable
  24519. */
  24520. getAnimatables(): IAnimatable[];
  24521. /**
  24522. * Modifies the mesh geometry according to the passed transformation matrix.
  24523. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24524. * The mesh normals are modified using the same transformation.
  24525. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24526. * @param transform defines the transform matrix to use
  24527. * @see http://doc.babylonjs.com/resources/baking_transformations
  24528. * @returns the current mesh
  24529. */
  24530. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24531. /**
  24532. * Modifies the mesh geometry according to its own current World Matrix.
  24533. * The mesh World Matrix is then reset.
  24534. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24535. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24536. * @see http://doc.babylonjs.com/resources/baking_transformations
  24537. * @returns the current mesh
  24538. */
  24539. bakeCurrentTransformIntoVertices(): Mesh;
  24540. /** @hidden */
  24541. readonly _positions: Nullable<Vector3[]>;
  24542. /** @hidden */
  24543. _resetPointsArrayCache(): Mesh;
  24544. /** @hidden */
  24545. _generatePointsArray(): boolean;
  24546. /**
  24547. * Returns a new Mesh object generated from the current mesh properties.
  24548. * This method must not get confused with createInstance()
  24549. * @param name is a string, the name given to the new mesh
  24550. * @param newParent can be any Node object (default `null`)
  24551. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24552. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24553. * @returns a new mesh
  24554. */
  24555. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24556. /**
  24557. * Releases resources associated with this mesh.
  24558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24560. */
  24561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24562. /**
  24563. * Modifies the mesh geometry according to a displacement map.
  24564. * 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.
  24565. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24566. * @param url is a string, the URL from the image file is to be downloaded.
  24567. * @param minHeight is the lower limit of the displacement.
  24568. * @param maxHeight is the upper limit of the displacement.
  24569. * @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.
  24570. * @param uvOffset is an optional vector2 used to offset UV.
  24571. * @param uvScale is an optional vector2 used to scale UV.
  24572. * @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.
  24573. * @returns the Mesh.
  24574. */
  24575. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24576. /**
  24577. * Modifies the mesh geometry according to a displacementMap buffer.
  24578. * 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.
  24579. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24580. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24581. * @param heightMapWidth is the width of the buffer image.
  24582. * @param heightMapHeight is the height of the buffer image.
  24583. * @param minHeight is the lower limit of the displacement.
  24584. * @param maxHeight is the upper limit of the displacement.
  24585. * @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.
  24586. * @param uvOffset is an optional vector2 used to offset UV.
  24587. * @param uvScale is an optional vector2 used to scale UV.
  24588. * @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.
  24589. * @returns the Mesh.
  24590. */
  24591. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24592. /**
  24593. * Modify the mesh to get a flat shading rendering.
  24594. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24595. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24596. * @returns current mesh
  24597. */
  24598. convertToFlatShadedMesh(): Mesh;
  24599. /**
  24600. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24601. * In other words, more vertices, no more indices and a single bigger VBO.
  24602. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24603. * @returns current mesh
  24604. */
  24605. convertToUnIndexedMesh(): Mesh;
  24606. /**
  24607. * Inverses facet orientations.
  24608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24609. * @param flipNormals will also inverts the normals
  24610. * @returns current mesh
  24611. */
  24612. flipFaces(flipNormals?: boolean): Mesh;
  24613. /**
  24614. * Increase the number of facets and hence vertices in a mesh
  24615. * Vertex normals are interpolated from existing vertex normals
  24616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24617. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24618. */
  24619. increaseVertices(numberPerEdge: number): void;
  24620. /**
  24621. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24622. * This will undo any application of covertToFlatShadedMesh
  24623. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24624. */
  24625. forceSharedVertices(): void;
  24626. /** @hidden */
  24627. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24628. /** @hidden */
  24629. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24630. /**
  24631. * Creates a new InstancedMesh object from the mesh model.
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24633. * @param name defines the name of the new instance
  24634. * @returns a new InstancedMesh
  24635. */
  24636. createInstance(name: string): InstancedMesh;
  24637. /**
  24638. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24639. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24640. * @returns the current mesh
  24641. */
  24642. synchronizeInstances(): Mesh;
  24643. /**
  24644. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24645. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24646. * This should be used together with the simplification to avoid disappearing triangles.
  24647. * @param successCallback an optional success callback to be called after the optimization finished.
  24648. * @returns the current mesh
  24649. */
  24650. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24651. /**
  24652. * Serialize current mesh
  24653. * @param serializationObject defines the object which will receive the serialization data
  24654. */
  24655. serialize(serializationObject: any): void;
  24656. /** @hidden */
  24657. _syncGeometryWithMorphTargetManager(): void;
  24658. /** @hidden */
  24659. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24660. /**
  24661. * Returns a new Mesh object parsed from the source provided.
  24662. * @param parsedMesh is the source
  24663. * @param scene defines the hosting scene
  24664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24665. * @returns a new Mesh
  24666. */
  24667. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24668. /**
  24669. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24670. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24671. * @param name defines the name of the mesh to create
  24672. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24673. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24674. * @param closePath creates a seam between the first and the last points of each path of the path array
  24675. * @param offset is taken in account only if the `pathArray` is containing a single path
  24676. * @param scene defines the hosting scene
  24677. * @param updatable defines if the mesh must be flagged as updatable
  24678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24679. * @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)
  24680. * @returns a new Mesh
  24681. */
  24682. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24683. /**
  24684. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24685. * @param name defines the name of the mesh to create
  24686. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24687. * @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
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24694. /**
  24695. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param size sets the size (float) of each box side (default 1)
  24698. * @param scene defines the hosting scene
  24699. * @param updatable defines if the mesh must be flagged as updatable
  24700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24701. * @returns a new Mesh
  24702. */
  24703. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24704. /**
  24705. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24706. * @param name defines the name of the mesh to create
  24707. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24708. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24709. * @param scene defines the hosting scene
  24710. * @param updatable defines if the mesh must be flagged as updatable
  24711. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24712. * @returns a new Mesh
  24713. */
  24714. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24715. /**
  24716. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24717. * @param name defines the name of the mesh to create
  24718. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24719. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24720. * @param scene defines the hosting scene
  24721. * @returns a new Mesh
  24722. */
  24723. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24724. /**
  24725. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24726. * @param name defines the name of the mesh to create
  24727. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24728. * @param diameterTop set the top cap diameter (floats, default 1)
  24729. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24730. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24731. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24732. * @param scene defines the hosting scene
  24733. * @param updatable defines if the mesh must be flagged as updatable
  24734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24735. * @returns a new Mesh
  24736. */
  24737. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24738. /**
  24739. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24740. * @param name defines the name of the mesh to create
  24741. * @param diameter sets the diameter size (float) of the torus (default 1)
  24742. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24743. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24744. * @param scene defines the hosting scene
  24745. * @param updatable defines if the mesh must be flagged as updatable
  24746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24747. * @returns a new Mesh
  24748. */
  24749. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24750. /**
  24751. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24752. * @param name defines the name of the mesh to create
  24753. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24754. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24755. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24756. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24757. * @param p the number of windings on X axis (positive integers, default 2)
  24758. * @param q the number of windings on Y axis (positive integers, default 3)
  24759. * @param scene defines the hosting scene
  24760. * @param updatable defines if the mesh must be flagged as updatable
  24761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24762. * @returns a new Mesh
  24763. */
  24764. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24765. /**
  24766. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24767. * @param name defines the name of the mesh to create
  24768. * @param points is an array successive Vector3
  24769. * @param scene defines the hosting scene
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @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).
  24772. * @returns a new Mesh
  24773. */
  24774. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24775. /**
  24776. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24777. * @param name defines the name of the mesh to create
  24778. * @param points is an array successive Vector3
  24779. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24780. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24781. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24782. * @param scene defines the hosting scene
  24783. * @param updatable defines if the mesh must be flagged as updatable
  24784. * @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)
  24785. * @returns a new Mesh
  24786. */
  24787. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24788. /**
  24789. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24790. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24791. * 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.
  24792. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24793. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24794. * Remember you can only change the shape positions, not their number when updating a polygon.
  24795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24796. * @param name defines the name of the mesh to create
  24797. * @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
  24798. * @param scene defines the hosting scene
  24799. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24800. * @param updatable defines if the mesh must be flagged as updatable
  24801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24802. * @param earcutInjection can be used to inject your own earcut reference
  24803. * @returns a new Mesh
  24804. */
  24805. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24806. /**
  24807. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24808. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24809. * @param name defines the name of the mesh to create
  24810. * @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
  24811. * @param depth defines the height of extrusion
  24812. * @param scene defines the hosting scene
  24813. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24814. * @param updatable defines if the mesh must be flagged as updatable
  24815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24816. * @param earcutInjection can be used to inject your own earcut reference
  24817. * @returns a new Mesh
  24818. */
  24819. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24820. /**
  24821. * Creates an extruded shape mesh.
  24822. * 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
  24823. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24824. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24825. * @param name defines the name of the mesh to create
  24826. * @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
  24827. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24828. * @param scale is the value to scale the shape
  24829. * @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
  24830. * @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
  24831. * @param scene defines the hosting scene
  24832. * @param updatable defines if the mesh must be flagged as updatable
  24833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24834. * @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)
  24835. * @returns a new Mesh
  24836. */
  24837. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24838. /**
  24839. * Creates an custom extruded shape mesh.
  24840. * The custom extrusion is a parametric shape.
  24841. * It has no predefined shape. Its final shape will depend on the input parameters.
  24842. * Please consider using the same method from the MeshBuilder class instead
  24843. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24844. * @param name defines the name of the mesh to create
  24845. * @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
  24846. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24847. * @param scaleFunction is a custom Javascript function called on each path point
  24848. * @param rotationFunction is a custom Javascript function called on each path point
  24849. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24850. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24851. * @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
  24852. * @param scene defines the hosting scene
  24853. * @param updatable defines if the mesh must be flagged as updatable
  24854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24855. * @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)
  24856. * @returns a new Mesh
  24857. */
  24858. 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;
  24859. /**
  24860. * Creates lathe mesh.
  24861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24862. * Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @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
  24865. * @param radius is the radius value of the lathe
  24866. * @param tessellation is the side number of the lathe.
  24867. * @param scene defines the hosting scene
  24868. * @param updatable defines if the mesh must be flagged as updatable
  24869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24870. * @returns a new Mesh
  24871. */
  24872. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24873. /**
  24874. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24875. * @param name defines the name of the mesh to create
  24876. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @param updatable defines if the mesh must be flagged as updatable
  24879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24880. * @returns a new Mesh
  24881. */
  24882. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24883. /**
  24884. * Creates a ground mesh.
  24885. * Please consider using the same method from the MeshBuilder class instead
  24886. * @param name defines the name of the mesh to create
  24887. * @param width set the width of the ground
  24888. * @param height set the height of the ground
  24889. * @param subdivisions sets the number of subdivisions per side
  24890. * @param scene defines the hosting scene
  24891. * @param updatable defines if the mesh must be flagged as updatable
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24895. /**
  24896. * Creates a tiled ground mesh.
  24897. * Please consider using the same method from the MeshBuilder class instead
  24898. * @param name defines the name of the mesh to create
  24899. * @param xmin set the ground minimum X coordinate
  24900. * @param zmin set the ground minimum Y coordinate
  24901. * @param xmax set the ground maximum X coordinate
  24902. * @param zmax set the ground maximum Z coordinate
  24903. * @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
  24904. * @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
  24905. * @param scene defines the hosting scene
  24906. * @param updatable defines if the mesh must be flagged as updatable
  24907. * @returns a new Mesh
  24908. */
  24909. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24910. w: number;
  24911. h: number;
  24912. }, precision: {
  24913. w: number;
  24914. h: number;
  24915. }, scene: Scene, updatable?: boolean): Mesh;
  24916. /**
  24917. * Creates a ground mesh from a height map.
  24918. * Please consider using the same method from the MeshBuilder class instead
  24919. * @see http://doc.babylonjs.com/babylon101/height_map
  24920. * @param name defines the name of the mesh to create
  24921. * @param url sets the URL of the height map image resource
  24922. * @param width set the ground width size
  24923. * @param height set the ground height size
  24924. * @param subdivisions sets the number of subdivision per side
  24925. * @param minHeight is the minimum altitude on the ground
  24926. * @param maxHeight is the maximum altitude on the ground
  24927. * @param scene defines the hosting scene
  24928. * @param updatable defines if the mesh must be flagged as updatable
  24929. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24930. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24931. * @returns a new Mesh
  24932. */
  24933. 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;
  24934. /**
  24935. * Creates a tube mesh.
  24936. * The tube is a parametric shape.
  24937. * It has no predefined shape. Its final shape will depend on the input parameters.
  24938. * Please consider using the same method from the MeshBuilder class instead
  24939. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24940. * @param name defines the name of the mesh to create
  24941. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24942. * @param radius sets the tube radius size
  24943. * @param tessellation is the number of sides on the tubular surface
  24944. * @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
  24945. * @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
  24946. * @param scene defines the hosting scene
  24947. * @param updatable defines if the mesh must be flagged as updatable
  24948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24949. * @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)
  24950. * @returns a new Mesh
  24951. */
  24952. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24953. (i: number, distance: number): number;
  24954. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24955. /**
  24956. * Creates a polyhedron mesh.
  24957. * Please consider using the same method from the MeshBuilder class instead.
  24958. * * 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
  24959. * * The parameter `size` (positive float, default 1) sets the polygon size
  24960. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24961. * * 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`
  24962. * * 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
  24963. * * 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)`)
  24964. * * 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
  24965. * * 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
  24966. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24967. * * If you create a double-sided mesh, you can choose what parts of 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
  24968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24969. * @param name defines the name of the mesh to create
  24970. * @param options defines the options used to create the mesh
  24971. * @param scene defines the hosting scene
  24972. * @returns a new Mesh
  24973. */
  24974. static CreatePolyhedron(name: string, options: {
  24975. type?: number;
  24976. size?: number;
  24977. sizeX?: number;
  24978. sizeY?: number;
  24979. sizeZ?: number;
  24980. custom?: any;
  24981. faceUV?: Vector4[];
  24982. faceColors?: Color4[];
  24983. updatable?: boolean;
  24984. sideOrientation?: number;
  24985. }, scene: Scene): Mesh;
  24986. /**
  24987. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24988. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24989. * * 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`)
  24990. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24991. * * 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
  24992. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24993. * * If you create a double-sided mesh, you can choose what parts of 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
  24994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24995. * @param name defines the name of the mesh
  24996. * @param options defines the options used to create the mesh
  24997. * @param scene defines the hosting scene
  24998. * @returns a new Mesh
  24999. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25000. */
  25001. static CreateIcoSphere(name: string, options: {
  25002. radius?: number;
  25003. flat?: boolean;
  25004. subdivisions?: number;
  25005. sideOrientation?: number;
  25006. updatable?: boolean;
  25007. }, scene: Scene): Mesh;
  25008. /**
  25009. * Creates a decal mesh.
  25010. * Please consider using the same method from the MeshBuilder class instead.
  25011. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25012. * @param name defines the name of the mesh
  25013. * @param sourceMesh defines the mesh receiving the decal
  25014. * @param position sets the position of the decal in world coordinates
  25015. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25016. * @param size sets the decal scaling
  25017. * @param angle sets the angle to rotate the decal
  25018. * @returns a new Mesh
  25019. */
  25020. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25021. /**
  25022. * Prepare internal position array for software CPU skinning
  25023. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25024. */
  25025. setPositionsForCPUSkinning(): Float32Array;
  25026. /**
  25027. * Prepare internal normal array for software CPU skinning
  25028. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25029. */
  25030. setNormalsForCPUSkinning(): Float32Array;
  25031. /**
  25032. * Updates the vertex buffer by applying transformation from the bones
  25033. * @param skeleton defines the skeleton to apply to current mesh
  25034. * @returns the current mesh
  25035. */
  25036. applySkeleton(skeleton: Skeleton): Mesh;
  25037. /**
  25038. * 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
  25039. * @param meshes defines the list of meshes to scan
  25040. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25041. */
  25042. static MinMax(meshes: AbstractMesh[]): {
  25043. min: Vector3;
  25044. max: Vector3;
  25045. };
  25046. /**
  25047. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25048. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25049. * @returns a vector3
  25050. */
  25051. static Center(meshesOrMinMaxVector: {
  25052. min: Vector3;
  25053. max: Vector3;
  25054. } | AbstractMesh[]): Vector3;
  25055. /**
  25056. * Merge the array of meshes into a single mesh for performance reasons.
  25057. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25058. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25059. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25060. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25061. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25062. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25063. * @returns a new mesh
  25064. */
  25065. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25066. /** @hidden */
  25067. addInstance(instance: InstancedMesh): void;
  25068. /** @hidden */
  25069. removeInstance(instance: InstancedMesh): void;
  25070. }
  25071. }
  25072. declare module "babylonjs/Cameras/camera" {
  25073. import { SmartArray } from "babylonjs/Misc/smartArray";
  25074. import { Observable } from "babylonjs/Misc/observable";
  25075. import { Nullable } from "babylonjs/types";
  25076. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25077. import { Scene } from "babylonjs/scene";
  25078. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25079. import { Node } from "babylonjs/node";
  25080. import { Mesh } from "babylonjs/Meshes/mesh";
  25081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25082. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25083. import { Viewport } from "babylonjs/Maths/math.viewport";
  25084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25085. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25086. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25087. import { Ray } from "babylonjs/Culling/ray";
  25088. /**
  25089. * This is the base class of all the camera used in the application.
  25090. * @see http://doc.babylonjs.com/features/cameras
  25091. */
  25092. export class Camera extends Node {
  25093. /** @hidden */
  25094. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25095. /**
  25096. * This is the default projection mode used by the cameras.
  25097. * It helps recreating a feeling of perspective and better appreciate depth.
  25098. * This is the best way to simulate real life cameras.
  25099. */
  25100. static readonly PERSPECTIVE_CAMERA: number;
  25101. /**
  25102. * This helps creating camera with an orthographic mode.
  25103. * 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.
  25104. */
  25105. static readonly ORTHOGRAPHIC_CAMERA: number;
  25106. /**
  25107. * This is the default FOV mode for perspective cameras.
  25108. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25109. */
  25110. static readonly FOVMODE_VERTICAL_FIXED: number;
  25111. /**
  25112. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25113. */
  25114. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25115. /**
  25116. * This specifies ther is no need for a camera rig.
  25117. * Basically only one eye is rendered corresponding to the camera.
  25118. */
  25119. static readonly RIG_MODE_NONE: number;
  25120. /**
  25121. * Simulates a camera Rig with one blue eye and one red eye.
  25122. * This can be use with 3d blue and red glasses.
  25123. */
  25124. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25125. /**
  25126. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25127. */
  25128. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25129. /**
  25130. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25131. */
  25132. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25133. /**
  25134. * Defines that both eyes of the camera will be rendered over under each other.
  25135. */
  25136. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25137. /**
  25138. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25139. */
  25140. static readonly RIG_MODE_VR: number;
  25141. /**
  25142. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25143. */
  25144. static readonly RIG_MODE_WEBVR: number;
  25145. /**
  25146. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25147. */
  25148. static readonly RIG_MODE_CUSTOM: number;
  25149. /**
  25150. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25151. */
  25152. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25153. /**
  25154. * Define the input manager associated with the camera.
  25155. */
  25156. inputs: CameraInputsManager<Camera>;
  25157. /** @hidden */
  25158. _position: Vector3;
  25159. /**
  25160. * Define the current local position of the camera in the scene
  25161. */
  25162. position: Vector3;
  25163. /**
  25164. * The vector the camera should consider as up.
  25165. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25166. */
  25167. upVector: Vector3;
  25168. /**
  25169. * Define the current limit on the left side for an orthographic camera
  25170. * In scene unit
  25171. */
  25172. orthoLeft: Nullable<number>;
  25173. /**
  25174. * Define the current limit on the right side for an orthographic camera
  25175. * In scene unit
  25176. */
  25177. orthoRight: Nullable<number>;
  25178. /**
  25179. * Define the current limit on the bottom side for an orthographic camera
  25180. * In scene unit
  25181. */
  25182. orthoBottom: Nullable<number>;
  25183. /**
  25184. * Define the current limit on the top side for an orthographic camera
  25185. * In scene unit
  25186. */
  25187. orthoTop: Nullable<number>;
  25188. /**
  25189. * Field Of View is set in Radians. (default is 0.8)
  25190. */
  25191. fov: number;
  25192. /**
  25193. * Define the minimum distance the camera can see from.
  25194. * This is important to note that the depth buffer are not infinite and the closer it starts
  25195. * the more your scene might encounter depth fighting issue.
  25196. */
  25197. minZ: number;
  25198. /**
  25199. * Define the maximum distance the camera can see to.
  25200. * This is important to note that the depth buffer are not infinite and the further it end
  25201. * the more your scene might encounter depth fighting issue.
  25202. */
  25203. maxZ: number;
  25204. /**
  25205. * Define the default inertia of the camera.
  25206. * This helps giving a smooth feeling to the camera movement.
  25207. */
  25208. inertia: number;
  25209. /**
  25210. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25211. */
  25212. mode: number;
  25213. /**
  25214. * Define wether the camera is intermediate.
  25215. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25216. */
  25217. isIntermediate: boolean;
  25218. /**
  25219. * Define the viewport of the camera.
  25220. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25221. */
  25222. viewport: Viewport;
  25223. /**
  25224. * Restricts the camera to viewing objects with the same layerMask.
  25225. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25226. */
  25227. layerMask: number;
  25228. /**
  25229. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25230. */
  25231. fovMode: number;
  25232. /**
  25233. * Rig mode of the camera.
  25234. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25235. * This is normally controlled byt the camera themselves as internal use.
  25236. */
  25237. cameraRigMode: number;
  25238. /**
  25239. * Defines the distance between both "eyes" in case of a RIG
  25240. */
  25241. interaxialDistance: number;
  25242. /**
  25243. * Defines if stereoscopic rendering is done side by side or over under.
  25244. */
  25245. isStereoscopicSideBySide: boolean;
  25246. /**
  25247. * 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
  25248. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25249. * else in the scene. (Eg. security camera)
  25250. *
  25251. * 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)
  25252. */
  25253. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25254. /**
  25255. * When set, the camera will render to this render target instead of the default canvas
  25256. *
  25257. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25258. */
  25259. outputRenderTarget: Nullable<RenderTargetTexture>;
  25260. /**
  25261. * Observable triggered when the camera view matrix has changed.
  25262. */
  25263. onViewMatrixChangedObservable: Observable<Camera>;
  25264. /**
  25265. * Observable triggered when the camera Projection matrix has changed.
  25266. */
  25267. onProjectionMatrixChangedObservable: Observable<Camera>;
  25268. /**
  25269. * Observable triggered when the inputs have been processed.
  25270. */
  25271. onAfterCheckInputsObservable: Observable<Camera>;
  25272. /**
  25273. * Observable triggered when reset has been called and applied to the camera.
  25274. */
  25275. onRestoreStateObservable: Observable<Camera>;
  25276. /** @hidden */
  25277. _cameraRigParams: any;
  25278. /** @hidden */
  25279. _rigCameras: Camera[];
  25280. /** @hidden */
  25281. _rigPostProcess: Nullable<PostProcess>;
  25282. protected _webvrViewMatrix: Matrix;
  25283. /** @hidden */
  25284. _skipRendering: boolean;
  25285. /** @hidden */
  25286. _projectionMatrix: Matrix;
  25287. /** @hidden */
  25288. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25289. /** @hidden */
  25290. _activeMeshes: SmartArray<AbstractMesh>;
  25291. protected _globalPosition: Vector3;
  25292. /** @hidden */
  25293. _computedViewMatrix: Matrix;
  25294. private _doNotComputeProjectionMatrix;
  25295. private _transformMatrix;
  25296. private _frustumPlanes;
  25297. private _refreshFrustumPlanes;
  25298. private _storedFov;
  25299. private _stateStored;
  25300. /**
  25301. * Instantiates a new camera object.
  25302. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25303. * @see http://doc.babylonjs.com/features/cameras
  25304. * @param name Defines the name of the camera in the scene
  25305. * @param position Defines the position of the camera
  25306. * @param scene Defines the scene the camera belongs too
  25307. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25308. */
  25309. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25310. /**
  25311. * Store current camera state (fov, position, etc..)
  25312. * @returns the camera
  25313. */
  25314. storeState(): Camera;
  25315. /**
  25316. * Restores the camera state values if it has been stored. You must call storeState() first
  25317. */
  25318. protected _restoreStateValues(): boolean;
  25319. /**
  25320. * Restored camera state. You must call storeState() first.
  25321. * @returns true if restored and false otherwise
  25322. */
  25323. restoreState(): boolean;
  25324. /**
  25325. * Gets the class name of the camera.
  25326. * @returns the class name
  25327. */
  25328. getClassName(): string;
  25329. /** @hidden */
  25330. readonly _isCamera: boolean;
  25331. /**
  25332. * Gets a string representation of the camera useful for debug purpose.
  25333. * @param fullDetails Defines that a more verboe level of logging is required
  25334. * @returns the string representation
  25335. */
  25336. toString(fullDetails?: boolean): string;
  25337. /**
  25338. * Gets the current world space position of the camera.
  25339. */
  25340. readonly globalPosition: Vector3;
  25341. /**
  25342. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25343. * @returns the active meshe list
  25344. */
  25345. getActiveMeshes(): SmartArray<AbstractMesh>;
  25346. /**
  25347. * Check wether a mesh is part of the current active mesh list of the camera
  25348. * @param mesh Defines the mesh to check
  25349. * @returns true if active, false otherwise
  25350. */
  25351. isActiveMesh(mesh: Mesh): boolean;
  25352. /**
  25353. * Is this camera ready to be used/rendered
  25354. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25355. * @return true if the camera is ready
  25356. */
  25357. isReady(completeCheck?: boolean): boolean;
  25358. /** @hidden */
  25359. _initCache(): void;
  25360. /** @hidden */
  25361. _updateCache(ignoreParentClass?: boolean): void;
  25362. /** @hidden */
  25363. _isSynchronized(): boolean;
  25364. /** @hidden */
  25365. _isSynchronizedViewMatrix(): boolean;
  25366. /** @hidden */
  25367. _isSynchronizedProjectionMatrix(): boolean;
  25368. /**
  25369. * Attach the input controls to a specific dom element to get the input from.
  25370. * @param element Defines the element the controls should be listened from
  25371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25372. */
  25373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25374. /**
  25375. * Detach the current controls from the specified dom element.
  25376. * @param element Defines the element to stop listening the inputs from
  25377. */
  25378. detachControl(element: HTMLElement): void;
  25379. /**
  25380. * Update the camera state according to the different inputs gathered during the frame.
  25381. */
  25382. update(): void;
  25383. /** @hidden */
  25384. _checkInputs(): void;
  25385. /** @hidden */
  25386. readonly rigCameras: Camera[];
  25387. /**
  25388. * Gets the post process used by the rig cameras
  25389. */
  25390. readonly rigPostProcess: Nullable<PostProcess>;
  25391. /**
  25392. * Internal, gets the first post proces.
  25393. * @returns the first post process to be run on this camera.
  25394. */
  25395. _getFirstPostProcess(): Nullable<PostProcess>;
  25396. private _cascadePostProcessesToRigCams;
  25397. /**
  25398. * Attach a post process to the camera.
  25399. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25400. * @param postProcess The post process to attach to the camera
  25401. * @param insertAt The position of the post process in case several of them are in use in the scene
  25402. * @returns the position the post process has been inserted at
  25403. */
  25404. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25405. /**
  25406. * Detach a post process to the camera.
  25407. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25408. * @param postProcess The post process to detach from the camera
  25409. */
  25410. detachPostProcess(postProcess: PostProcess): void;
  25411. /**
  25412. * Gets the current world matrix of the camera
  25413. */
  25414. getWorldMatrix(): Matrix;
  25415. /** @hidden */
  25416. _getViewMatrix(): Matrix;
  25417. /**
  25418. * Gets the current view matrix of the camera.
  25419. * @param force forces the camera to recompute the matrix without looking at the cached state
  25420. * @returns the view matrix
  25421. */
  25422. getViewMatrix(force?: boolean): Matrix;
  25423. /**
  25424. * Freeze the projection matrix.
  25425. * It will prevent the cache check of the camera projection compute and can speed up perf
  25426. * if no parameter of the camera are meant to change
  25427. * @param projection Defines manually a projection if necessary
  25428. */
  25429. freezeProjectionMatrix(projection?: Matrix): void;
  25430. /**
  25431. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25432. */
  25433. unfreezeProjectionMatrix(): void;
  25434. /**
  25435. * Gets the current projection matrix of the camera.
  25436. * @param force forces the camera to recompute the matrix without looking at the cached state
  25437. * @returns the projection matrix
  25438. */
  25439. getProjectionMatrix(force?: boolean): Matrix;
  25440. /**
  25441. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25442. * @returns a Matrix
  25443. */
  25444. getTransformationMatrix(): Matrix;
  25445. private _updateFrustumPlanes;
  25446. /**
  25447. * Checks if a cullable object (mesh...) is in the camera frustum
  25448. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25449. * @param target The object to check
  25450. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25451. * @returns true if the object is in frustum otherwise false
  25452. */
  25453. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25454. /**
  25455. * Checks if a cullable object (mesh...) is in the camera frustum
  25456. * Unlike isInFrustum this cheks the full bounding box
  25457. * @param target The object to check
  25458. * @returns true if the object is in frustum otherwise false
  25459. */
  25460. isCompletelyInFrustum(target: ICullable): boolean;
  25461. /**
  25462. * Gets a ray in the forward direction from the camera.
  25463. * @param length Defines the length of the ray to create
  25464. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25465. * @param origin Defines the start point of the ray which defaults to the camera position
  25466. * @returns the forward ray
  25467. */
  25468. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25469. /**
  25470. * Releases resources associated with this node.
  25471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25473. */
  25474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25475. /** @hidden */
  25476. _isLeftCamera: boolean;
  25477. /**
  25478. * Gets the left camera of a rig setup in case of Rigged Camera
  25479. */
  25480. readonly isLeftCamera: boolean;
  25481. /** @hidden */
  25482. _isRightCamera: boolean;
  25483. /**
  25484. * Gets the right camera of a rig setup in case of Rigged Camera
  25485. */
  25486. readonly isRightCamera: boolean;
  25487. /**
  25488. * Gets the left camera of a rig setup in case of Rigged Camera
  25489. */
  25490. readonly leftCamera: Nullable<FreeCamera>;
  25491. /**
  25492. * Gets the right camera of a rig setup in case of Rigged Camera
  25493. */
  25494. readonly rightCamera: Nullable<FreeCamera>;
  25495. /**
  25496. * Gets the left camera target of a rig setup in case of Rigged Camera
  25497. * @returns the target position
  25498. */
  25499. getLeftTarget(): Nullable<Vector3>;
  25500. /**
  25501. * Gets the right camera target of a rig setup in case of Rigged Camera
  25502. * @returns the target position
  25503. */
  25504. getRightTarget(): Nullable<Vector3>;
  25505. /**
  25506. * @hidden
  25507. */
  25508. setCameraRigMode(mode: number, rigParams: any): void;
  25509. /** @hidden */
  25510. static _setStereoscopicRigMode(camera: Camera): void;
  25511. /** @hidden */
  25512. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25513. /** @hidden */
  25514. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25515. /** @hidden */
  25516. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25517. /** @hidden */
  25518. _getVRProjectionMatrix(): Matrix;
  25519. protected _updateCameraRotationMatrix(): void;
  25520. protected _updateWebVRCameraRotationMatrix(): void;
  25521. /**
  25522. * This function MUST be overwritten by the different WebVR cameras available.
  25523. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25524. * @hidden
  25525. */
  25526. _getWebVRProjectionMatrix(): Matrix;
  25527. /**
  25528. * This function MUST be overwritten by the different WebVR cameras available.
  25529. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25530. * @hidden
  25531. */
  25532. _getWebVRViewMatrix(): Matrix;
  25533. /** @hidden */
  25534. setCameraRigParameter(name: string, value: any): void;
  25535. /**
  25536. * needs to be overridden by children so sub has required properties to be copied
  25537. * @hidden
  25538. */
  25539. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25540. /**
  25541. * May need to be overridden by children
  25542. * @hidden
  25543. */
  25544. _updateRigCameras(): void;
  25545. /** @hidden */
  25546. _setupInputs(): void;
  25547. /**
  25548. * Serialiaze the camera setup to a json represention
  25549. * @returns the JSON representation
  25550. */
  25551. serialize(): any;
  25552. /**
  25553. * Clones the current camera.
  25554. * @param name The cloned camera name
  25555. * @returns the cloned camera
  25556. */
  25557. clone(name: string): Camera;
  25558. /**
  25559. * Gets the direction of the camera relative to a given local axis.
  25560. * @param localAxis Defines the reference axis to provide a relative direction.
  25561. * @return the direction
  25562. */
  25563. getDirection(localAxis: Vector3): Vector3;
  25564. /**
  25565. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25566. * @param localAxis Defines the reference axis to provide a relative direction.
  25567. * @param result Defines the vector to store the result in
  25568. */
  25569. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25570. /**
  25571. * Gets a camera constructor for a given camera type
  25572. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25573. * @param name The name of the camera the result will be able to instantiate
  25574. * @param scene The scene the result will construct the camera in
  25575. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25576. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25577. * @returns a factory method to construc the camera
  25578. */
  25579. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25580. /**
  25581. * Compute the world matrix of the camera.
  25582. * @returns the camera workd matrix
  25583. */
  25584. computeWorldMatrix(): Matrix;
  25585. /**
  25586. * Parse a JSON and creates the camera from the parsed information
  25587. * @param parsedCamera The JSON to parse
  25588. * @param scene The scene to instantiate the camera in
  25589. * @returns the newly constructed camera
  25590. */
  25591. static Parse(parsedCamera: any, scene: Scene): Camera;
  25592. }
  25593. }
  25594. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25595. import { Nullable } from "babylonjs/types";
  25596. import { Scene } from "babylonjs/scene";
  25597. import { Vector4 } from "babylonjs/Maths/math.vector";
  25598. import { Mesh } from "babylonjs/Meshes/mesh";
  25599. /**
  25600. * Class containing static functions to help procedurally build meshes
  25601. */
  25602. export class DiscBuilder {
  25603. /**
  25604. * Creates a plane polygonal mesh. By default, this is a disc
  25605. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25606. * * 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
  25607. * * 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
  25608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25611. * @param name defines the name of the mesh
  25612. * @param options defines the options used to create the mesh
  25613. * @param scene defines the hosting scene
  25614. * @returns the plane polygonal mesh
  25615. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25616. */
  25617. static CreateDisc(name: string, options: {
  25618. radius?: number;
  25619. tessellation?: number;
  25620. arc?: number;
  25621. updatable?: boolean;
  25622. sideOrientation?: number;
  25623. frontUVs?: Vector4;
  25624. backUVs?: Vector4;
  25625. }, scene?: Nullable<Scene>): Mesh;
  25626. }
  25627. }
  25628. declare module "babylonjs/Particles/solidParticleSystem" {
  25629. import { Vector3 } from "babylonjs/Maths/math.vector";
  25630. import { Mesh } from "babylonjs/Meshes/mesh";
  25631. import { Scene, IDisposable } from "babylonjs/scene";
  25632. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25633. /**
  25634. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25635. *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.
  25636. * The SPS is also a particle system. It provides some methods to manage the particles.
  25637. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25638. *
  25639. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25640. */
  25641. export class SolidParticleSystem implements IDisposable {
  25642. /**
  25643. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25644. * Example : var p = SPS.particles[i];
  25645. */
  25646. particles: SolidParticle[];
  25647. /**
  25648. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25649. */
  25650. nbParticles: number;
  25651. /**
  25652. * If the particles must ever face the camera (default false). Useful for planar particles.
  25653. */
  25654. billboard: boolean;
  25655. /**
  25656. * Recompute normals when adding a shape
  25657. */
  25658. recomputeNormals: boolean;
  25659. /**
  25660. * This a counter ofr your own usage. It's not set by any SPS functions.
  25661. */
  25662. counter: number;
  25663. /**
  25664. * The SPS name. This name is also given to the underlying mesh.
  25665. */
  25666. name: string;
  25667. /**
  25668. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25669. */
  25670. mesh: Mesh;
  25671. /**
  25672. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25673. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25674. */
  25675. vars: any;
  25676. /**
  25677. * This array is populated when the SPS is set as 'pickable'.
  25678. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25679. * Each element of this array is an object `{idx: int, faceId: int}`.
  25680. * `idx` is the picked particle index in the `SPS.particles` array
  25681. * `faceId` is the picked face index counted within this particle.
  25682. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25683. */
  25684. pickedParticles: {
  25685. idx: number;
  25686. faceId: number;
  25687. }[];
  25688. /**
  25689. * This array is populated when `enableDepthSort` is set to true.
  25690. * Each element of this array is an instance of the class DepthSortedParticle.
  25691. */
  25692. depthSortedParticles: DepthSortedParticle[];
  25693. /**
  25694. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25695. * @hidden
  25696. */
  25697. _bSphereOnly: boolean;
  25698. /**
  25699. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25700. * @hidden
  25701. */
  25702. _bSphereRadiusFactor: number;
  25703. private _scene;
  25704. private _positions;
  25705. private _indices;
  25706. private _normals;
  25707. private _colors;
  25708. private _uvs;
  25709. private _indices32;
  25710. private _positions32;
  25711. private _normals32;
  25712. private _fixedNormal32;
  25713. private _colors32;
  25714. private _uvs32;
  25715. private _index;
  25716. private _updatable;
  25717. private _pickable;
  25718. private _isVisibilityBoxLocked;
  25719. private _alwaysVisible;
  25720. private _depthSort;
  25721. private _shapeCounter;
  25722. private _copy;
  25723. private _color;
  25724. private _computeParticleColor;
  25725. private _computeParticleTexture;
  25726. private _computeParticleRotation;
  25727. private _computeParticleVertex;
  25728. private _computeBoundingBox;
  25729. private _depthSortParticles;
  25730. private _camera;
  25731. private _mustUnrotateFixedNormals;
  25732. private _particlesIntersect;
  25733. private _needs32Bits;
  25734. /**
  25735. * Creates a SPS (Solid Particle System) object.
  25736. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25737. * @param scene (Scene) is the scene in which the SPS is added.
  25738. * @param options defines the options of the sps e.g.
  25739. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25740. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25741. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25742. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25743. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25744. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25745. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25746. */
  25747. constructor(name: string, scene: Scene, options?: {
  25748. updatable?: boolean;
  25749. isPickable?: boolean;
  25750. enableDepthSort?: boolean;
  25751. particleIntersection?: boolean;
  25752. boundingSphereOnly?: boolean;
  25753. bSphereRadiusFactor?: number;
  25754. });
  25755. /**
  25756. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25757. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25758. * @returns the created mesh
  25759. */
  25760. buildMesh(): Mesh;
  25761. /**
  25762. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25763. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25764. * Thus the particles generated from `digest()` have their property `position` set yet.
  25765. * @param mesh ( Mesh ) is the mesh to be digested
  25766. * @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
  25767. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25768. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25769. * @returns the current SPS
  25770. */
  25771. digest(mesh: Mesh, options?: {
  25772. facetNb?: number;
  25773. number?: number;
  25774. delta?: number;
  25775. }): SolidParticleSystem;
  25776. private _unrotateFixedNormals;
  25777. private _resetCopy;
  25778. private _meshBuilder;
  25779. private _posToShape;
  25780. private _uvsToShapeUV;
  25781. private _addParticle;
  25782. /**
  25783. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25784. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25785. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25786. * @param nb (positive integer) the number of particles to be created from this model
  25787. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25788. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25789. * @returns the number of shapes in the system
  25790. */
  25791. addShape(mesh: Mesh, nb: number, options?: {
  25792. positionFunction?: any;
  25793. vertexFunction?: any;
  25794. }): number;
  25795. private _rebuildParticle;
  25796. /**
  25797. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25798. * @returns the SPS.
  25799. */
  25800. rebuildMesh(): SolidParticleSystem;
  25801. /**
  25802. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25803. * This method calls `updateParticle()` for each particle of the SPS.
  25804. * For an animated SPS, it is usually called within the render loop.
  25805. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25806. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25807. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25808. * @returns the SPS.
  25809. */
  25810. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25811. /**
  25812. * Disposes the SPS.
  25813. */
  25814. dispose(): void;
  25815. /**
  25816. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25818. * @returns the SPS.
  25819. */
  25820. refreshVisibleSize(): SolidParticleSystem;
  25821. /**
  25822. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25823. * @param size the size (float) of the visibility box
  25824. * note : this doesn't lock the SPS mesh bounding box.
  25825. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25826. */
  25827. setVisibilityBox(size: number): void;
  25828. /**
  25829. * Gets whether the SPS as always visible or not
  25830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25831. */
  25832. /**
  25833. * Sets the SPS as always visible or not
  25834. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25835. */
  25836. isAlwaysVisible: boolean;
  25837. /**
  25838. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25839. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25840. */
  25841. /**
  25842. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25844. */
  25845. isVisibilityBoxLocked: boolean;
  25846. /**
  25847. * Tells to `setParticles()` to compute the particle rotations or not.
  25848. * Default value : true. The SPS is faster when it's set to false.
  25849. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25850. */
  25851. /**
  25852. * Gets if `setParticles()` computes the particle rotations or not.
  25853. * Default value : true. The SPS is faster when it's set to false.
  25854. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25855. */
  25856. computeParticleRotation: boolean;
  25857. /**
  25858. * Tells to `setParticles()` to compute the particle colors or not.
  25859. * Default value : true. The SPS is faster when it's set to false.
  25860. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25861. */
  25862. /**
  25863. * Gets if `setParticles()` computes the particle colors or not.
  25864. * Default value : true. The SPS is faster when it's set to false.
  25865. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25866. */
  25867. computeParticleColor: boolean;
  25868. /**
  25869. * Gets if `setParticles()` computes the particle textures or not.
  25870. * Default value : true. The SPS is faster when it's set to false.
  25871. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25872. */
  25873. computeParticleTexture: boolean;
  25874. /**
  25875. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25876. * Default value : false. The SPS is faster when it's set to false.
  25877. * Note : the particle custom vertex positions aren't stored values.
  25878. */
  25879. /**
  25880. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25881. * Default value : false. The SPS is faster when it's set to false.
  25882. * Note : the particle custom vertex positions aren't stored values.
  25883. */
  25884. computeParticleVertex: boolean;
  25885. /**
  25886. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25887. */
  25888. /**
  25889. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25890. */
  25891. computeBoundingBox: boolean;
  25892. /**
  25893. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25894. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25895. * Default : `true`
  25896. */
  25897. /**
  25898. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25899. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25900. * Default : `true`
  25901. */
  25902. depthSortParticles: boolean;
  25903. /**
  25904. * This function does nothing. It may be overwritten to set all the particle first values.
  25905. * The SPS doesn't call this function, you may have to call it by your own.
  25906. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25907. */
  25908. initParticles(): void;
  25909. /**
  25910. * This function does nothing. It may be overwritten to recycle a particle.
  25911. * The SPS doesn't call this function, you may have to call it by your own.
  25912. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25913. * @param particle The particle to recycle
  25914. * @returns the recycled particle
  25915. */
  25916. recycleParticle(particle: SolidParticle): SolidParticle;
  25917. /**
  25918. * Updates a particle : this function should be overwritten by the user.
  25919. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25920. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25921. * @example : just set a particle position or velocity and recycle conditions
  25922. * @param particle The particle to update
  25923. * @returns the updated particle
  25924. */
  25925. updateParticle(particle: SolidParticle): SolidParticle;
  25926. /**
  25927. * Updates a vertex of a particle : it can be overwritten by the user.
  25928. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25929. * @param particle the current particle
  25930. * @param vertex the current index of the current particle
  25931. * @param pt the index of the current vertex in the particle shape
  25932. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25933. * @example : just set a vertex particle position
  25934. * @returns the updated vertex
  25935. */
  25936. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25937. /**
  25938. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25939. * This does nothing and may be overwritten by the user.
  25940. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25941. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25942. * @param update the boolean update value actually passed to setParticles()
  25943. */
  25944. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25945. /**
  25946. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25947. * This will be passed three parameters.
  25948. * This does nothing and may be overwritten by the user.
  25949. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25950. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25951. * @param update the boolean update value actually passed to setParticles()
  25952. */
  25953. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25954. }
  25955. }
  25956. declare module "babylonjs/Particles/solidParticle" {
  25957. import { Nullable } from "babylonjs/types";
  25958. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25959. import { Color4 } from "babylonjs/Maths/math.color";
  25960. import { Mesh } from "babylonjs/Meshes/mesh";
  25961. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25962. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25963. import { Plane } from "babylonjs/Maths/math.plane";
  25964. /**
  25965. * Represents one particle of a solid particle system.
  25966. */
  25967. export class SolidParticle {
  25968. /**
  25969. * particle global index
  25970. */
  25971. idx: number;
  25972. /**
  25973. * The color of the particle
  25974. */
  25975. color: Nullable<Color4>;
  25976. /**
  25977. * The world space position of the particle.
  25978. */
  25979. position: Vector3;
  25980. /**
  25981. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25982. */
  25983. rotation: Vector3;
  25984. /**
  25985. * The world space rotation quaternion of the particle.
  25986. */
  25987. rotationQuaternion: Nullable<Quaternion>;
  25988. /**
  25989. * The scaling of the particle.
  25990. */
  25991. scaling: Vector3;
  25992. /**
  25993. * The uvs of the particle.
  25994. */
  25995. uvs: Vector4;
  25996. /**
  25997. * The current speed of the particle.
  25998. */
  25999. velocity: Vector3;
  26000. /**
  26001. * The pivot point in the particle local space.
  26002. */
  26003. pivot: Vector3;
  26004. /**
  26005. * Must the particle be translated from its pivot point in its local space ?
  26006. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26007. * Default : false
  26008. */
  26009. translateFromPivot: boolean;
  26010. /**
  26011. * Is the particle active or not ?
  26012. */
  26013. alive: boolean;
  26014. /**
  26015. * Is the particle visible or not ?
  26016. */
  26017. isVisible: boolean;
  26018. /**
  26019. * Index of this particle in the global "positions" array (Internal use)
  26020. * @hidden
  26021. */
  26022. _pos: number;
  26023. /**
  26024. * @hidden Index of this particle in the global "indices" array (Internal use)
  26025. */
  26026. _ind: number;
  26027. /**
  26028. * @hidden ModelShape of this particle (Internal use)
  26029. */
  26030. _model: ModelShape;
  26031. /**
  26032. * ModelShape id of this particle
  26033. */
  26034. shapeId: number;
  26035. /**
  26036. * Index of the particle in its shape id (Internal use)
  26037. */
  26038. idxInShape: number;
  26039. /**
  26040. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26041. */
  26042. _modelBoundingInfo: BoundingInfo;
  26043. /**
  26044. * @hidden Particle BoundingInfo object (Internal use)
  26045. */
  26046. _boundingInfo: BoundingInfo;
  26047. /**
  26048. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26049. */
  26050. _sps: SolidParticleSystem;
  26051. /**
  26052. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26053. */
  26054. _stillInvisible: boolean;
  26055. /**
  26056. * @hidden Last computed particle rotation matrix
  26057. */
  26058. _rotationMatrix: number[];
  26059. /**
  26060. * Parent particle Id, if any.
  26061. * Default null.
  26062. */
  26063. parentId: Nullable<number>;
  26064. /**
  26065. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26066. * The possible values are :
  26067. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26068. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26070. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26071. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26072. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26073. * */
  26074. cullingStrategy: number;
  26075. /**
  26076. * @hidden Internal global position in the SPS.
  26077. */
  26078. _globalPosition: Vector3;
  26079. /**
  26080. * Creates a Solid Particle object.
  26081. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26082. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26083. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26084. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26085. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26086. * @param shapeId (integer) is the model shape identifier in the SPS.
  26087. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26088. * @param sps defines the sps it is associated to
  26089. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26090. */
  26091. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26092. /**
  26093. * Legacy support, changed scale to scaling
  26094. */
  26095. /**
  26096. * Legacy support, changed scale to scaling
  26097. */
  26098. scale: Vector3;
  26099. /**
  26100. * Legacy support, changed quaternion to rotationQuaternion
  26101. */
  26102. /**
  26103. * Legacy support, changed quaternion to rotationQuaternion
  26104. */
  26105. quaternion: Nullable<Quaternion>;
  26106. /**
  26107. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26108. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26109. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26110. * @returns true if it intersects
  26111. */
  26112. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26113. /**
  26114. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26115. * A particle is in the frustum if its bounding box intersects the frustum
  26116. * @param frustumPlanes defines the frustum to test
  26117. * @returns true if the particle is in the frustum planes
  26118. */
  26119. isInFrustum(frustumPlanes: Plane[]): boolean;
  26120. /**
  26121. * get the rotation matrix of the particle
  26122. * @hidden
  26123. */
  26124. getRotationMatrix(m: Matrix): void;
  26125. }
  26126. /**
  26127. * Represents the shape of the model used by one particle of a solid particle system.
  26128. * SPS internal tool, don't use it manually.
  26129. */
  26130. export class ModelShape {
  26131. /**
  26132. * The shape id
  26133. * @hidden
  26134. */
  26135. shapeID: number;
  26136. /**
  26137. * flat array of model positions (internal use)
  26138. * @hidden
  26139. */
  26140. _shape: Vector3[];
  26141. /**
  26142. * flat array of model UVs (internal use)
  26143. * @hidden
  26144. */
  26145. _shapeUV: number[];
  26146. /**
  26147. * length of the shape in the model indices array (internal use)
  26148. * @hidden
  26149. */
  26150. _indicesLength: number;
  26151. /**
  26152. * Custom position function (internal use)
  26153. * @hidden
  26154. */
  26155. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26156. /**
  26157. * Custom vertex function (internal use)
  26158. * @hidden
  26159. */
  26160. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26161. /**
  26162. * 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.
  26163. * SPS internal tool, don't use it manually.
  26164. * @hidden
  26165. */
  26166. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26167. }
  26168. /**
  26169. * Represents a Depth Sorted Particle in the solid particle system.
  26170. */
  26171. export class DepthSortedParticle {
  26172. /**
  26173. * Index of the particle in the "indices" array
  26174. */
  26175. ind: number;
  26176. /**
  26177. * Length of the particle shape in the "indices" array
  26178. */
  26179. indicesLength: number;
  26180. /**
  26181. * Squared distance from the particle to the camera
  26182. */
  26183. sqDistance: number;
  26184. }
  26185. }
  26186. declare module "babylonjs/Collisions/meshCollisionData" {
  26187. import { Collider } from "babylonjs/Collisions/collider";
  26188. import { Vector3 } from "babylonjs/Maths/math.vector";
  26189. import { Nullable } from "babylonjs/types";
  26190. import { Observer } from "babylonjs/Misc/observable";
  26191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26192. /**
  26193. * @hidden
  26194. */
  26195. export class _MeshCollisionData {
  26196. _checkCollisions: boolean;
  26197. _collisionMask: number;
  26198. _collisionGroup: number;
  26199. _collider: Nullable<Collider>;
  26200. _oldPositionForCollisions: Vector3;
  26201. _diffPositionForCollisions: Vector3;
  26202. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26203. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26204. }
  26205. }
  26206. declare module "babylonjs/Meshes/abstractMesh" {
  26207. import { Observable } from "babylonjs/Misc/observable";
  26208. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26209. import { Camera } from "babylonjs/Cameras/camera";
  26210. import { Scene, IDisposable } from "babylonjs/scene";
  26211. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26212. import { Node } from "babylonjs/node";
  26213. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26216. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26217. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26218. import { Material } from "babylonjs/Materials/material";
  26219. import { Light } from "babylonjs/Lights/light";
  26220. import { Skeleton } from "babylonjs/Bones/skeleton";
  26221. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26222. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26223. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26224. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26225. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26226. import { Plane } from "babylonjs/Maths/math.plane";
  26227. import { Ray } from "babylonjs/Culling/ray";
  26228. import { Collider } from "babylonjs/Collisions/collider";
  26229. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26230. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26231. /** @hidden */
  26232. class _FacetDataStorage {
  26233. facetPositions: Vector3[];
  26234. facetNormals: Vector3[];
  26235. facetPartitioning: number[][];
  26236. facetNb: number;
  26237. partitioningSubdivisions: number;
  26238. partitioningBBoxRatio: number;
  26239. facetDataEnabled: boolean;
  26240. facetParameters: any;
  26241. bbSize: Vector3;
  26242. subDiv: {
  26243. max: number;
  26244. X: number;
  26245. Y: number;
  26246. Z: number;
  26247. };
  26248. facetDepthSort: boolean;
  26249. facetDepthSortEnabled: boolean;
  26250. depthSortedIndices: IndicesArray;
  26251. depthSortedFacets: {
  26252. ind: number;
  26253. sqDistance: number;
  26254. }[];
  26255. facetDepthSortFunction: (f1: {
  26256. ind: number;
  26257. sqDistance: number;
  26258. }, f2: {
  26259. ind: number;
  26260. sqDistance: number;
  26261. }) => number;
  26262. facetDepthSortFrom: Vector3;
  26263. facetDepthSortOrigin: Vector3;
  26264. invertedMatrix: Matrix;
  26265. }
  26266. /**
  26267. * @hidden
  26268. **/
  26269. class _InternalAbstractMeshDataInfo {
  26270. _hasVertexAlpha: boolean;
  26271. _useVertexColors: boolean;
  26272. _numBoneInfluencers: number;
  26273. _applyFog: boolean;
  26274. _receiveShadows: boolean;
  26275. _facetData: _FacetDataStorage;
  26276. _visibility: number;
  26277. _skeleton: Nullable<Skeleton>;
  26278. _layerMask: number;
  26279. _computeBonesUsingShaders: boolean;
  26280. _isActive: boolean;
  26281. _onlyForInstances: boolean;
  26282. _isActiveIntermediate: boolean;
  26283. _onlyForInstancesIntermediate: boolean;
  26284. }
  26285. /**
  26286. * Class used to store all common mesh properties
  26287. */
  26288. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26289. /** No occlusion */
  26290. static OCCLUSION_TYPE_NONE: number;
  26291. /** Occlusion set to optimisitic */
  26292. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26293. /** Occlusion set to strict */
  26294. static OCCLUSION_TYPE_STRICT: number;
  26295. /** Use an accurante occlusion algorithm */
  26296. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26297. /** Use a conservative occlusion algorithm */
  26298. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26299. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26300. * Test order :
  26301. * Is the bounding sphere outside the frustum ?
  26302. * If not, are the bounding box vertices outside the frustum ?
  26303. * It not, then the cullable object is in the frustum.
  26304. */
  26305. static readonly CULLINGSTRATEGY_STANDARD: number;
  26306. /** Culling strategy : Bounding Sphere Only.
  26307. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26308. * It's also less accurate than the standard because some not visible objects can still be selected.
  26309. * Test : is the bounding sphere outside the frustum ?
  26310. * If not, then the cullable object is in the frustum.
  26311. */
  26312. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26313. /** Culling strategy : Optimistic Inclusion.
  26314. * This in an inclusion test first, then the standard exclusion test.
  26315. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26316. * 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.
  26317. * Anyway, it's as accurate as the standard strategy.
  26318. * Test :
  26319. * Is the cullable object bounding sphere center in the frustum ?
  26320. * If not, apply the default culling strategy.
  26321. */
  26322. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26323. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26324. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26325. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26326. * 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.
  26327. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26328. * Test :
  26329. * Is the cullable object bounding sphere center in the frustum ?
  26330. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26331. */
  26332. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26333. /**
  26334. * No billboard
  26335. */
  26336. static readonly BILLBOARDMODE_NONE: number;
  26337. /** Billboard on X axis */
  26338. static readonly BILLBOARDMODE_X: number;
  26339. /** Billboard on Y axis */
  26340. static readonly BILLBOARDMODE_Y: number;
  26341. /** Billboard on Z axis */
  26342. static readonly BILLBOARDMODE_Z: number;
  26343. /** Billboard on all axes */
  26344. static readonly BILLBOARDMODE_ALL: number;
  26345. /** Billboard on using position instead of orientation */
  26346. static readonly BILLBOARDMODE_USE_POSITION: number;
  26347. /** @hidden */
  26348. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26349. /**
  26350. * The culling strategy to use to check whether the mesh must be rendered or not.
  26351. * This value can be changed at any time and will be used on the next render mesh selection.
  26352. * The possible values are :
  26353. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26354. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26356. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26357. * Please read each static variable documentation to get details about the culling process.
  26358. * */
  26359. cullingStrategy: number;
  26360. /**
  26361. * Gets the number of facets in the mesh
  26362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26363. */
  26364. readonly facetNb: number;
  26365. /**
  26366. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26368. */
  26369. partitioningSubdivisions: number;
  26370. /**
  26371. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26372. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26374. */
  26375. partitioningBBoxRatio: number;
  26376. /**
  26377. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26378. * Works only for updatable meshes.
  26379. * Doesn't work with multi-materials
  26380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26381. */
  26382. mustDepthSortFacets: boolean;
  26383. /**
  26384. * The location (Vector3) where the facet depth sort must be computed from.
  26385. * By default, the active camera position.
  26386. * Used only when facet depth sort is enabled
  26387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26388. */
  26389. facetDepthSortFrom: Vector3;
  26390. /**
  26391. * gets a boolean indicating if facetData is enabled
  26392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26393. */
  26394. readonly isFacetDataEnabled: boolean;
  26395. /** @hidden */
  26396. _updateNonUniformScalingState(value: boolean): boolean;
  26397. /**
  26398. * An event triggered when this mesh collides with another one
  26399. */
  26400. onCollideObservable: Observable<AbstractMesh>;
  26401. /** Set a function to call when this mesh collides with another one */
  26402. onCollide: () => void;
  26403. /**
  26404. * An event triggered when the collision's position changes
  26405. */
  26406. onCollisionPositionChangeObservable: Observable<Vector3>;
  26407. /** Set a function to call when the collision's position changes */
  26408. onCollisionPositionChange: () => void;
  26409. /**
  26410. * An event triggered when material is changed
  26411. */
  26412. onMaterialChangedObservable: Observable<AbstractMesh>;
  26413. /**
  26414. * Gets or sets the orientation for POV movement & rotation
  26415. */
  26416. definedFacingForward: boolean;
  26417. /** @hidden */
  26418. _occlusionQuery: Nullable<WebGLQuery>;
  26419. /** @hidden */
  26420. _renderingGroup: Nullable<RenderingGroup>;
  26421. /**
  26422. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26423. */
  26424. /**
  26425. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26426. */
  26427. visibility: number;
  26428. /** Gets or sets the alpha index used to sort transparent meshes
  26429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26430. */
  26431. alphaIndex: number;
  26432. /**
  26433. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26434. */
  26435. isVisible: boolean;
  26436. /**
  26437. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26438. */
  26439. isPickable: boolean;
  26440. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26441. showSubMeshesBoundingBox: boolean;
  26442. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26443. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26444. */
  26445. isBlocker: boolean;
  26446. /**
  26447. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26448. */
  26449. enablePointerMoveEvents: boolean;
  26450. /**
  26451. * Specifies the rendering group id for this mesh (0 by default)
  26452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26453. */
  26454. renderingGroupId: number;
  26455. private _material;
  26456. /** Gets or sets current material */
  26457. material: Nullable<Material>;
  26458. /**
  26459. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26460. * @see http://doc.babylonjs.com/babylon101/shadows
  26461. */
  26462. receiveShadows: boolean;
  26463. /** Defines color to use when rendering outline */
  26464. outlineColor: Color3;
  26465. /** Define width to use when rendering outline */
  26466. outlineWidth: number;
  26467. /** Defines color to use when rendering overlay */
  26468. overlayColor: Color3;
  26469. /** Defines alpha to use when rendering overlay */
  26470. overlayAlpha: number;
  26471. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26472. hasVertexAlpha: boolean;
  26473. /** 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) */
  26474. useVertexColors: boolean;
  26475. /**
  26476. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26477. */
  26478. computeBonesUsingShaders: boolean;
  26479. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26480. numBoneInfluencers: number;
  26481. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26482. applyFog: boolean;
  26483. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26484. useOctreeForRenderingSelection: boolean;
  26485. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26486. useOctreeForPicking: boolean;
  26487. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26488. useOctreeForCollisions: boolean;
  26489. /**
  26490. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26491. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26492. */
  26493. layerMask: number;
  26494. /**
  26495. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26496. */
  26497. alwaysSelectAsActiveMesh: boolean;
  26498. /**
  26499. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26500. */
  26501. doNotSyncBoundingInfo: boolean;
  26502. /**
  26503. * Gets or sets the current action manager
  26504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26505. */
  26506. actionManager: Nullable<AbstractActionManager>;
  26507. private _meshCollisionData;
  26508. /**
  26509. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26511. */
  26512. ellipsoid: Vector3;
  26513. /**
  26514. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26516. */
  26517. ellipsoidOffset: Vector3;
  26518. /**
  26519. * Gets or sets a collision mask used to mask collisions (default is -1).
  26520. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26521. */
  26522. collisionMask: number;
  26523. /**
  26524. * Gets or sets the current collision group mask (-1 by default).
  26525. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26526. */
  26527. collisionGroup: number;
  26528. /**
  26529. * Defines edge width used when edgesRenderer is enabled
  26530. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26531. */
  26532. edgesWidth: number;
  26533. /**
  26534. * Defines edge color used when edgesRenderer is enabled
  26535. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26536. */
  26537. edgesColor: Color4;
  26538. /** @hidden */
  26539. _edgesRenderer: Nullable<IEdgesRenderer>;
  26540. /** @hidden */
  26541. _masterMesh: Nullable<AbstractMesh>;
  26542. /** @hidden */
  26543. _boundingInfo: Nullable<BoundingInfo>;
  26544. /** @hidden */
  26545. _renderId: number;
  26546. /**
  26547. * Gets or sets the list of subMeshes
  26548. * @see http://doc.babylonjs.com/how_to/multi_materials
  26549. */
  26550. subMeshes: SubMesh[];
  26551. /** @hidden */
  26552. _intersectionsInProgress: AbstractMesh[];
  26553. /** @hidden */
  26554. _unIndexed: boolean;
  26555. /** @hidden */
  26556. _lightSources: Light[];
  26557. /** Gets the list of lights affecting that mesh */
  26558. readonly lightSources: Light[];
  26559. /** @hidden */
  26560. readonly _positions: Nullable<Vector3[]>;
  26561. /** @hidden */
  26562. _waitingData: {
  26563. lods: Nullable<any>;
  26564. actions: Nullable<any>;
  26565. freezeWorldMatrix: Nullable<boolean>;
  26566. };
  26567. /** @hidden */
  26568. _bonesTransformMatrices: Nullable<Float32Array>;
  26569. /** @hidden */
  26570. _transformMatrixTexture: Nullable<RawTexture>;
  26571. /**
  26572. * Gets or sets a skeleton to apply skining transformations
  26573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26574. */
  26575. skeleton: Nullable<Skeleton>;
  26576. /**
  26577. * An event triggered when the mesh is rebuilt.
  26578. */
  26579. onRebuildObservable: Observable<AbstractMesh>;
  26580. /**
  26581. * Creates a new AbstractMesh
  26582. * @param name defines the name of the mesh
  26583. * @param scene defines the hosting scene
  26584. */
  26585. constructor(name: string, scene?: Nullable<Scene>);
  26586. /**
  26587. * Returns the string "AbstractMesh"
  26588. * @returns "AbstractMesh"
  26589. */
  26590. getClassName(): string;
  26591. /**
  26592. * Gets a string representation of the current mesh
  26593. * @param fullDetails defines a boolean indicating if full details must be included
  26594. * @returns a string representation of the current mesh
  26595. */
  26596. toString(fullDetails?: boolean): string;
  26597. /**
  26598. * @hidden
  26599. */
  26600. protected _getEffectiveParent(): Nullable<Node>;
  26601. /** @hidden */
  26602. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26603. /** @hidden */
  26604. _rebuild(): void;
  26605. /** @hidden */
  26606. _resyncLightSources(): void;
  26607. /** @hidden */
  26608. _resyncLighSource(light: Light): void;
  26609. /** @hidden */
  26610. _unBindEffect(): void;
  26611. /** @hidden */
  26612. _removeLightSource(light: Light): void;
  26613. private _markSubMeshesAsDirty;
  26614. /** @hidden */
  26615. _markSubMeshesAsLightDirty(): void;
  26616. /** @hidden */
  26617. _markSubMeshesAsAttributesDirty(): void;
  26618. /** @hidden */
  26619. _markSubMeshesAsMiscDirty(): void;
  26620. /**
  26621. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26622. */
  26623. scaling: Vector3;
  26624. /**
  26625. * Returns true if the mesh is blocked. Implemented by child classes
  26626. */
  26627. readonly isBlocked: boolean;
  26628. /**
  26629. * Returns the mesh itself by default. Implemented by child classes
  26630. * @param camera defines the camera to use to pick the right LOD level
  26631. * @returns the currentAbstractMesh
  26632. */
  26633. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26634. /**
  26635. * Returns 0 by default. Implemented by child classes
  26636. * @returns an integer
  26637. */
  26638. getTotalVertices(): number;
  26639. /**
  26640. * Returns a positive integer : the total number of indices in this mesh geometry.
  26641. * @returns the numner of indices or zero if the mesh has no geometry.
  26642. */
  26643. getTotalIndices(): number;
  26644. /**
  26645. * Returns null by default. Implemented by child classes
  26646. * @returns null
  26647. */
  26648. getIndices(): Nullable<IndicesArray>;
  26649. /**
  26650. * Returns the array of the requested vertex data kind. Implemented by child classes
  26651. * @param kind defines the vertex data kind to use
  26652. * @returns null
  26653. */
  26654. getVerticesData(kind: string): Nullable<FloatArray>;
  26655. /**
  26656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26658. * Note that a new underlying VertexBuffer object is created each call.
  26659. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26660. * @param kind defines vertex data kind:
  26661. * * VertexBuffer.PositionKind
  26662. * * VertexBuffer.UVKind
  26663. * * VertexBuffer.UV2Kind
  26664. * * VertexBuffer.UV3Kind
  26665. * * VertexBuffer.UV4Kind
  26666. * * VertexBuffer.UV5Kind
  26667. * * VertexBuffer.UV6Kind
  26668. * * VertexBuffer.ColorKind
  26669. * * VertexBuffer.MatricesIndicesKind
  26670. * * VertexBuffer.MatricesIndicesExtraKind
  26671. * * VertexBuffer.MatricesWeightsKind
  26672. * * VertexBuffer.MatricesWeightsExtraKind
  26673. * @param data defines the data source
  26674. * @param updatable defines if the data must be flagged as updatable (or static)
  26675. * @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
  26676. * @returns the current mesh
  26677. */
  26678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26679. /**
  26680. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26681. * If the mesh has no geometry, it is simply returned as it is.
  26682. * @param kind defines vertex data kind:
  26683. * * VertexBuffer.PositionKind
  26684. * * VertexBuffer.UVKind
  26685. * * VertexBuffer.UV2Kind
  26686. * * VertexBuffer.UV3Kind
  26687. * * VertexBuffer.UV4Kind
  26688. * * VertexBuffer.UV5Kind
  26689. * * VertexBuffer.UV6Kind
  26690. * * VertexBuffer.ColorKind
  26691. * * VertexBuffer.MatricesIndicesKind
  26692. * * VertexBuffer.MatricesIndicesExtraKind
  26693. * * VertexBuffer.MatricesWeightsKind
  26694. * * VertexBuffer.MatricesWeightsExtraKind
  26695. * @param data defines the data source
  26696. * @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
  26697. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26698. * @returns the current mesh
  26699. */
  26700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26701. /**
  26702. * Sets the mesh indices,
  26703. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26704. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26705. * @param totalVertices Defines the total number of vertices
  26706. * @returns the current mesh
  26707. */
  26708. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26709. /**
  26710. * Gets a boolean indicating if specific vertex data is present
  26711. * @param kind defines the vertex data kind to use
  26712. * @returns true is data kind is present
  26713. */
  26714. isVerticesDataPresent(kind: string): boolean;
  26715. /**
  26716. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26717. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26718. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26719. * @returns a BoundingInfo
  26720. */
  26721. getBoundingInfo(): BoundingInfo;
  26722. /**
  26723. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26724. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26725. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26726. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26727. * @returns the current mesh
  26728. */
  26729. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26730. /**
  26731. * Overwrite the current bounding info
  26732. * @param boundingInfo defines the new bounding info
  26733. * @returns the current mesh
  26734. */
  26735. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26736. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26737. readonly useBones: boolean;
  26738. /** @hidden */
  26739. _preActivate(): void;
  26740. /** @hidden */
  26741. _preActivateForIntermediateRendering(renderId: number): void;
  26742. /** @hidden */
  26743. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26744. /** @hidden */
  26745. _postActivate(): void;
  26746. /** @hidden */
  26747. _freeze(): void;
  26748. /** @hidden */
  26749. _unFreeze(): void;
  26750. /**
  26751. * Gets the current world matrix
  26752. * @returns a Matrix
  26753. */
  26754. getWorldMatrix(): Matrix;
  26755. /** @hidden */
  26756. _getWorldMatrixDeterminant(): number;
  26757. /**
  26758. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26759. */
  26760. readonly isAnInstance: boolean;
  26761. /**
  26762. * Gets a boolean indicating if this mesh has instances
  26763. */
  26764. readonly hasInstances: boolean;
  26765. /**
  26766. * Perform relative position change from the point of view of behind the front of the mesh.
  26767. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26768. * Supports definition of mesh facing forward or backward
  26769. * @param amountRight defines the distance on the right axis
  26770. * @param amountUp defines the distance on the up axis
  26771. * @param amountForward defines the distance on the forward axis
  26772. * @returns the current mesh
  26773. */
  26774. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26775. /**
  26776. * Calculate relative position change from the point of view of behind the front of the mesh.
  26777. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26778. * Supports definition of mesh facing forward or backward
  26779. * @param amountRight defines the distance on the right axis
  26780. * @param amountUp defines the distance on the up axis
  26781. * @param amountForward defines the distance on the forward axis
  26782. * @returns the new displacement vector
  26783. */
  26784. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26785. /**
  26786. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26787. * Supports definition of mesh facing forward or backward
  26788. * @param flipBack defines the flip
  26789. * @param twirlClockwise defines the twirl
  26790. * @param tiltRight defines the tilt
  26791. * @returns the current mesh
  26792. */
  26793. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26794. /**
  26795. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26796. * Supports definition of mesh facing forward or backward.
  26797. * @param flipBack defines the flip
  26798. * @param twirlClockwise defines the twirl
  26799. * @param tiltRight defines the tilt
  26800. * @returns the new rotation vector
  26801. */
  26802. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26803. /**
  26804. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26805. * This means the mesh underlying bounding box and sphere are recomputed.
  26806. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26807. * @returns the current mesh
  26808. */
  26809. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26810. /** @hidden */
  26811. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26812. /** @hidden */
  26813. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26814. /** @hidden */
  26815. _updateBoundingInfo(): AbstractMesh;
  26816. /** @hidden */
  26817. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26818. /** @hidden */
  26819. protected _afterComputeWorldMatrix(): void;
  26820. /** @hidden */
  26821. readonly _effectiveMesh: AbstractMesh;
  26822. /**
  26823. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26824. * A mesh is in the frustum if its bounding box intersects the frustum
  26825. * @param frustumPlanes defines the frustum to test
  26826. * @returns true if the mesh is in the frustum planes
  26827. */
  26828. isInFrustum(frustumPlanes: Plane[]): boolean;
  26829. /**
  26830. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26831. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26832. * @param frustumPlanes defines the frustum to test
  26833. * @returns true if the mesh is completely in the frustum planes
  26834. */
  26835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26836. /**
  26837. * True if the mesh intersects another mesh or a SolidParticle object
  26838. * @param mesh defines a target mesh or SolidParticle to test
  26839. * @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)
  26840. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26841. * @returns true if there is an intersection
  26842. */
  26843. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26844. /**
  26845. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26846. * @param point defines the point to test
  26847. * @returns true if there is an intersection
  26848. */
  26849. intersectsPoint(point: Vector3): boolean;
  26850. /**
  26851. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26853. */
  26854. checkCollisions: boolean;
  26855. /**
  26856. * Gets Collider object used to compute collisions (not physics)
  26857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26858. */
  26859. readonly collider: Nullable<Collider>;
  26860. /**
  26861. * Move the mesh using collision engine
  26862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26863. * @param displacement defines the requested displacement vector
  26864. * @returns the current mesh
  26865. */
  26866. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26867. private _onCollisionPositionChange;
  26868. /** @hidden */
  26869. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26870. /** @hidden */
  26871. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26872. /** @hidden */
  26873. _checkCollision(collider: Collider): AbstractMesh;
  26874. /** @hidden */
  26875. _generatePointsArray(): boolean;
  26876. /**
  26877. * Checks if the passed Ray intersects with the mesh
  26878. * @param ray defines the ray to use
  26879. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26881. * @returns the picking info
  26882. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26883. */
  26884. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26885. /**
  26886. * Clones the current mesh
  26887. * @param name defines the mesh name
  26888. * @param newParent defines the new mesh parent
  26889. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26890. * @returns the new mesh
  26891. */
  26892. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26893. /**
  26894. * Disposes all the submeshes of the current meshnp
  26895. * @returns the current mesh
  26896. */
  26897. releaseSubMeshes(): AbstractMesh;
  26898. /**
  26899. * Releases resources associated with this abstract mesh.
  26900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26902. */
  26903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26904. /**
  26905. * Adds the passed mesh as a child to the current mesh
  26906. * @param mesh defines the child mesh
  26907. * @returns the current mesh
  26908. */
  26909. addChild(mesh: AbstractMesh): AbstractMesh;
  26910. /**
  26911. * Removes the passed mesh from the current mesh children list
  26912. * @param mesh defines the child mesh
  26913. * @returns the current mesh
  26914. */
  26915. removeChild(mesh: AbstractMesh): AbstractMesh;
  26916. /** @hidden */
  26917. private _initFacetData;
  26918. /**
  26919. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26920. * This method can be called within the render loop.
  26921. * 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
  26922. * @returns the current mesh
  26923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26924. */
  26925. updateFacetData(): AbstractMesh;
  26926. /**
  26927. * Returns the facetLocalNormals array.
  26928. * The normals are expressed in the mesh local spac
  26929. * @returns an array of Vector3
  26930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26931. */
  26932. getFacetLocalNormals(): Vector3[];
  26933. /**
  26934. * Returns the facetLocalPositions array.
  26935. * The facet positions are expressed in the mesh local space
  26936. * @returns an array of Vector3
  26937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26938. */
  26939. getFacetLocalPositions(): Vector3[];
  26940. /**
  26941. * Returns the facetLocalPartioning array
  26942. * @returns an array of array of numbers
  26943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26944. */
  26945. getFacetLocalPartitioning(): number[][];
  26946. /**
  26947. * Returns the i-th facet position in the world system.
  26948. * This method allocates a new Vector3 per call
  26949. * @param i defines the facet index
  26950. * @returns a new Vector3
  26951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26952. */
  26953. getFacetPosition(i: number): Vector3;
  26954. /**
  26955. * Sets the reference Vector3 with the i-th facet position in the world system
  26956. * @param i defines the facet index
  26957. * @param ref defines the target vector
  26958. * @returns the current mesh
  26959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26960. */
  26961. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26962. /**
  26963. * Returns the i-th facet normal in the world system.
  26964. * This method allocates a new Vector3 per call
  26965. * @param i defines the facet index
  26966. * @returns a new Vector3
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26968. */
  26969. getFacetNormal(i: number): Vector3;
  26970. /**
  26971. * Sets the reference Vector3 with the i-th facet normal in the world system
  26972. * @param i defines the facet index
  26973. * @param ref defines the target vector
  26974. * @returns the current mesh
  26975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26976. */
  26977. getFacetNormalToRef(i: number, ref: Vector3): this;
  26978. /**
  26979. * 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)
  26980. * @param x defines x coordinate
  26981. * @param y defines y coordinate
  26982. * @param z defines z coordinate
  26983. * @returns the array of facet indexes
  26984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26985. */
  26986. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26987. /**
  26988. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26989. * @param projected sets as the (x,y,z) world projection on the facet
  26990. * @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
  26991. * @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
  26992. * @param x defines x coordinate
  26993. * @param y defines y coordinate
  26994. * @param z defines z coordinate
  26995. * @returns the face index if found (or null instead)
  26996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26997. */
  26998. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26999. /**
  27000. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27001. * @param projected sets as the (x,y,z) local projection on the facet
  27002. * @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
  27003. * @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
  27004. * @param x defines x coordinate
  27005. * @param y defines y coordinate
  27006. * @param z defines z coordinate
  27007. * @returns the face index if found (or null instead)
  27008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27009. */
  27010. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27011. /**
  27012. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27013. * @returns the parameters
  27014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27015. */
  27016. getFacetDataParameters(): any;
  27017. /**
  27018. * Disables the feature FacetData and frees the related memory
  27019. * @returns the current mesh
  27020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27021. */
  27022. disableFacetData(): AbstractMesh;
  27023. /**
  27024. * Updates the AbstractMesh indices array
  27025. * @param indices defines the data source
  27026. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27027. * @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)
  27028. * @returns the current mesh
  27029. */
  27030. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27031. /**
  27032. * Creates new normals data for the mesh
  27033. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27034. * @returns the current mesh
  27035. */
  27036. createNormals(updatable: boolean): AbstractMesh;
  27037. /**
  27038. * Align the mesh with a normal
  27039. * @param normal defines the normal to use
  27040. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27041. * @returns the current mesh
  27042. */
  27043. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27044. /** @hidden */
  27045. _checkOcclusionQuery(): boolean;
  27046. /**
  27047. * Disables the mesh edge rendering mode
  27048. * @returns the currentAbstractMesh
  27049. */
  27050. disableEdgesRendering(): AbstractMesh;
  27051. /**
  27052. * Enables the edge rendering mode on the mesh.
  27053. * This mode makes the mesh edges visible
  27054. * @param epsilon defines the maximal distance between two angles to detect a face
  27055. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27056. * @returns the currentAbstractMesh
  27057. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27058. */
  27059. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27060. }
  27061. }
  27062. declare module "babylonjs/Actions/actionEvent" {
  27063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27064. import { Nullable } from "babylonjs/types";
  27065. import { Sprite } from "babylonjs/Sprites/sprite";
  27066. import { Scene } from "babylonjs/scene";
  27067. import { Vector2 } from "babylonjs/Maths/math.vector";
  27068. /**
  27069. * Interface used to define ActionEvent
  27070. */
  27071. export interface IActionEvent {
  27072. /** The mesh or sprite that triggered the action */
  27073. source: any;
  27074. /** The X mouse cursor position at the time of the event */
  27075. pointerX: number;
  27076. /** The Y mouse cursor position at the time of the event */
  27077. pointerY: number;
  27078. /** The mesh that is currently pointed at (can be null) */
  27079. meshUnderPointer: Nullable<AbstractMesh>;
  27080. /** the original (browser) event that triggered the ActionEvent */
  27081. sourceEvent?: any;
  27082. /** additional data for the event */
  27083. additionalData?: any;
  27084. }
  27085. /**
  27086. * ActionEvent is the event being sent when an action is triggered.
  27087. */
  27088. export class ActionEvent implements IActionEvent {
  27089. /** The mesh or sprite that triggered the action */
  27090. source: any;
  27091. /** The X mouse cursor position at the time of the event */
  27092. pointerX: number;
  27093. /** The Y mouse cursor position at the time of the event */
  27094. pointerY: number;
  27095. /** The mesh that is currently pointed at (can be null) */
  27096. meshUnderPointer: Nullable<AbstractMesh>;
  27097. /** the original (browser) event that triggered the ActionEvent */
  27098. sourceEvent?: any;
  27099. /** additional data for the event */
  27100. additionalData?: any;
  27101. /**
  27102. * Creates a new ActionEvent
  27103. * @param source The mesh or sprite that triggered the action
  27104. * @param pointerX The X mouse cursor position at the time of the event
  27105. * @param pointerY The Y mouse cursor position at the time of the event
  27106. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27107. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27108. * @param additionalData additional data for the event
  27109. */
  27110. constructor(
  27111. /** The mesh or sprite that triggered the action */
  27112. source: any,
  27113. /** The X mouse cursor position at the time of the event */
  27114. pointerX: number,
  27115. /** The Y mouse cursor position at the time of the event */
  27116. pointerY: number,
  27117. /** The mesh that is currently pointed at (can be null) */
  27118. meshUnderPointer: Nullable<AbstractMesh>,
  27119. /** the original (browser) event that triggered the ActionEvent */
  27120. sourceEvent?: any,
  27121. /** additional data for the event */
  27122. additionalData?: any);
  27123. /**
  27124. * Helper function to auto-create an ActionEvent from a source mesh.
  27125. * @param source The source mesh that triggered the event
  27126. * @param evt The original (browser) event
  27127. * @param additionalData additional data for the event
  27128. * @returns the new ActionEvent
  27129. */
  27130. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27131. /**
  27132. * Helper function to auto-create an ActionEvent from a source sprite
  27133. * @param source The source sprite that triggered the event
  27134. * @param scene Scene associated with the sprite
  27135. * @param evt The original (browser) event
  27136. * @param additionalData additional data for the event
  27137. * @returns the new ActionEvent
  27138. */
  27139. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27140. /**
  27141. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27142. * @param scene the scene where the event occurred
  27143. * @param evt The original (browser) event
  27144. * @returns the new ActionEvent
  27145. */
  27146. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27147. /**
  27148. * Helper function to auto-create an ActionEvent from a primitive
  27149. * @param prim defines the target primitive
  27150. * @param pointerPos defines the pointer position
  27151. * @param evt The original (browser) event
  27152. * @param additionalData additional data for the event
  27153. * @returns the new ActionEvent
  27154. */
  27155. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27156. }
  27157. }
  27158. declare module "babylonjs/Actions/abstractActionManager" {
  27159. import { IDisposable } from "babylonjs/scene";
  27160. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27161. import { IAction } from "babylonjs/Actions/action";
  27162. import { Nullable } from "babylonjs/types";
  27163. /**
  27164. * Abstract class used to decouple action Manager from scene and meshes.
  27165. * Do not instantiate.
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27167. */
  27168. export abstract class AbstractActionManager implements IDisposable {
  27169. /** Gets the list of active triggers */
  27170. static Triggers: {
  27171. [key: string]: number;
  27172. };
  27173. /** Gets the cursor to use when hovering items */
  27174. hoverCursor: string;
  27175. /** Gets the list of actions */
  27176. actions: IAction[];
  27177. /**
  27178. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27179. */
  27180. isRecursive: boolean;
  27181. /**
  27182. * Releases all associated resources
  27183. */
  27184. abstract dispose(): void;
  27185. /**
  27186. * Does this action manager has pointer triggers
  27187. */
  27188. abstract readonly hasPointerTriggers: boolean;
  27189. /**
  27190. * Does this action manager has pick triggers
  27191. */
  27192. abstract readonly hasPickTriggers: boolean;
  27193. /**
  27194. * Process a specific trigger
  27195. * @param trigger defines the trigger to process
  27196. * @param evt defines the event details to be processed
  27197. */
  27198. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27199. /**
  27200. * Does this action manager handles actions of any of the given triggers
  27201. * @param triggers defines the triggers to be tested
  27202. * @return a boolean indicating whether one (or more) of the triggers is handled
  27203. */
  27204. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27205. /**
  27206. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27207. * speed.
  27208. * @param triggerA defines the trigger to be tested
  27209. * @param triggerB defines the trigger to be tested
  27210. * @return a boolean indicating whether one (or more) of the triggers is handled
  27211. */
  27212. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27213. /**
  27214. * Does this action manager handles actions of a given trigger
  27215. * @param trigger defines the trigger to be tested
  27216. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27217. * @return whether the trigger is handled
  27218. */
  27219. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27220. /**
  27221. * Serialize this manager to a JSON object
  27222. * @param name defines the property name to store this manager
  27223. * @returns a JSON representation of this manager
  27224. */
  27225. abstract serialize(name: string): any;
  27226. /**
  27227. * Registers an action to this action manager
  27228. * @param action defines the action to be registered
  27229. * @return the action amended (prepared) after registration
  27230. */
  27231. abstract registerAction(action: IAction): Nullable<IAction>;
  27232. /**
  27233. * Unregisters an action to this action manager
  27234. * @param action defines the action to be unregistered
  27235. * @return a boolean indicating whether the action has been unregistered
  27236. */
  27237. abstract unregisterAction(action: IAction): Boolean;
  27238. /**
  27239. * Does exist one action manager with at least one trigger
  27240. **/
  27241. static readonly HasTriggers: boolean;
  27242. /**
  27243. * Does exist one action manager with at least one pick trigger
  27244. **/
  27245. static readonly HasPickTriggers: boolean;
  27246. /**
  27247. * Does exist one action manager that handles actions of a given trigger
  27248. * @param trigger defines the trigger to be tested
  27249. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27250. **/
  27251. static HasSpecificTrigger(trigger: number): boolean;
  27252. }
  27253. }
  27254. declare module "babylonjs/node" {
  27255. import { Scene } from "babylonjs/scene";
  27256. import { Nullable } from "babylonjs/types";
  27257. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27258. import { Engine } from "babylonjs/Engines/engine";
  27259. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27260. import { Observable } from "babylonjs/Misc/observable";
  27261. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27262. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27263. import { Animatable } from "babylonjs/Animations/animatable";
  27264. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27265. import { Animation } from "babylonjs/Animations/animation";
  27266. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27268. /**
  27269. * Defines how a node can be built from a string name.
  27270. */
  27271. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27272. /**
  27273. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27274. */
  27275. export class Node implements IBehaviorAware<Node> {
  27276. /** @hidden */
  27277. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27278. private static _NodeConstructors;
  27279. /**
  27280. * Add a new node constructor
  27281. * @param type defines the type name of the node to construct
  27282. * @param constructorFunc defines the constructor function
  27283. */
  27284. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27285. /**
  27286. * Returns a node constructor based on type name
  27287. * @param type defines the type name
  27288. * @param name defines the new node name
  27289. * @param scene defines the hosting scene
  27290. * @param options defines optional options to transmit to constructors
  27291. * @returns the new constructor or null
  27292. */
  27293. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27294. /**
  27295. * Gets or sets the name of the node
  27296. */
  27297. name: string;
  27298. /**
  27299. * Gets or sets the id of the node
  27300. */
  27301. id: string;
  27302. /**
  27303. * Gets or sets the unique id of the node
  27304. */
  27305. uniqueId: number;
  27306. /**
  27307. * Gets or sets a string used to store user defined state for the node
  27308. */
  27309. state: string;
  27310. /**
  27311. * Gets or sets an object used to store user defined information for the node
  27312. */
  27313. metadata: any;
  27314. /**
  27315. * For internal use only. Please do not use.
  27316. */
  27317. reservedDataStore: any;
  27318. /**
  27319. * List of inspectable custom properties (used by the Inspector)
  27320. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27321. */
  27322. inspectableCustomProperties: IInspectable[];
  27323. /**
  27324. * Gets or sets a boolean used to define if the node must be serialized
  27325. */
  27326. doNotSerialize: boolean;
  27327. /** @hidden */
  27328. _isDisposed: boolean;
  27329. /**
  27330. * Gets a list of Animations associated with the node
  27331. */
  27332. animations: import("babylonjs/Animations/animation").Animation[];
  27333. protected _ranges: {
  27334. [name: string]: Nullable<AnimationRange>;
  27335. };
  27336. /**
  27337. * Callback raised when the node is ready to be used
  27338. */
  27339. onReady: Nullable<(node: Node) => void>;
  27340. private _isEnabled;
  27341. private _isParentEnabled;
  27342. private _isReady;
  27343. /** @hidden */
  27344. _currentRenderId: number;
  27345. private _parentUpdateId;
  27346. /** @hidden */
  27347. _childUpdateId: number;
  27348. /** @hidden */
  27349. _waitingParentId: Nullable<string>;
  27350. /** @hidden */
  27351. _scene: Scene;
  27352. /** @hidden */
  27353. _cache: any;
  27354. private _parentNode;
  27355. private _children;
  27356. /** @hidden */
  27357. _worldMatrix: Matrix;
  27358. /** @hidden */
  27359. _worldMatrixDeterminant: number;
  27360. /** @hidden */
  27361. _worldMatrixDeterminantIsDirty: boolean;
  27362. /** @hidden */
  27363. private _sceneRootNodesIndex;
  27364. /**
  27365. * Gets a boolean indicating if the node has been disposed
  27366. * @returns true if the node was disposed
  27367. */
  27368. isDisposed(): boolean;
  27369. /**
  27370. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27371. * @see https://doc.babylonjs.com/how_to/parenting
  27372. */
  27373. parent: Nullable<Node>;
  27374. private addToSceneRootNodes;
  27375. private removeFromSceneRootNodes;
  27376. private _animationPropertiesOverride;
  27377. /**
  27378. * Gets or sets the animation properties override
  27379. */
  27380. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27381. /**
  27382. * Gets a string idenfifying the name of the class
  27383. * @returns "Node" string
  27384. */
  27385. getClassName(): string;
  27386. /** @hidden */
  27387. readonly _isNode: boolean;
  27388. /**
  27389. * An event triggered when the mesh is disposed
  27390. */
  27391. onDisposeObservable: Observable<Node>;
  27392. private _onDisposeObserver;
  27393. /**
  27394. * Sets a callback that will be raised when the node will be disposed
  27395. */
  27396. onDispose: () => void;
  27397. /**
  27398. * Creates a new Node
  27399. * @param name the name and id to be given to this node
  27400. * @param scene the scene this node will be added to
  27401. * @param addToRootNodes the node will be added to scene.rootNodes
  27402. */
  27403. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27404. /**
  27405. * Gets the scene of the node
  27406. * @returns a scene
  27407. */
  27408. getScene(): Scene;
  27409. /**
  27410. * Gets the engine of the node
  27411. * @returns a Engine
  27412. */
  27413. getEngine(): Engine;
  27414. private _behaviors;
  27415. /**
  27416. * Attach a behavior to the node
  27417. * @see http://doc.babylonjs.com/features/behaviour
  27418. * @param behavior defines the behavior to attach
  27419. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27420. * @returns the current Node
  27421. */
  27422. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27423. /**
  27424. * Remove an attached behavior
  27425. * @see http://doc.babylonjs.com/features/behaviour
  27426. * @param behavior defines the behavior to attach
  27427. * @returns the current Node
  27428. */
  27429. removeBehavior(behavior: Behavior<Node>): Node;
  27430. /**
  27431. * Gets the list of attached behaviors
  27432. * @see http://doc.babylonjs.com/features/behaviour
  27433. */
  27434. readonly behaviors: Behavior<Node>[];
  27435. /**
  27436. * Gets an attached behavior by name
  27437. * @param name defines the name of the behavior to look for
  27438. * @see http://doc.babylonjs.com/features/behaviour
  27439. * @returns null if behavior was not found else the requested behavior
  27440. */
  27441. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27442. /**
  27443. * Returns the latest update of the World matrix
  27444. * @returns a Matrix
  27445. */
  27446. getWorldMatrix(): Matrix;
  27447. /** @hidden */
  27448. _getWorldMatrixDeterminant(): number;
  27449. /**
  27450. * Returns directly the latest state of the mesh World matrix.
  27451. * A Matrix is returned.
  27452. */
  27453. readonly worldMatrixFromCache: Matrix;
  27454. /** @hidden */
  27455. _initCache(): void;
  27456. /** @hidden */
  27457. updateCache(force?: boolean): void;
  27458. /** @hidden */
  27459. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27460. /** @hidden */
  27461. _updateCache(ignoreParentClass?: boolean): void;
  27462. /** @hidden */
  27463. _isSynchronized(): boolean;
  27464. /** @hidden */
  27465. _markSyncedWithParent(): void;
  27466. /** @hidden */
  27467. isSynchronizedWithParent(): boolean;
  27468. /** @hidden */
  27469. isSynchronized(): boolean;
  27470. /**
  27471. * Is this node ready to be used/rendered
  27472. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27473. * @return true if the node is ready
  27474. */
  27475. isReady(completeCheck?: boolean): boolean;
  27476. /**
  27477. * Is this node enabled?
  27478. * 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
  27479. * @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
  27480. * @return whether this node (and its parent) is enabled
  27481. */
  27482. isEnabled(checkAncestors?: boolean): boolean;
  27483. /** @hidden */
  27484. protected _syncParentEnabledState(): void;
  27485. /**
  27486. * Set the enabled state of this node
  27487. * @param value defines the new enabled state
  27488. */
  27489. setEnabled(value: boolean): void;
  27490. /**
  27491. * Is this node a descendant of the given node?
  27492. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27493. * @param ancestor defines the parent node to inspect
  27494. * @returns a boolean indicating if this node is a descendant of the given node
  27495. */
  27496. isDescendantOf(ancestor: Node): boolean;
  27497. /** @hidden */
  27498. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27499. /**
  27500. * Will return all nodes that have this node as ascendant
  27501. * @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
  27502. * @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
  27503. * @return all children nodes of all types
  27504. */
  27505. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27506. /**
  27507. * Get all child-meshes of this node
  27508. * @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)
  27509. * @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
  27510. * @returns an array of AbstractMesh
  27511. */
  27512. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27513. /**
  27514. * Get all direct children of this node
  27515. * @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
  27516. * @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)
  27517. * @returns an array of Node
  27518. */
  27519. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27520. /** @hidden */
  27521. _setReady(state: boolean): void;
  27522. /**
  27523. * Get an animation by name
  27524. * @param name defines the name of the animation to look for
  27525. * @returns null if not found else the requested animation
  27526. */
  27527. getAnimationByName(name: string): Nullable<Animation>;
  27528. /**
  27529. * Creates an animation range for this node
  27530. * @param name defines the name of the range
  27531. * @param from defines the starting key
  27532. * @param to defines the end key
  27533. */
  27534. createAnimationRange(name: string, from: number, to: number): void;
  27535. /**
  27536. * Delete a specific animation range
  27537. * @param name defines the name of the range to delete
  27538. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27539. */
  27540. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27541. /**
  27542. * Get an animation range by name
  27543. * @param name defines the name of the animation range to look for
  27544. * @returns null if not found else the requested animation range
  27545. */
  27546. getAnimationRange(name: string): Nullable<AnimationRange>;
  27547. /**
  27548. * Gets the list of all animation ranges defined on this node
  27549. * @returns an array
  27550. */
  27551. getAnimationRanges(): Nullable<AnimationRange>[];
  27552. /**
  27553. * Will start the animation sequence
  27554. * @param name defines the range frames for animation sequence
  27555. * @param loop defines if the animation should loop (false by default)
  27556. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27557. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27558. * @returns the object created for this animation. If range does not exist, it will return null
  27559. */
  27560. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27561. /**
  27562. * Serialize animation ranges into a JSON compatible object
  27563. * @returns serialization object
  27564. */
  27565. serializeAnimationRanges(): any;
  27566. /**
  27567. * Computes the world matrix of the node
  27568. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27569. * @returns the world matrix
  27570. */
  27571. computeWorldMatrix(force?: boolean): Matrix;
  27572. /**
  27573. * Releases resources associated with this node.
  27574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27576. */
  27577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27578. /**
  27579. * Parse animation range data from a serialization object and store them into a given node
  27580. * @param node defines where to store the animation ranges
  27581. * @param parsedNode defines the serialization object to read data from
  27582. * @param scene defines the hosting scene
  27583. */
  27584. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27585. /**
  27586. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27587. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27588. * @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
  27589. * @returns the new bounding vectors
  27590. */
  27591. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27592. min: Vector3;
  27593. max: Vector3;
  27594. };
  27595. }
  27596. }
  27597. declare module "babylonjs/Animations/animation" {
  27598. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27599. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27600. import { Color3 } from "babylonjs/Maths/math.color";
  27601. import { Nullable } from "babylonjs/types";
  27602. import { Scene } from "babylonjs/scene";
  27603. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27604. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27605. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27606. import { Node } from "babylonjs/node";
  27607. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27608. import { Size } from "babylonjs/Maths/math.size";
  27609. import { Animatable } from "babylonjs/Animations/animatable";
  27610. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27611. /**
  27612. * @hidden
  27613. */
  27614. export class _IAnimationState {
  27615. key: number;
  27616. repeatCount: number;
  27617. workValue?: any;
  27618. loopMode?: number;
  27619. offsetValue?: any;
  27620. highLimitValue?: any;
  27621. }
  27622. /**
  27623. * Class used to store any kind of animation
  27624. */
  27625. export class Animation {
  27626. /**Name of the animation */
  27627. name: string;
  27628. /**Property to animate */
  27629. targetProperty: string;
  27630. /**The frames per second of the animation */
  27631. framePerSecond: number;
  27632. /**The data type of the animation */
  27633. dataType: number;
  27634. /**The loop mode of the animation */
  27635. loopMode?: number | undefined;
  27636. /**Specifies if blending should be enabled */
  27637. enableBlending?: boolean | undefined;
  27638. /**
  27639. * Use matrix interpolation instead of using direct key value when animating matrices
  27640. */
  27641. static AllowMatricesInterpolation: boolean;
  27642. /**
  27643. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27644. */
  27645. static AllowMatrixDecomposeForInterpolation: boolean;
  27646. /**
  27647. * Stores the key frames of the animation
  27648. */
  27649. private _keys;
  27650. /**
  27651. * Stores the easing function of the animation
  27652. */
  27653. private _easingFunction;
  27654. /**
  27655. * @hidden Internal use only
  27656. */
  27657. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27658. /**
  27659. * The set of event that will be linked to this animation
  27660. */
  27661. private _events;
  27662. /**
  27663. * Stores an array of target property paths
  27664. */
  27665. targetPropertyPath: string[];
  27666. /**
  27667. * Stores the blending speed of the animation
  27668. */
  27669. blendingSpeed: number;
  27670. /**
  27671. * Stores the animation ranges for the animation
  27672. */
  27673. private _ranges;
  27674. /**
  27675. * @hidden Internal use
  27676. */
  27677. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27678. /**
  27679. * Sets up an animation
  27680. * @param property The property to animate
  27681. * @param animationType The animation type to apply
  27682. * @param framePerSecond The frames per second of the animation
  27683. * @param easingFunction The easing function used in the animation
  27684. * @returns The created animation
  27685. */
  27686. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27687. /**
  27688. * Create and start an animation on a node
  27689. * @param name defines the name of the global animation that will be run on all nodes
  27690. * @param node defines the root node where the animation will take place
  27691. * @param targetProperty defines property to animate
  27692. * @param framePerSecond defines the number of frame per second yo use
  27693. * @param totalFrame defines the number of frames in total
  27694. * @param from defines the initial value
  27695. * @param to defines the final value
  27696. * @param loopMode defines which loop mode you want to use (off by default)
  27697. * @param easingFunction defines the easing function to use (linear by default)
  27698. * @param onAnimationEnd defines the callback to call when animation end
  27699. * @returns the animatable created for this animation
  27700. */
  27701. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27702. /**
  27703. * Create and start an animation on a node and its descendants
  27704. * @param name defines the name of the global animation that will be run on all nodes
  27705. * @param node defines the root node where the animation will take place
  27706. * @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
  27707. * @param targetProperty defines property to animate
  27708. * @param framePerSecond defines the number of frame per second to use
  27709. * @param totalFrame defines the number of frames in total
  27710. * @param from defines the initial value
  27711. * @param to defines the final value
  27712. * @param loopMode defines which loop mode you want to use (off by default)
  27713. * @param easingFunction defines the easing function to use (linear by default)
  27714. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27715. * @returns the list of animatables created for all nodes
  27716. * @example https://www.babylonjs-playground.com/#MH0VLI
  27717. */
  27718. 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[]>;
  27719. /**
  27720. * Creates a new animation, merges it with the existing animations and starts it
  27721. * @param name Name of the animation
  27722. * @param node Node which contains the scene that begins the animations
  27723. * @param targetProperty Specifies which property to animate
  27724. * @param framePerSecond The frames per second of the animation
  27725. * @param totalFrame The total number of frames
  27726. * @param from The frame at the beginning of the animation
  27727. * @param to The frame at the end of the animation
  27728. * @param loopMode Specifies the loop mode of the animation
  27729. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27730. * @param onAnimationEnd Callback to run once the animation is complete
  27731. * @returns Nullable animation
  27732. */
  27733. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27734. /**
  27735. * Transition property of an host to the target Value
  27736. * @param property The property to transition
  27737. * @param targetValue The target Value of the property
  27738. * @param host The object where the property to animate belongs
  27739. * @param scene Scene used to run the animation
  27740. * @param frameRate Framerate (in frame/s) to use
  27741. * @param transition The transition type we want to use
  27742. * @param duration The duration of the animation, in milliseconds
  27743. * @param onAnimationEnd Callback trigger at the end of the animation
  27744. * @returns Nullable animation
  27745. */
  27746. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27747. /**
  27748. * Return the array of runtime animations currently using this animation
  27749. */
  27750. readonly runtimeAnimations: RuntimeAnimation[];
  27751. /**
  27752. * Specifies if any of the runtime animations are currently running
  27753. */
  27754. readonly hasRunningRuntimeAnimations: boolean;
  27755. /**
  27756. * Initializes the animation
  27757. * @param name Name of the animation
  27758. * @param targetProperty Property to animate
  27759. * @param framePerSecond The frames per second of the animation
  27760. * @param dataType The data type of the animation
  27761. * @param loopMode The loop mode of the animation
  27762. * @param enableBlending Specifies if blending should be enabled
  27763. */
  27764. constructor(
  27765. /**Name of the animation */
  27766. name: string,
  27767. /**Property to animate */
  27768. targetProperty: string,
  27769. /**The frames per second of the animation */
  27770. framePerSecond: number,
  27771. /**The data type of the animation */
  27772. dataType: number,
  27773. /**The loop mode of the animation */
  27774. loopMode?: number | undefined,
  27775. /**Specifies if blending should be enabled */
  27776. enableBlending?: boolean | undefined);
  27777. /**
  27778. * Converts the animation to a string
  27779. * @param fullDetails support for multiple levels of logging within scene loading
  27780. * @returns String form of the animation
  27781. */
  27782. toString(fullDetails?: boolean): string;
  27783. /**
  27784. * Add an event to this animation
  27785. * @param event Event to add
  27786. */
  27787. addEvent(event: AnimationEvent): void;
  27788. /**
  27789. * Remove all events found at the given frame
  27790. * @param frame The frame to remove events from
  27791. */
  27792. removeEvents(frame: number): void;
  27793. /**
  27794. * Retrieves all the events from the animation
  27795. * @returns Events from the animation
  27796. */
  27797. getEvents(): AnimationEvent[];
  27798. /**
  27799. * Creates an animation range
  27800. * @param name Name of the animation range
  27801. * @param from Starting frame of the animation range
  27802. * @param to Ending frame of the animation
  27803. */
  27804. createRange(name: string, from: number, to: number): void;
  27805. /**
  27806. * Deletes an animation range by name
  27807. * @param name Name of the animation range to delete
  27808. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27809. */
  27810. deleteRange(name: string, deleteFrames?: boolean): void;
  27811. /**
  27812. * Gets the animation range by name, or null if not defined
  27813. * @param name Name of the animation range
  27814. * @returns Nullable animation range
  27815. */
  27816. getRange(name: string): Nullable<AnimationRange>;
  27817. /**
  27818. * Gets the key frames from the animation
  27819. * @returns The key frames of the animation
  27820. */
  27821. getKeys(): Array<IAnimationKey>;
  27822. /**
  27823. * Gets the highest frame rate of the animation
  27824. * @returns Highest frame rate of the animation
  27825. */
  27826. getHighestFrame(): number;
  27827. /**
  27828. * Gets the easing function of the animation
  27829. * @returns Easing function of the animation
  27830. */
  27831. getEasingFunction(): IEasingFunction;
  27832. /**
  27833. * Sets the easing function of the animation
  27834. * @param easingFunction A custom mathematical formula for animation
  27835. */
  27836. setEasingFunction(easingFunction: EasingFunction): void;
  27837. /**
  27838. * Interpolates a scalar linearly
  27839. * @param startValue Start value of the animation curve
  27840. * @param endValue End value of the animation curve
  27841. * @param gradient Scalar amount to interpolate
  27842. * @returns Interpolated scalar value
  27843. */
  27844. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27845. /**
  27846. * Interpolates a scalar cubically
  27847. * @param startValue Start value of the animation curve
  27848. * @param outTangent End tangent of the animation
  27849. * @param endValue End value of the animation curve
  27850. * @param inTangent Start tangent of the animation curve
  27851. * @param gradient Scalar amount to interpolate
  27852. * @returns Interpolated scalar value
  27853. */
  27854. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27855. /**
  27856. * Interpolates a quaternion using a spherical linear interpolation
  27857. * @param startValue Start value of the animation curve
  27858. * @param endValue End value of the animation curve
  27859. * @param gradient Scalar amount to interpolate
  27860. * @returns Interpolated quaternion value
  27861. */
  27862. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27863. /**
  27864. * Interpolates a quaternion cubically
  27865. * @param startValue Start value of the animation curve
  27866. * @param outTangent End tangent of the animation curve
  27867. * @param endValue End value of the animation curve
  27868. * @param inTangent Start tangent of the animation curve
  27869. * @param gradient Scalar amount to interpolate
  27870. * @returns Interpolated quaternion value
  27871. */
  27872. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27873. /**
  27874. * Interpolates a Vector3 linearl
  27875. * @param startValue Start value of the animation curve
  27876. * @param endValue End value of the animation curve
  27877. * @param gradient Scalar amount to interpolate
  27878. * @returns Interpolated scalar value
  27879. */
  27880. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27881. /**
  27882. * Interpolates a Vector3 cubically
  27883. * @param startValue Start value of the animation curve
  27884. * @param outTangent End tangent of the animation
  27885. * @param endValue End value of the animation curve
  27886. * @param inTangent Start tangent of the animation curve
  27887. * @param gradient Scalar amount to interpolate
  27888. * @returns InterpolatedVector3 value
  27889. */
  27890. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27891. /**
  27892. * Interpolates a Vector2 linearly
  27893. * @param startValue Start value of the animation curve
  27894. * @param endValue End value of the animation curve
  27895. * @param gradient Scalar amount to interpolate
  27896. * @returns Interpolated Vector2 value
  27897. */
  27898. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27899. /**
  27900. * Interpolates a Vector2 cubically
  27901. * @param startValue Start value of the animation curve
  27902. * @param outTangent End tangent of the animation
  27903. * @param endValue End value of the animation curve
  27904. * @param inTangent Start tangent of the animation curve
  27905. * @param gradient Scalar amount to interpolate
  27906. * @returns Interpolated Vector2 value
  27907. */
  27908. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27909. /**
  27910. * Interpolates a size linearly
  27911. * @param startValue Start value of the animation curve
  27912. * @param endValue End value of the animation curve
  27913. * @param gradient Scalar amount to interpolate
  27914. * @returns Interpolated Size value
  27915. */
  27916. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27917. /**
  27918. * Interpolates a Color3 linearly
  27919. * @param startValue Start value of the animation curve
  27920. * @param endValue End value of the animation curve
  27921. * @param gradient Scalar amount to interpolate
  27922. * @returns Interpolated Color3 value
  27923. */
  27924. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27925. /**
  27926. * @hidden Internal use only
  27927. */
  27928. _getKeyValue(value: any): any;
  27929. /**
  27930. * @hidden Internal use only
  27931. */
  27932. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27933. /**
  27934. * Defines the function to use to interpolate matrices
  27935. * @param startValue defines the start matrix
  27936. * @param endValue defines the end matrix
  27937. * @param gradient defines the gradient between both matrices
  27938. * @param result defines an optional target matrix where to store the interpolation
  27939. * @returns the interpolated matrix
  27940. */
  27941. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27942. /**
  27943. * Makes a copy of the animation
  27944. * @returns Cloned animation
  27945. */
  27946. clone(): Animation;
  27947. /**
  27948. * Sets the key frames of the animation
  27949. * @param values The animation key frames to set
  27950. */
  27951. setKeys(values: Array<IAnimationKey>): void;
  27952. /**
  27953. * Serializes the animation to an object
  27954. * @returns Serialized object
  27955. */
  27956. serialize(): any;
  27957. /**
  27958. * Float animation type
  27959. */
  27960. private static _ANIMATIONTYPE_FLOAT;
  27961. /**
  27962. * Vector3 animation type
  27963. */
  27964. private static _ANIMATIONTYPE_VECTOR3;
  27965. /**
  27966. * Quaternion animation type
  27967. */
  27968. private static _ANIMATIONTYPE_QUATERNION;
  27969. /**
  27970. * Matrix animation type
  27971. */
  27972. private static _ANIMATIONTYPE_MATRIX;
  27973. /**
  27974. * Color3 animation type
  27975. */
  27976. private static _ANIMATIONTYPE_COLOR3;
  27977. /**
  27978. * Vector2 animation type
  27979. */
  27980. private static _ANIMATIONTYPE_VECTOR2;
  27981. /**
  27982. * Size animation type
  27983. */
  27984. private static _ANIMATIONTYPE_SIZE;
  27985. /**
  27986. * Relative Loop Mode
  27987. */
  27988. private static _ANIMATIONLOOPMODE_RELATIVE;
  27989. /**
  27990. * Cycle Loop Mode
  27991. */
  27992. private static _ANIMATIONLOOPMODE_CYCLE;
  27993. /**
  27994. * Constant Loop Mode
  27995. */
  27996. private static _ANIMATIONLOOPMODE_CONSTANT;
  27997. /**
  27998. * Get the float animation type
  27999. */
  28000. static readonly ANIMATIONTYPE_FLOAT: number;
  28001. /**
  28002. * Get the Vector3 animation type
  28003. */
  28004. static readonly ANIMATIONTYPE_VECTOR3: number;
  28005. /**
  28006. * Get the Vector2 animation type
  28007. */
  28008. static readonly ANIMATIONTYPE_VECTOR2: number;
  28009. /**
  28010. * Get the Size animation type
  28011. */
  28012. static readonly ANIMATIONTYPE_SIZE: number;
  28013. /**
  28014. * Get the Quaternion animation type
  28015. */
  28016. static readonly ANIMATIONTYPE_QUATERNION: number;
  28017. /**
  28018. * Get the Matrix animation type
  28019. */
  28020. static readonly ANIMATIONTYPE_MATRIX: number;
  28021. /**
  28022. * Get the Color3 animation type
  28023. */
  28024. static readonly ANIMATIONTYPE_COLOR3: number;
  28025. /**
  28026. * Get the Relative Loop Mode
  28027. */
  28028. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28029. /**
  28030. * Get the Cycle Loop Mode
  28031. */
  28032. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28033. /**
  28034. * Get the Constant Loop Mode
  28035. */
  28036. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28037. /** @hidden */
  28038. static _UniversalLerp(left: any, right: any, amount: number): any;
  28039. /**
  28040. * Parses an animation object and creates an animation
  28041. * @param parsedAnimation Parsed animation object
  28042. * @returns Animation object
  28043. */
  28044. static Parse(parsedAnimation: any): Animation;
  28045. /**
  28046. * Appends the serialized animations from the source animations
  28047. * @param source Source containing the animations
  28048. * @param destination Target to store the animations
  28049. */
  28050. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28051. }
  28052. }
  28053. declare module "babylonjs/Animations/animatable.interface" {
  28054. import { Nullable } from "babylonjs/types";
  28055. import { Animation } from "babylonjs/Animations/animation";
  28056. /**
  28057. * Interface containing an array of animations
  28058. */
  28059. export interface IAnimatable {
  28060. /**
  28061. * Array of animations
  28062. */
  28063. animations: Nullable<Array<Animation>>;
  28064. }
  28065. }
  28066. declare module "babylonjs/Materials/fresnelParameters" {
  28067. import { Color3 } from "babylonjs/Maths/math.color";
  28068. /**
  28069. * This represents all the required information to add a fresnel effect on a material:
  28070. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28071. */
  28072. export class FresnelParameters {
  28073. private _isEnabled;
  28074. /**
  28075. * Define if the fresnel effect is enable or not.
  28076. */
  28077. isEnabled: boolean;
  28078. /**
  28079. * Define the color used on edges (grazing angle)
  28080. */
  28081. leftColor: Color3;
  28082. /**
  28083. * Define the color used on center
  28084. */
  28085. rightColor: Color3;
  28086. /**
  28087. * Define bias applied to computed fresnel term
  28088. */
  28089. bias: number;
  28090. /**
  28091. * Defined the power exponent applied to fresnel term
  28092. */
  28093. power: number;
  28094. /**
  28095. * Clones the current fresnel and its valuues
  28096. * @returns a clone fresnel configuration
  28097. */
  28098. clone(): FresnelParameters;
  28099. /**
  28100. * Serializes the current fresnel parameters to a JSON representation.
  28101. * @return the JSON serialization
  28102. */
  28103. serialize(): any;
  28104. /**
  28105. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28106. * @param parsedFresnelParameters Define the JSON representation
  28107. * @returns the parsed parameters
  28108. */
  28109. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28110. }
  28111. }
  28112. declare module "babylonjs/Misc/decorators" {
  28113. import { Nullable } from "babylonjs/types";
  28114. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28115. import { Scene } from "babylonjs/scene";
  28116. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28117. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28118. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28119. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28120. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28121. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28122. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28123. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28124. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28125. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28126. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28127. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28128. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28129. /**
  28130. * Decorator used to define property that can be serialized as reference to a camera
  28131. * @param sourceName defines the name of the property to decorate
  28132. */
  28133. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28134. /**
  28135. * Class used to help serialization objects
  28136. */
  28137. export class SerializationHelper {
  28138. /** @hidden */
  28139. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28140. /** @hidden */
  28141. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28142. /** @hidden */
  28143. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28144. /** @hidden */
  28145. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28146. /**
  28147. * Appends the serialized animations from the source animations
  28148. * @param source Source containing the animations
  28149. * @param destination Target to store the animations
  28150. */
  28151. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28152. /**
  28153. * Static function used to serialized a specific entity
  28154. * @param entity defines the entity to serialize
  28155. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28156. * @returns a JSON compatible object representing the serialization of the entity
  28157. */
  28158. static Serialize<T>(entity: T, serializationObject?: any): any;
  28159. /**
  28160. * Creates a new entity from a serialization data object
  28161. * @param creationFunction defines a function used to instanciated the new entity
  28162. * @param source defines the source serialization data
  28163. * @param scene defines the hosting scene
  28164. * @param rootUrl defines the root url for resources
  28165. * @returns a new entity
  28166. */
  28167. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28168. /**
  28169. * Clones an object
  28170. * @param creationFunction defines the function used to instanciate the new object
  28171. * @param source defines the source object
  28172. * @returns the cloned object
  28173. */
  28174. static Clone<T>(creationFunction: () => T, source: T): T;
  28175. /**
  28176. * Instanciates a new object based on a source one (some data will be shared between both object)
  28177. * @param creationFunction defines the function used to instanciate the new object
  28178. * @param source defines the source object
  28179. * @returns the new object
  28180. */
  28181. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28182. }
  28183. }
  28184. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28185. import { Nullable } from "babylonjs/types";
  28186. /**
  28187. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28188. */
  28189. export interface CubeMapInfo {
  28190. /**
  28191. * The pixel array for the front face.
  28192. * This is stored in format, left to right, up to down format.
  28193. */
  28194. front: Nullable<ArrayBufferView>;
  28195. /**
  28196. * The pixel array for the back face.
  28197. * This is stored in format, left to right, up to down format.
  28198. */
  28199. back: Nullable<ArrayBufferView>;
  28200. /**
  28201. * The pixel array for the left face.
  28202. * This is stored in format, left to right, up to down format.
  28203. */
  28204. left: Nullable<ArrayBufferView>;
  28205. /**
  28206. * The pixel array for the right face.
  28207. * This is stored in format, left to right, up to down format.
  28208. */
  28209. right: Nullable<ArrayBufferView>;
  28210. /**
  28211. * The pixel array for the up face.
  28212. * This is stored in format, left to right, up to down format.
  28213. */
  28214. up: Nullable<ArrayBufferView>;
  28215. /**
  28216. * The pixel array for the down face.
  28217. * This is stored in format, left to right, up to down format.
  28218. */
  28219. down: Nullable<ArrayBufferView>;
  28220. /**
  28221. * The size of the cubemap stored.
  28222. *
  28223. * Each faces will be size * size pixels.
  28224. */
  28225. size: number;
  28226. /**
  28227. * The format of the texture.
  28228. *
  28229. * RGBA, RGB.
  28230. */
  28231. format: number;
  28232. /**
  28233. * The type of the texture data.
  28234. *
  28235. * UNSIGNED_INT, FLOAT.
  28236. */
  28237. type: number;
  28238. /**
  28239. * Specifies whether the texture is in gamma space.
  28240. */
  28241. gammaSpace: boolean;
  28242. }
  28243. /**
  28244. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28245. */
  28246. export class PanoramaToCubeMapTools {
  28247. private static FACE_FRONT;
  28248. private static FACE_BACK;
  28249. private static FACE_RIGHT;
  28250. private static FACE_LEFT;
  28251. private static FACE_DOWN;
  28252. private static FACE_UP;
  28253. /**
  28254. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28255. *
  28256. * @param float32Array The source data.
  28257. * @param inputWidth The width of the input panorama.
  28258. * @param inputHeight The height of the input panorama.
  28259. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28260. * @return The cubemap data
  28261. */
  28262. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28263. private static CreateCubemapTexture;
  28264. private static CalcProjectionSpherical;
  28265. }
  28266. }
  28267. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28268. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28270. import { Nullable } from "babylonjs/types";
  28271. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28272. /**
  28273. * Helper class dealing with the extraction of spherical polynomial dataArray
  28274. * from a cube map.
  28275. */
  28276. export class CubeMapToSphericalPolynomialTools {
  28277. private static FileFaces;
  28278. /**
  28279. * Converts a texture to the according Spherical Polynomial data.
  28280. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28281. *
  28282. * @param texture The texture to extract the information from.
  28283. * @return The Spherical Polynomial data.
  28284. */
  28285. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28286. /**
  28287. * Converts a cubemap to the according Spherical Polynomial data.
  28288. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28289. *
  28290. * @param cubeInfo The Cube map to extract the information from.
  28291. * @return The Spherical Polynomial data.
  28292. */
  28293. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28294. }
  28295. }
  28296. declare module "babylonjs/Misc/guid" {
  28297. /**
  28298. * Class used to manipulate GUIDs
  28299. */
  28300. export class GUID {
  28301. /**
  28302. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28303. * Be aware Math.random() could cause collisions, but:
  28304. * "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"
  28305. * @returns a pseudo random id
  28306. */
  28307. static RandomId(): string;
  28308. }
  28309. }
  28310. declare module "babylonjs/Materials/Textures/baseTexture" {
  28311. import { Observable } from "babylonjs/Misc/observable";
  28312. import { Nullable } from "babylonjs/types";
  28313. import { Scene } from "babylonjs/scene";
  28314. import { Matrix } from "babylonjs/Maths/math.vector";
  28315. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28317. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28318. import { ISize } from "babylonjs/Maths/math.size";
  28319. /**
  28320. * Base class of all the textures in babylon.
  28321. * It groups all the common properties the materials, post process, lights... might need
  28322. * in order to make a correct use of the texture.
  28323. */
  28324. export class BaseTexture implements IAnimatable {
  28325. /**
  28326. * Default anisotropic filtering level for the application.
  28327. * It is set to 4 as a good tradeoff between perf and quality.
  28328. */
  28329. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28330. /**
  28331. * Gets or sets the unique id of the texture
  28332. */
  28333. uniqueId: number;
  28334. /**
  28335. * Define the name of the texture.
  28336. */
  28337. name: string;
  28338. /**
  28339. * Gets or sets an object used to store user defined information.
  28340. */
  28341. metadata: any;
  28342. /**
  28343. * For internal use only. Please do not use.
  28344. */
  28345. reservedDataStore: any;
  28346. private _hasAlpha;
  28347. /**
  28348. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28349. */
  28350. hasAlpha: boolean;
  28351. /**
  28352. * Defines if the alpha value should be determined via the rgb values.
  28353. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28354. */
  28355. getAlphaFromRGB: boolean;
  28356. /**
  28357. * Intensity or strength of the texture.
  28358. * It is commonly used by materials to fine tune the intensity of the texture
  28359. */
  28360. level: number;
  28361. /**
  28362. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28363. * This is part of the texture as textures usually maps to one uv set.
  28364. */
  28365. coordinatesIndex: number;
  28366. private _coordinatesMode;
  28367. /**
  28368. * How a texture is mapped.
  28369. *
  28370. * | Value | Type | Description |
  28371. * | ----- | ----------------------------------- | ----------- |
  28372. * | 0 | EXPLICIT_MODE | |
  28373. * | 1 | SPHERICAL_MODE | |
  28374. * | 2 | PLANAR_MODE | |
  28375. * | 3 | CUBIC_MODE | |
  28376. * | 4 | PROJECTION_MODE | |
  28377. * | 5 | SKYBOX_MODE | |
  28378. * | 6 | INVCUBIC_MODE | |
  28379. * | 7 | EQUIRECTANGULAR_MODE | |
  28380. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28381. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28382. */
  28383. coordinatesMode: number;
  28384. /**
  28385. * | Value | Type | Description |
  28386. * | ----- | ------------------ | ----------- |
  28387. * | 0 | CLAMP_ADDRESSMODE | |
  28388. * | 1 | WRAP_ADDRESSMODE | |
  28389. * | 2 | MIRROR_ADDRESSMODE | |
  28390. */
  28391. wrapU: number;
  28392. /**
  28393. * | Value | Type | Description |
  28394. * | ----- | ------------------ | ----------- |
  28395. * | 0 | CLAMP_ADDRESSMODE | |
  28396. * | 1 | WRAP_ADDRESSMODE | |
  28397. * | 2 | MIRROR_ADDRESSMODE | |
  28398. */
  28399. wrapV: number;
  28400. /**
  28401. * | Value | Type | Description |
  28402. * | ----- | ------------------ | ----------- |
  28403. * | 0 | CLAMP_ADDRESSMODE | |
  28404. * | 1 | WRAP_ADDRESSMODE | |
  28405. * | 2 | MIRROR_ADDRESSMODE | |
  28406. */
  28407. wrapR: number;
  28408. /**
  28409. * With compliant hardware and browser (supporting anisotropic filtering)
  28410. * this defines the level of anisotropic filtering in the texture.
  28411. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28412. */
  28413. anisotropicFilteringLevel: number;
  28414. /**
  28415. * Define if the texture is a cube texture or if false a 2d texture.
  28416. */
  28417. isCube: boolean;
  28418. /**
  28419. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28420. */
  28421. is3D: boolean;
  28422. /**
  28423. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28424. * HDR texture are usually stored in linear space.
  28425. * This only impacts the PBR and Background materials
  28426. */
  28427. gammaSpace: boolean;
  28428. /**
  28429. * Gets whether or not the texture contains RGBD data.
  28430. */
  28431. readonly isRGBD: boolean;
  28432. /**
  28433. * Is Z inverted in the texture (useful in a cube texture).
  28434. */
  28435. invertZ: boolean;
  28436. /**
  28437. * Are mip maps generated for this texture or not.
  28438. */
  28439. readonly noMipmap: boolean;
  28440. /**
  28441. * @hidden
  28442. */
  28443. lodLevelInAlpha: boolean;
  28444. /**
  28445. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28446. */
  28447. lodGenerationOffset: number;
  28448. /**
  28449. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28450. */
  28451. lodGenerationScale: number;
  28452. /**
  28453. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28454. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28455. * average roughness values.
  28456. */
  28457. linearSpecularLOD: boolean;
  28458. /**
  28459. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28460. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28461. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28462. */
  28463. irradianceTexture: Nullable<BaseTexture>;
  28464. /**
  28465. * Define if the texture is a render target.
  28466. */
  28467. isRenderTarget: boolean;
  28468. /**
  28469. * Define the unique id of the texture in the scene.
  28470. */
  28471. readonly uid: string;
  28472. /**
  28473. * Return a string representation of the texture.
  28474. * @returns the texture as a string
  28475. */
  28476. toString(): string;
  28477. /**
  28478. * Get the class name of the texture.
  28479. * @returns "BaseTexture"
  28480. */
  28481. getClassName(): string;
  28482. /**
  28483. * Define the list of animation attached to the texture.
  28484. */
  28485. animations: import("babylonjs/Animations/animation").Animation[];
  28486. /**
  28487. * An event triggered when the texture is disposed.
  28488. */
  28489. onDisposeObservable: Observable<BaseTexture>;
  28490. private _onDisposeObserver;
  28491. /**
  28492. * Callback triggered when the texture has been disposed.
  28493. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28494. */
  28495. onDispose: () => void;
  28496. /**
  28497. * Define the current state of the loading sequence when in delayed load mode.
  28498. */
  28499. delayLoadState: number;
  28500. private _scene;
  28501. /** @hidden */
  28502. _texture: Nullable<InternalTexture>;
  28503. private _uid;
  28504. /**
  28505. * Define if the texture is preventinga material to render or not.
  28506. * If not and the texture is not ready, the engine will use a default black texture instead.
  28507. */
  28508. readonly isBlocking: boolean;
  28509. /**
  28510. * Instantiates a new BaseTexture.
  28511. * Base class of all the textures in babylon.
  28512. * It groups all the common properties the materials, post process, lights... might need
  28513. * in order to make a correct use of the texture.
  28514. * @param scene Define the scene the texture blongs to
  28515. */
  28516. constructor(scene: Nullable<Scene>);
  28517. /**
  28518. * Get the scene the texture belongs to.
  28519. * @returns the scene or null if undefined
  28520. */
  28521. getScene(): Nullable<Scene>;
  28522. /**
  28523. * Get the texture transform matrix used to offset tile the texture for istance.
  28524. * @returns the transformation matrix
  28525. */
  28526. getTextureMatrix(): Matrix;
  28527. /**
  28528. * Get the texture reflection matrix used to rotate/transform the reflection.
  28529. * @returns the reflection matrix
  28530. */
  28531. getReflectionTextureMatrix(): Matrix;
  28532. /**
  28533. * Get the underlying lower level texture from Babylon.
  28534. * @returns the insternal texture
  28535. */
  28536. getInternalTexture(): Nullable<InternalTexture>;
  28537. /**
  28538. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28539. * @returns true if ready or not blocking
  28540. */
  28541. isReadyOrNotBlocking(): boolean;
  28542. /**
  28543. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28544. * @returns true if fully ready
  28545. */
  28546. isReady(): boolean;
  28547. private _cachedSize;
  28548. /**
  28549. * Get the size of the texture.
  28550. * @returns the texture size.
  28551. */
  28552. getSize(): ISize;
  28553. /**
  28554. * Get the base size of the texture.
  28555. * It can be different from the size if the texture has been resized for POT for instance
  28556. * @returns the base size
  28557. */
  28558. getBaseSize(): ISize;
  28559. /**
  28560. * Update the sampling mode of the texture.
  28561. * Default is Trilinear mode.
  28562. *
  28563. * | Value | Type | Description |
  28564. * | ----- | ------------------ | ----------- |
  28565. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28566. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28567. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28568. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28569. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28570. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28571. * | 7 | NEAREST_LINEAR | |
  28572. * | 8 | NEAREST_NEAREST | |
  28573. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28574. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28575. * | 11 | LINEAR_LINEAR | |
  28576. * | 12 | LINEAR_NEAREST | |
  28577. *
  28578. * > _mag_: magnification filter (close to the viewer)
  28579. * > _min_: minification filter (far from the viewer)
  28580. * > _mip_: filter used between mip map levels
  28581. *@param samplingMode Define the new sampling mode of the texture
  28582. */
  28583. updateSamplingMode(samplingMode: number): void;
  28584. /**
  28585. * Scales the texture if is `canRescale()`
  28586. * @param ratio the resize factor we want to use to rescale
  28587. */
  28588. scale(ratio: number): void;
  28589. /**
  28590. * Get if the texture can rescale.
  28591. */
  28592. readonly canRescale: boolean;
  28593. /** @hidden */
  28594. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28595. /** @hidden */
  28596. _rebuild(): void;
  28597. /**
  28598. * Triggers the load sequence in delayed load mode.
  28599. */
  28600. delayLoad(): void;
  28601. /**
  28602. * Clones the texture.
  28603. * @returns the cloned texture
  28604. */
  28605. clone(): Nullable<BaseTexture>;
  28606. /**
  28607. * Get the texture underlying type (INT, FLOAT...)
  28608. */
  28609. readonly textureType: number;
  28610. /**
  28611. * Get the texture underlying format (RGB, RGBA...)
  28612. */
  28613. readonly textureFormat: number;
  28614. /**
  28615. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28616. * This will returns an RGBA array buffer containing either in values (0-255) or
  28617. * float values (0-1) depending of the underlying buffer type.
  28618. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28619. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28620. * @param buffer defines a user defined buffer to fill with data (can be null)
  28621. * @returns The Array buffer containing the pixels data.
  28622. */
  28623. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28624. /**
  28625. * Release and destroy the underlying lower level texture aka internalTexture.
  28626. */
  28627. releaseInternalTexture(): void;
  28628. /**
  28629. * Get the polynomial representation of the texture data.
  28630. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28631. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28632. */
  28633. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28634. /** @hidden */
  28635. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28636. /** @hidden */
  28637. readonly _lodTextureMid: Nullable<BaseTexture>;
  28638. /** @hidden */
  28639. readonly _lodTextureLow: Nullable<BaseTexture>;
  28640. /**
  28641. * Dispose the texture and release its associated resources.
  28642. */
  28643. dispose(): void;
  28644. /**
  28645. * Serialize the texture into a JSON representation that can be parsed later on.
  28646. * @returns the JSON representation of the texture
  28647. */
  28648. serialize(): any;
  28649. /**
  28650. * Helper function to be called back once a list of texture contains only ready textures.
  28651. * @param textures Define the list of textures to wait for
  28652. * @param callback Define the callback triggered once the entire list will be ready
  28653. */
  28654. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28655. }
  28656. }
  28657. declare module "babylonjs/Materials/Textures/internalTexture" {
  28658. import { Observable } from "babylonjs/Misc/observable";
  28659. import { Nullable, int } from "babylonjs/types";
  28660. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28661. import { Engine } from "babylonjs/Engines/engine";
  28662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28663. /**
  28664. * Class used to store data associated with WebGL texture data for the engine
  28665. * This class should not be used directly
  28666. */
  28667. export class InternalTexture {
  28668. /** @hidden */
  28669. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28670. /**
  28671. * The source of the texture data is unknown
  28672. */
  28673. static DATASOURCE_UNKNOWN: number;
  28674. /**
  28675. * Texture data comes from an URL
  28676. */
  28677. static DATASOURCE_URL: number;
  28678. /**
  28679. * Texture data is only used for temporary storage
  28680. */
  28681. static DATASOURCE_TEMP: number;
  28682. /**
  28683. * Texture data comes from raw data (ArrayBuffer)
  28684. */
  28685. static DATASOURCE_RAW: number;
  28686. /**
  28687. * Texture content is dynamic (video or dynamic texture)
  28688. */
  28689. static DATASOURCE_DYNAMIC: number;
  28690. /**
  28691. * Texture content is generated by rendering to it
  28692. */
  28693. static DATASOURCE_RENDERTARGET: number;
  28694. /**
  28695. * Texture content is part of a multi render target process
  28696. */
  28697. static DATASOURCE_MULTIRENDERTARGET: number;
  28698. /**
  28699. * Texture data comes from a cube data file
  28700. */
  28701. static DATASOURCE_CUBE: number;
  28702. /**
  28703. * Texture data comes from a raw cube data
  28704. */
  28705. static DATASOURCE_CUBERAW: number;
  28706. /**
  28707. * Texture data come from a prefiltered cube data file
  28708. */
  28709. static DATASOURCE_CUBEPREFILTERED: number;
  28710. /**
  28711. * Texture content is raw 3D data
  28712. */
  28713. static DATASOURCE_RAW3D: number;
  28714. /**
  28715. * Texture content is a depth texture
  28716. */
  28717. static DATASOURCE_DEPTHTEXTURE: number;
  28718. /**
  28719. * Texture data comes from a raw cube data encoded with RGBD
  28720. */
  28721. static DATASOURCE_CUBERAW_RGBD: number;
  28722. /**
  28723. * Defines if the texture is ready
  28724. */
  28725. isReady: boolean;
  28726. /**
  28727. * Defines if the texture is a cube texture
  28728. */
  28729. isCube: boolean;
  28730. /**
  28731. * Defines if the texture contains 3D data
  28732. */
  28733. is3D: boolean;
  28734. /**
  28735. * Defines if the texture contains multiview data
  28736. */
  28737. isMultiview: boolean;
  28738. /**
  28739. * Gets the URL used to load this texture
  28740. */
  28741. url: string;
  28742. /**
  28743. * Gets the sampling mode of the texture
  28744. */
  28745. samplingMode: number;
  28746. /**
  28747. * Gets a boolean indicating if the texture needs mipmaps generation
  28748. */
  28749. generateMipMaps: boolean;
  28750. /**
  28751. * Gets the number of samples used by the texture (WebGL2+ only)
  28752. */
  28753. samples: number;
  28754. /**
  28755. * Gets the type of the texture (int, float...)
  28756. */
  28757. type: number;
  28758. /**
  28759. * Gets the format of the texture (RGB, RGBA...)
  28760. */
  28761. format: number;
  28762. /**
  28763. * Observable called when the texture is loaded
  28764. */
  28765. onLoadedObservable: Observable<InternalTexture>;
  28766. /**
  28767. * Gets the width of the texture
  28768. */
  28769. width: number;
  28770. /**
  28771. * Gets the height of the texture
  28772. */
  28773. height: number;
  28774. /**
  28775. * Gets the depth of the texture
  28776. */
  28777. depth: number;
  28778. /**
  28779. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28780. */
  28781. baseWidth: number;
  28782. /**
  28783. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28784. */
  28785. baseHeight: number;
  28786. /**
  28787. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28788. */
  28789. baseDepth: number;
  28790. /**
  28791. * Gets a boolean indicating if the texture is inverted on Y axis
  28792. */
  28793. invertY: boolean;
  28794. /** @hidden */
  28795. _invertVScale: boolean;
  28796. /** @hidden */
  28797. _associatedChannel: number;
  28798. /** @hidden */
  28799. _dataSource: number;
  28800. /** @hidden */
  28801. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28802. /** @hidden */
  28803. _bufferView: Nullable<ArrayBufferView>;
  28804. /** @hidden */
  28805. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28806. /** @hidden */
  28807. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28808. /** @hidden */
  28809. _size: number;
  28810. /** @hidden */
  28811. _extension: string;
  28812. /** @hidden */
  28813. _files: Nullable<string[]>;
  28814. /** @hidden */
  28815. _workingCanvas: Nullable<HTMLCanvasElement>;
  28816. /** @hidden */
  28817. _workingContext: Nullable<CanvasRenderingContext2D>;
  28818. /** @hidden */
  28819. _framebuffer: Nullable<WebGLFramebuffer>;
  28820. /** @hidden */
  28821. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28822. /** @hidden */
  28823. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28824. /** @hidden */
  28825. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28826. /** @hidden */
  28827. _attachments: Nullable<number[]>;
  28828. /** @hidden */
  28829. _cachedCoordinatesMode: Nullable<number>;
  28830. /** @hidden */
  28831. _cachedWrapU: Nullable<number>;
  28832. /** @hidden */
  28833. _cachedWrapV: Nullable<number>;
  28834. /** @hidden */
  28835. _cachedWrapR: Nullable<number>;
  28836. /** @hidden */
  28837. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28838. /** @hidden */
  28839. _isDisabled: boolean;
  28840. /** @hidden */
  28841. _compression: Nullable<string>;
  28842. /** @hidden */
  28843. _generateStencilBuffer: boolean;
  28844. /** @hidden */
  28845. _generateDepthBuffer: boolean;
  28846. /** @hidden */
  28847. _comparisonFunction: number;
  28848. /** @hidden */
  28849. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28850. /** @hidden */
  28851. _lodGenerationScale: number;
  28852. /** @hidden */
  28853. _lodGenerationOffset: number;
  28854. /** @hidden */
  28855. _colorTextureArray: Nullable<WebGLTexture>;
  28856. /** @hidden */
  28857. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28858. /** @hidden */
  28859. _lodTextureHigh: Nullable<BaseTexture>;
  28860. /** @hidden */
  28861. _lodTextureMid: Nullable<BaseTexture>;
  28862. /** @hidden */
  28863. _lodTextureLow: Nullable<BaseTexture>;
  28864. /** @hidden */
  28865. _isRGBD: boolean;
  28866. /** @hidden */
  28867. _linearSpecularLOD: boolean;
  28868. /** @hidden */
  28869. _irradianceTexture: Nullable<BaseTexture>;
  28870. /** @hidden */
  28871. _webGLTexture: Nullable<WebGLTexture>;
  28872. /** @hidden */
  28873. _references: number;
  28874. private _engine;
  28875. /**
  28876. * Gets the Engine the texture belongs to.
  28877. * @returns The babylon engine
  28878. */
  28879. getEngine(): Engine;
  28880. /**
  28881. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28882. */
  28883. readonly dataSource: number;
  28884. /**
  28885. * Creates a new InternalTexture
  28886. * @param engine defines the engine to use
  28887. * @param dataSource defines the type of data that will be used
  28888. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28889. */
  28890. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28891. /**
  28892. * Increments the number of references (ie. the number of Texture that point to it)
  28893. */
  28894. incrementReferences(): void;
  28895. /**
  28896. * Change the size of the texture (not the size of the content)
  28897. * @param width defines the new width
  28898. * @param height defines the new height
  28899. * @param depth defines the new depth (1 by default)
  28900. */
  28901. updateSize(width: int, height: int, depth?: int): void;
  28902. /** @hidden */
  28903. _rebuild(): void;
  28904. /** @hidden */
  28905. _swapAndDie(target: InternalTexture): void;
  28906. /**
  28907. * Dispose the current allocated resources
  28908. */
  28909. dispose(): void;
  28910. }
  28911. }
  28912. declare module "babylonjs/Materials/effect" {
  28913. import { Observable } from "babylonjs/Misc/observable";
  28914. import { Nullable } from "babylonjs/types";
  28915. import { IDisposable } from "babylonjs/scene";
  28916. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28917. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28918. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28919. import { Engine } from "babylonjs/Engines/engine";
  28920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28923. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28925. /**
  28926. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28927. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28928. */
  28929. export class EffectFallbacks {
  28930. private _defines;
  28931. private _currentRank;
  28932. private _maxRank;
  28933. private _mesh;
  28934. /**
  28935. * Removes the fallback from the bound mesh.
  28936. */
  28937. unBindMesh(): void;
  28938. /**
  28939. * Adds a fallback on the specified property.
  28940. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28941. * @param define The name of the define in the shader
  28942. */
  28943. addFallback(rank: number, define: string): void;
  28944. /**
  28945. * Sets the mesh to use CPU skinning when needing to fallback.
  28946. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28947. * @param mesh The mesh to use the fallbacks.
  28948. */
  28949. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28950. /**
  28951. * Checks to see if more fallbacks are still availible.
  28952. */
  28953. readonly isMoreFallbacks: boolean;
  28954. /**
  28955. * Removes the defines that should be removed when falling back.
  28956. * @param currentDefines defines the current define statements for the shader.
  28957. * @param effect defines the current effect we try to compile
  28958. * @returns The resulting defines with defines of the current rank removed.
  28959. */
  28960. reduce(currentDefines: string, effect: Effect): string;
  28961. }
  28962. /**
  28963. * Options to be used when creating an effect.
  28964. */
  28965. export class EffectCreationOptions {
  28966. /**
  28967. * Atrributes that will be used in the shader.
  28968. */
  28969. attributes: string[];
  28970. /**
  28971. * Uniform varible names that will be set in the shader.
  28972. */
  28973. uniformsNames: string[];
  28974. /**
  28975. * Uniform buffer varible names that will be set in the shader.
  28976. */
  28977. uniformBuffersNames: string[];
  28978. /**
  28979. * Sampler texture variable names that will be set in the shader.
  28980. */
  28981. samplers: string[];
  28982. /**
  28983. * Define statements that will be set in the shader.
  28984. */
  28985. defines: any;
  28986. /**
  28987. * Possible fallbacks for this effect to improve performance when needed.
  28988. */
  28989. fallbacks: Nullable<EffectFallbacks>;
  28990. /**
  28991. * Callback that will be called when the shader is compiled.
  28992. */
  28993. onCompiled: Nullable<(effect: Effect) => void>;
  28994. /**
  28995. * Callback that will be called if an error occurs during shader compilation.
  28996. */
  28997. onError: Nullable<(effect: Effect, errors: string) => void>;
  28998. /**
  28999. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29000. */
  29001. indexParameters: any;
  29002. /**
  29003. * Max number of lights that can be used in the shader.
  29004. */
  29005. maxSimultaneousLights: number;
  29006. /**
  29007. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29008. */
  29009. transformFeedbackVaryings: Nullable<string[]>;
  29010. }
  29011. /**
  29012. * Effect containing vertex and fragment shader that can be executed on an object.
  29013. */
  29014. export class Effect implements IDisposable {
  29015. /**
  29016. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29017. */
  29018. static ShadersRepository: string;
  29019. /**
  29020. * Name of the effect.
  29021. */
  29022. name: any;
  29023. /**
  29024. * String container all the define statements that should be set on the shader.
  29025. */
  29026. defines: string;
  29027. /**
  29028. * Callback that will be called when the shader is compiled.
  29029. */
  29030. onCompiled: Nullable<(effect: Effect) => void>;
  29031. /**
  29032. * Callback that will be called if an error occurs during shader compilation.
  29033. */
  29034. onError: Nullable<(effect: Effect, errors: string) => void>;
  29035. /**
  29036. * Callback that will be called when effect is bound.
  29037. */
  29038. onBind: Nullable<(effect: Effect) => void>;
  29039. /**
  29040. * Unique ID of the effect.
  29041. */
  29042. uniqueId: number;
  29043. /**
  29044. * Observable that will be called when the shader is compiled.
  29045. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29046. */
  29047. onCompileObservable: Observable<Effect>;
  29048. /**
  29049. * Observable that will be called if an error occurs during shader compilation.
  29050. */
  29051. onErrorObservable: Observable<Effect>;
  29052. /** @hidden */
  29053. _onBindObservable: Nullable<Observable<Effect>>;
  29054. /**
  29055. * Observable that will be called when effect is bound.
  29056. */
  29057. readonly onBindObservable: Observable<Effect>;
  29058. /** @hidden */
  29059. _bonesComputationForcedToCPU: boolean;
  29060. private static _uniqueIdSeed;
  29061. private _engine;
  29062. private _uniformBuffersNames;
  29063. private _uniformsNames;
  29064. private _samplerList;
  29065. private _samplers;
  29066. private _isReady;
  29067. private _compilationError;
  29068. private _attributesNames;
  29069. private _attributes;
  29070. private _uniforms;
  29071. /**
  29072. * Key for the effect.
  29073. * @hidden
  29074. */
  29075. _key: string;
  29076. private _indexParameters;
  29077. private _fallbacks;
  29078. private _vertexSourceCode;
  29079. private _fragmentSourceCode;
  29080. private _vertexSourceCodeOverride;
  29081. private _fragmentSourceCodeOverride;
  29082. private _transformFeedbackVaryings;
  29083. /**
  29084. * Compiled shader to webGL program.
  29085. * @hidden
  29086. */
  29087. _pipelineContext: Nullable<IPipelineContext>;
  29088. private _valueCache;
  29089. private static _baseCache;
  29090. /**
  29091. * Instantiates an effect.
  29092. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29093. * @param baseName Name of the effect.
  29094. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29095. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29096. * @param samplers List of sampler variables that will be passed to the shader.
  29097. * @param engine Engine to be used to render the effect
  29098. * @param defines Define statements to be added to the shader.
  29099. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29100. * @param onCompiled Callback that will be called when the shader is compiled.
  29101. * @param onError Callback that will be called if an error occurs during shader compilation.
  29102. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29103. */
  29104. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29105. private _useFinalCode;
  29106. /**
  29107. * Unique key for this effect
  29108. */
  29109. readonly key: string;
  29110. /**
  29111. * If the effect has been compiled and prepared.
  29112. * @returns if the effect is compiled and prepared.
  29113. */
  29114. isReady(): boolean;
  29115. /**
  29116. * The engine the effect was initialized with.
  29117. * @returns the engine.
  29118. */
  29119. getEngine(): Engine;
  29120. /**
  29121. * The pipeline context for this effect
  29122. * @returns the associated pipeline context
  29123. */
  29124. getPipelineContext(): Nullable<IPipelineContext>;
  29125. /**
  29126. * The set of names of attribute variables for the shader.
  29127. * @returns An array of attribute names.
  29128. */
  29129. getAttributesNames(): string[];
  29130. /**
  29131. * Returns the attribute at the given index.
  29132. * @param index The index of the attribute.
  29133. * @returns The location of the attribute.
  29134. */
  29135. getAttributeLocation(index: number): number;
  29136. /**
  29137. * Returns the attribute based on the name of the variable.
  29138. * @param name of the attribute to look up.
  29139. * @returns the attribute location.
  29140. */
  29141. getAttributeLocationByName(name: string): number;
  29142. /**
  29143. * The number of attributes.
  29144. * @returns the numnber of attributes.
  29145. */
  29146. getAttributesCount(): number;
  29147. /**
  29148. * Gets the index of a uniform variable.
  29149. * @param uniformName of the uniform to look up.
  29150. * @returns the index.
  29151. */
  29152. getUniformIndex(uniformName: string): number;
  29153. /**
  29154. * Returns the attribute based on the name of the variable.
  29155. * @param uniformName of the uniform to look up.
  29156. * @returns the location of the uniform.
  29157. */
  29158. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29159. /**
  29160. * Returns an array of sampler variable names
  29161. * @returns The array of sampler variable neames.
  29162. */
  29163. getSamplers(): string[];
  29164. /**
  29165. * The error from the last compilation.
  29166. * @returns the error string.
  29167. */
  29168. getCompilationError(): string;
  29169. /**
  29170. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29171. * @param func The callback to be used.
  29172. */
  29173. executeWhenCompiled(func: (effect: Effect) => void): void;
  29174. private _checkIsReady;
  29175. /** @hidden */
  29176. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29177. /** @hidden */
  29178. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29179. /** @hidden */
  29180. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29181. /**
  29182. * Recompiles the webGL program
  29183. * @param vertexSourceCode The source code for the vertex shader.
  29184. * @param fragmentSourceCode The source code for the fragment shader.
  29185. * @param onCompiled Callback called when completed.
  29186. * @param onError Callback called on error.
  29187. * @hidden
  29188. */
  29189. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29190. /**
  29191. * Prepares the effect
  29192. * @hidden
  29193. */
  29194. _prepareEffect(): void;
  29195. /**
  29196. * Checks if the effect is supported. (Must be called after compilation)
  29197. */
  29198. readonly isSupported: boolean;
  29199. /**
  29200. * Binds a texture to the engine to be used as output of the shader.
  29201. * @param channel Name of the output variable.
  29202. * @param texture Texture to bind.
  29203. * @hidden
  29204. */
  29205. _bindTexture(channel: string, texture: InternalTexture): void;
  29206. /**
  29207. * Sets a texture on the engine to be used in the shader.
  29208. * @param channel Name of the sampler variable.
  29209. * @param texture Texture to set.
  29210. */
  29211. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29212. /**
  29213. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29214. * @param channel Name of the sampler variable.
  29215. * @param texture Texture to set.
  29216. */
  29217. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29218. /**
  29219. * Sets an array of textures on the engine to be used in the shader.
  29220. * @param channel Name of the variable.
  29221. * @param textures Textures to set.
  29222. */
  29223. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29224. /**
  29225. * 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)
  29226. * @param channel Name of the sampler variable.
  29227. * @param postProcess Post process to get the input texture from.
  29228. */
  29229. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29230. /**
  29231. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29232. * 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)
  29233. * @param channel Name of the sampler variable.
  29234. * @param postProcess Post process to get the output texture from.
  29235. */
  29236. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29237. /** @hidden */
  29238. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29239. /** @hidden */
  29240. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29241. /** @hidden */
  29242. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29243. /** @hidden */
  29244. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29245. /**
  29246. * Binds a buffer to a uniform.
  29247. * @param buffer Buffer to bind.
  29248. * @param name Name of the uniform variable to bind to.
  29249. */
  29250. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29251. /**
  29252. * Binds block to a uniform.
  29253. * @param blockName Name of the block to bind.
  29254. * @param index Index to bind.
  29255. */
  29256. bindUniformBlock(blockName: string, index: number): void;
  29257. /**
  29258. * Sets an interger value on a uniform variable.
  29259. * @param uniformName Name of the variable.
  29260. * @param value Value to be set.
  29261. * @returns this effect.
  29262. */
  29263. setInt(uniformName: string, value: number): Effect;
  29264. /**
  29265. * Sets an int array on a uniform variable.
  29266. * @param uniformName Name of the variable.
  29267. * @param array array to be set.
  29268. * @returns this effect.
  29269. */
  29270. setIntArray(uniformName: string, array: Int32Array): Effect;
  29271. /**
  29272. * 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)
  29273. * @param uniformName Name of the variable.
  29274. * @param array array to be set.
  29275. * @returns this effect.
  29276. */
  29277. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29278. /**
  29279. * 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)
  29280. * @param uniformName Name of the variable.
  29281. * @param array array to be set.
  29282. * @returns this effect.
  29283. */
  29284. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29285. /**
  29286. * 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)
  29287. * @param uniformName Name of the variable.
  29288. * @param array array to be set.
  29289. * @returns this effect.
  29290. */
  29291. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29292. /**
  29293. * Sets an float array on a uniform variable.
  29294. * @param uniformName Name of the variable.
  29295. * @param array array to be set.
  29296. * @returns this effect.
  29297. */
  29298. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29299. /**
  29300. * 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)
  29301. * @param uniformName Name of the variable.
  29302. * @param array array to be set.
  29303. * @returns this effect.
  29304. */
  29305. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29306. /**
  29307. * 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)
  29308. * @param uniformName Name of the variable.
  29309. * @param array array to be set.
  29310. * @returns this effect.
  29311. */
  29312. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29313. /**
  29314. * 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)
  29315. * @param uniformName Name of the variable.
  29316. * @param array array to be set.
  29317. * @returns this effect.
  29318. */
  29319. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29320. /**
  29321. * Sets an array on a uniform variable.
  29322. * @param uniformName Name of the variable.
  29323. * @param array array to be set.
  29324. * @returns this effect.
  29325. */
  29326. setArray(uniformName: string, array: number[]): Effect;
  29327. /**
  29328. * 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)
  29329. * @param uniformName Name of the variable.
  29330. * @param array array to be set.
  29331. * @returns this effect.
  29332. */
  29333. setArray2(uniformName: string, array: number[]): Effect;
  29334. /**
  29335. * 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)
  29336. * @param uniformName Name of the variable.
  29337. * @param array array to be set.
  29338. * @returns this effect.
  29339. */
  29340. setArray3(uniformName: string, array: number[]): Effect;
  29341. /**
  29342. * 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)
  29343. * @param uniformName Name of the variable.
  29344. * @param array array to be set.
  29345. * @returns this effect.
  29346. */
  29347. setArray4(uniformName: string, array: number[]): Effect;
  29348. /**
  29349. * Sets matrices on a uniform variable.
  29350. * @param uniformName Name of the variable.
  29351. * @param matrices matrices to be set.
  29352. * @returns this effect.
  29353. */
  29354. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29355. /**
  29356. * Sets matrix on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param matrix matrix to be set.
  29359. * @returns this effect.
  29360. */
  29361. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29362. /**
  29363. * 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)
  29364. * @param uniformName Name of the variable.
  29365. * @param matrix matrix to be set.
  29366. * @returns this effect.
  29367. */
  29368. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29369. /**
  29370. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29371. * @param uniformName Name of the variable.
  29372. * @param matrix matrix to be set.
  29373. * @returns this effect.
  29374. */
  29375. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29376. /**
  29377. * Sets a float on a uniform variable.
  29378. * @param uniformName Name of the variable.
  29379. * @param value value to be set.
  29380. * @returns this effect.
  29381. */
  29382. setFloat(uniformName: string, value: number): Effect;
  29383. /**
  29384. * Sets a boolean on a uniform variable.
  29385. * @param uniformName Name of the variable.
  29386. * @param bool value to be set.
  29387. * @returns this effect.
  29388. */
  29389. setBool(uniformName: string, bool: boolean): Effect;
  29390. /**
  29391. * Sets a Vector2 on a uniform variable.
  29392. * @param uniformName Name of the variable.
  29393. * @param vector2 vector2 to be set.
  29394. * @returns this effect.
  29395. */
  29396. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29397. /**
  29398. * Sets a float2 on a uniform variable.
  29399. * @param uniformName Name of the variable.
  29400. * @param x First float in float2.
  29401. * @param y Second float in float2.
  29402. * @returns this effect.
  29403. */
  29404. setFloat2(uniformName: string, x: number, y: number): Effect;
  29405. /**
  29406. * Sets a Vector3 on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param vector3 Value to be set.
  29409. * @returns this effect.
  29410. */
  29411. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29412. /**
  29413. * Sets a float3 on a uniform variable.
  29414. * @param uniformName Name of the variable.
  29415. * @param x First float in float3.
  29416. * @param y Second float in float3.
  29417. * @param z Third float in float3.
  29418. * @returns this effect.
  29419. */
  29420. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29421. /**
  29422. * Sets a Vector4 on a uniform variable.
  29423. * @param uniformName Name of the variable.
  29424. * @param vector4 Value to be set.
  29425. * @returns this effect.
  29426. */
  29427. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29428. /**
  29429. * Sets a float4 on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param x First float in float4.
  29432. * @param y Second float in float4.
  29433. * @param z Third float in float4.
  29434. * @param w Fourth float in float4.
  29435. * @returns this effect.
  29436. */
  29437. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29438. /**
  29439. * Sets a Color3 on a uniform variable.
  29440. * @param uniformName Name of the variable.
  29441. * @param color3 Value to be set.
  29442. * @returns this effect.
  29443. */
  29444. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29445. /**
  29446. * Sets a Color4 on a uniform variable.
  29447. * @param uniformName Name of the variable.
  29448. * @param color3 Value to be set.
  29449. * @param alpha Alpha value to be set.
  29450. * @returns this effect.
  29451. */
  29452. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29453. /**
  29454. * Sets a Color4 on a uniform variable
  29455. * @param uniformName defines the name of the variable
  29456. * @param color4 defines the value to be set
  29457. * @returns this effect.
  29458. */
  29459. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29460. /** Release all associated resources */
  29461. dispose(): void;
  29462. /**
  29463. * This function will add a new shader to the shader store
  29464. * @param name the name of the shader
  29465. * @param pixelShader optional pixel shader content
  29466. * @param vertexShader optional vertex shader content
  29467. */
  29468. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29469. /**
  29470. * Store of each shader (The can be looked up using effect.key)
  29471. */
  29472. static ShadersStore: {
  29473. [key: string]: string;
  29474. };
  29475. /**
  29476. * Store of each included file for a shader (The can be looked up using effect.key)
  29477. */
  29478. static IncludesShadersStore: {
  29479. [key: string]: string;
  29480. };
  29481. /**
  29482. * Resets the cache of effects.
  29483. */
  29484. static ResetCache(): void;
  29485. }
  29486. }
  29487. declare module "babylonjs/Materials/uniformBuffer" {
  29488. import { Nullable, FloatArray } from "babylonjs/types";
  29489. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29490. import { Engine } from "babylonjs/Engines/engine";
  29491. import { Effect } from "babylonjs/Materials/effect";
  29492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29494. import { Color3 } from "babylonjs/Maths/math.color";
  29495. /**
  29496. * Uniform buffer objects.
  29497. *
  29498. * Handles blocks of uniform on the GPU.
  29499. *
  29500. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29501. *
  29502. * For more information, please refer to :
  29503. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29504. */
  29505. export class UniformBuffer {
  29506. private _engine;
  29507. private _buffer;
  29508. private _data;
  29509. private _bufferData;
  29510. private _dynamic?;
  29511. private _uniformLocations;
  29512. private _uniformSizes;
  29513. private _uniformLocationPointer;
  29514. private _needSync;
  29515. private _noUBO;
  29516. private _currentEffect;
  29517. private static _MAX_UNIFORM_SIZE;
  29518. private static _tempBuffer;
  29519. /**
  29520. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29521. * This is dynamic to allow compat with webgl 1 and 2.
  29522. * You will need to pass the name of the uniform as well as the value.
  29523. */
  29524. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29525. /**
  29526. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29527. * This is dynamic to allow compat with webgl 1 and 2.
  29528. * You will need to pass the name of the uniform as well as the value.
  29529. */
  29530. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29531. /**
  29532. * Lambda to Update a single float in a uniform buffer.
  29533. * This is dynamic to allow compat with webgl 1 and 2.
  29534. * You will need to pass the name of the uniform as well as the value.
  29535. */
  29536. updateFloat: (name: string, x: number) => void;
  29537. /**
  29538. * Lambda to Update a vec2 of float in a uniform buffer.
  29539. * This is dynamic to allow compat with webgl 1 and 2.
  29540. * You will need to pass the name of the uniform as well as the value.
  29541. */
  29542. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29543. /**
  29544. * Lambda to Update a vec3 of float in a uniform buffer.
  29545. * This is dynamic to allow compat with webgl 1 and 2.
  29546. * You will need to pass the name of the uniform as well as the value.
  29547. */
  29548. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29549. /**
  29550. * Lambda to Update a vec4 of float in a uniform buffer.
  29551. * This is dynamic to allow compat with webgl 1 and 2.
  29552. * You will need to pass the name of the uniform as well as the value.
  29553. */
  29554. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29555. /**
  29556. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29557. * This is dynamic to allow compat with webgl 1 and 2.
  29558. * You will need to pass the name of the uniform as well as the value.
  29559. */
  29560. updateMatrix: (name: string, mat: Matrix) => void;
  29561. /**
  29562. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29563. * This is dynamic to allow compat with webgl 1 and 2.
  29564. * You will need to pass the name of the uniform as well as the value.
  29565. */
  29566. updateVector3: (name: string, vector: Vector3) => void;
  29567. /**
  29568. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29569. * This is dynamic to allow compat with webgl 1 and 2.
  29570. * You will need to pass the name of the uniform as well as the value.
  29571. */
  29572. updateVector4: (name: string, vector: Vector4) => void;
  29573. /**
  29574. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29575. * This is dynamic to allow compat with webgl 1 and 2.
  29576. * You will need to pass the name of the uniform as well as the value.
  29577. */
  29578. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29579. /**
  29580. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29581. * This is dynamic to allow compat with webgl 1 and 2.
  29582. * You will need to pass the name of the uniform as well as the value.
  29583. */
  29584. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29585. /**
  29586. * Instantiates a new Uniform buffer objects.
  29587. *
  29588. * Handles blocks of uniform on the GPU.
  29589. *
  29590. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29591. *
  29592. * For more information, please refer to :
  29593. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29594. * @param engine Define the engine the buffer is associated with
  29595. * @param data Define the data contained in the buffer
  29596. * @param dynamic Define if the buffer is updatable
  29597. */
  29598. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29599. /**
  29600. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29601. * or just falling back on setUniformXXX calls.
  29602. */
  29603. readonly useUbo: boolean;
  29604. /**
  29605. * Indicates if the WebGL underlying uniform buffer is in sync
  29606. * with the javascript cache data.
  29607. */
  29608. readonly isSync: boolean;
  29609. /**
  29610. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29611. * Also, a dynamic UniformBuffer will disable cache verification and always
  29612. * update the underlying WebGL uniform buffer to the GPU.
  29613. * @returns if Dynamic, otherwise false
  29614. */
  29615. isDynamic(): boolean;
  29616. /**
  29617. * The data cache on JS side.
  29618. * @returns the underlying data as a float array
  29619. */
  29620. getData(): Float32Array;
  29621. /**
  29622. * The underlying WebGL Uniform buffer.
  29623. * @returns the webgl buffer
  29624. */
  29625. getBuffer(): Nullable<DataBuffer>;
  29626. /**
  29627. * std140 layout specifies how to align data within an UBO structure.
  29628. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29629. * for specs.
  29630. */
  29631. private _fillAlignment;
  29632. /**
  29633. * Adds an uniform in the buffer.
  29634. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29635. * for the layout to be correct !
  29636. * @param name Name of the uniform, as used in the uniform block in the shader.
  29637. * @param size Data size, or data directly.
  29638. */
  29639. addUniform(name: string, size: number | number[]): void;
  29640. /**
  29641. * Adds a Matrix 4x4 to the uniform buffer.
  29642. * @param name Name of the uniform, as used in the uniform block in the shader.
  29643. * @param mat A 4x4 matrix.
  29644. */
  29645. addMatrix(name: string, mat: Matrix): void;
  29646. /**
  29647. * Adds a vec2 to the uniform buffer.
  29648. * @param name Name of the uniform, as used in the uniform block in the shader.
  29649. * @param x Define the x component value of the vec2
  29650. * @param y Define the y component value of the vec2
  29651. */
  29652. addFloat2(name: string, x: number, y: number): void;
  29653. /**
  29654. * Adds a vec3 to the uniform buffer.
  29655. * @param name Name of the uniform, as used in the uniform block in the shader.
  29656. * @param x Define the x component value of the vec3
  29657. * @param y Define the y component value of the vec3
  29658. * @param z Define the z component value of the vec3
  29659. */
  29660. addFloat3(name: string, x: number, y: number, z: number): void;
  29661. /**
  29662. * Adds a vec3 to the uniform buffer.
  29663. * @param name Name of the uniform, as used in the uniform block in the shader.
  29664. * @param color Define the vec3 from a Color
  29665. */
  29666. addColor3(name: string, color: Color3): void;
  29667. /**
  29668. * Adds a vec4 to the uniform buffer.
  29669. * @param name Name of the uniform, as used in the uniform block in the shader.
  29670. * @param color Define the rgb components from a Color
  29671. * @param alpha Define the a component of the vec4
  29672. */
  29673. addColor4(name: string, color: Color3, alpha: number): void;
  29674. /**
  29675. * Adds a vec3 to the uniform buffer.
  29676. * @param name Name of the uniform, as used in the uniform block in the shader.
  29677. * @param vector Define the vec3 components from a Vector
  29678. */
  29679. addVector3(name: string, vector: Vector3): void;
  29680. /**
  29681. * Adds a Matrix 3x3 to the uniform buffer.
  29682. * @param name Name of the uniform, as used in the uniform block in the shader.
  29683. */
  29684. addMatrix3x3(name: string): void;
  29685. /**
  29686. * Adds a Matrix 2x2 to the uniform buffer.
  29687. * @param name Name of the uniform, as used in the uniform block in the shader.
  29688. */
  29689. addMatrix2x2(name: string): void;
  29690. /**
  29691. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29692. */
  29693. create(): void;
  29694. /** @hidden */
  29695. _rebuild(): void;
  29696. /**
  29697. * Updates the WebGL Uniform Buffer on the GPU.
  29698. * If the `dynamic` flag is set to true, no cache comparison is done.
  29699. * Otherwise, the buffer will be updated only if the cache differs.
  29700. */
  29701. update(): void;
  29702. /**
  29703. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29704. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29705. * @param data Define the flattened data
  29706. * @param size Define the size of the data.
  29707. */
  29708. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29709. private _updateMatrix3x3ForUniform;
  29710. private _updateMatrix3x3ForEffect;
  29711. private _updateMatrix2x2ForEffect;
  29712. private _updateMatrix2x2ForUniform;
  29713. private _updateFloatForEffect;
  29714. private _updateFloatForUniform;
  29715. private _updateFloat2ForEffect;
  29716. private _updateFloat2ForUniform;
  29717. private _updateFloat3ForEffect;
  29718. private _updateFloat3ForUniform;
  29719. private _updateFloat4ForEffect;
  29720. private _updateFloat4ForUniform;
  29721. private _updateMatrixForEffect;
  29722. private _updateMatrixForUniform;
  29723. private _updateVector3ForEffect;
  29724. private _updateVector3ForUniform;
  29725. private _updateVector4ForEffect;
  29726. private _updateVector4ForUniform;
  29727. private _updateColor3ForEffect;
  29728. private _updateColor3ForUniform;
  29729. private _updateColor4ForEffect;
  29730. private _updateColor4ForUniform;
  29731. /**
  29732. * Sets a sampler uniform on the effect.
  29733. * @param name Define the name of the sampler.
  29734. * @param texture Define the texture to set in the sampler
  29735. */
  29736. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29737. /**
  29738. * Directly updates the value of the uniform in the cache AND on the GPU.
  29739. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29740. * @param data Define the flattened data
  29741. */
  29742. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29743. /**
  29744. * Binds this uniform buffer to an effect.
  29745. * @param effect Define the effect to bind the buffer to
  29746. * @param name Name of the uniform block in the shader.
  29747. */
  29748. bindToEffect(effect: Effect, name: string): void;
  29749. /**
  29750. * Disposes the uniform buffer.
  29751. */
  29752. dispose(): void;
  29753. }
  29754. }
  29755. declare module "babylonjs/Audio/analyser" {
  29756. import { Scene } from "babylonjs/scene";
  29757. /**
  29758. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29760. */
  29761. export class Analyser {
  29762. /**
  29763. * Gets or sets the smoothing
  29764. * @ignorenaming
  29765. */
  29766. SMOOTHING: number;
  29767. /**
  29768. * Gets or sets the FFT table size
  29769. * @ignorenaming
  29770. */
  29771. FFT_SIZE: number;
  29772. /**
  29773. * Gets or sets the bar graph amplitude
  29774. * @ignorenaming
  29775. */
  29776. BARGRAPHAMPLITUDE: number;
  29777. /**
  29778. * Gets or sets the position of the debug canvas
  29779. * @ignorenaming
  29780. */
  29781. DEBUGCANVASPOS: {
  29782. x: number;
  29783. y: number;
  29784. };
  29785. /**
  29786. * Gets or sets the debug canvas size
  29787. * @ignorenaming
  29788. */
  29789. DEBUGCANVASSIZE: {
  29790. width: number;
  29791. height: number;
  29792. };
  29793. private _byteFreqs;
  29794. private _byteTime;
  29795. private _floatFreqs;
  29796. private _webAudioAnalyser;
  29797. private _debugCanvas;
  29798. private _debugCanvasContext;
  29799. private _scene;
  29800. private _registerFunc;
  29801. private _audioEngine;
  29802. /**
  29803. * Creates a new analyser
  29804. * @param scene defines hosting scene
  29805. */
  29806. constructor(scene: Scene);
  29807. /**
  29808. * Get the number of data values you will have to play with for the visualization
  29809. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29810. * @returns a number
  29811. */
  29812. getFrequencyBinCount(): number;
  29813. /**
  29814. * Gets the current frequency data as a byte array
  29815. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29816. * @returns a Uint8Array
  29817. */
  29818. getByteFrequencyData(): Uint8Array;
  29819. /**
  29820. * Gets the current waveform as a byte array
  29821. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29822. * @returns a Uint8Array
  29823. */
  29824. getByteTimeDomainData(): Uint8Array;
  29825. /**
  29826. * Gets the current frequency data as a float array
  29827. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29828. * @returns a Float32Array
  29829. */
  29830. getFloatFrequencyData(): Float32Array;
  29831. /**
  29832. * Renders the debug canvas
  29833. */
  29834. drawDebugCanvas(): void;
  29835. /**
  29836. * Stops rendering the debug canvas and removes it
  29837. */
  29838. stopDebugCanvas(): void;
  29839. /**
  29840. * Connects two audio nodes
  29841. * @param inputAudioNode defines first node to connect
  29842. * @param outputAudioNode defines second node to connect
  29843. */
  29844. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29845. /**
  29846. * Releases all associated resources
  29847. */
  29848. dispose(): void;
  29849. }
  29850. }
  29851. declare module "babylonjs/Audio/audioEngine" {
  29852. import { IDisposable } from "babylonjs/scene";
  29853. import { Analyser } from "babylonjs/Audio/analyser";
  29854. import { Nullable } from "babylonjs/types";
  29855. import { Observable } from "babylonjs/Misc/observable";
  29856. /**
  29857. * This represents an audio engine and it is responsible
  29858. * to play, synchronize and analyse sounds throughout the application.
  29859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29860. */
  29861. export interface IAudioEngine extends IDisposable {
  29862. /**
  29863. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29864. */
  29865. readonly canUseWebAudio: boolean;
  29866. /**
  29867. * Gets the current AudioContext if available.
  29868. */
  29869. readonly audioContext: Nullable<AudioContext>;
  29870. /**
  29871. * The master gain node defines the global audio volume of your audio engine.
  29872. */
  29873. readonly masterGain: GainNode;
  29874. /**
  29875. * Gets whether or not mp3 are supported by your browser.
  29876. */
  29877. readonly isMP3supported: boolean;
  29878. /**
  29879. * Gets whether or not ogg are supported by your browser.
  29880. */
  29881. readonly isOGGsupported: boolean;
  29882. /**
  29883. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29884. * @ignoreNaming
  29885. */
  29886. WarnedWebAudioUnsupported: boolean;
  29887. /**
  29888. * Defines if the audio engine relies on a custom unlocked button.
  29889. * In this case, the embedded button will not be displayed.
  29890. */
  29891. useCustomUnlockedButton: boolean;
  29892. /**
  29893. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29894. */
  29895. readonly unlocked: boolean;
  29896. /**
  29897. * Event raised when audio has been unlocked on the browser.
  29898. */
  29899. onAudioUnlockedObservable: Observable<AudioEngine>;
  29900. /**
  29901. * Event raised when audio has been locked on the browser.
  29902. */
  29903. onAudioLockedObservable: Observable<AudioEngine>;
  29904. /**
  29905. * Flags the audio engine in Locked state.
  29906. * This happens due to new browser policies preventing audio to autoplay.
  29907. */
  29908. lock(): void;
  29909. /**
  29910. * Unlocks the audio engine once a user action has been done on the dom.
  29911. * This is helpful to resume play once browser policies have been satisfied.
  29912. */
  29913. unlock(): void;
  29914. }
  29915. /**
  29916. * This represents the default audio engine used in babylon.
  29917. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29919. */
  29920. export class AudioEngine implements IAudioEngine {
  29921. private _audioContext;
  29922. private _audioContextInitialized;
  29923. private _muteButton;
  29924. private _hostElement;
  29925. /**
  29926. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29927. */
  29928. canUseWebAudio: boolean;
  29929. /**
  29930. * The master gain node defines the global audio volume of your audio engine.
  29931. */
  29932. masterGain: GainNode;
  29933. /**
  29934. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29935. * @ignoreNaming
  29936. */
  29937. WarnedWebAudioUnsupported: boolean;
  29938. /**
  29939. * Gets whether or not mp3 are supported by your browser.
  29940. */
  29941. isMP3supported: boolean;
  29942. /**
  29943. * Gets whether or not ogg are supported by your browser.
  29944. */
  29945. isOGGsupported: boolean;
  29946. /**
  29947. * Gets whether audio has been unlocked on the device.
  29948. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29949. * a user interaction has happened.
  29950. */
  29951. unlocked: boolean;
  29952. /**
  29953. * Defines if the audio engine relies on a custom unlocked button.
  29954. * In this case, the embedded button will not be displayed.
  29955. */
  29956. useCustomUnlockedButton: boolean;
  29957. /**
  29958. * Event raised when audio has been unlocked on the browser.
  29959. */
  29960. onAudioUnlockedObservable: Observable<AudioEngine>;
  29961. /**
  29962. * Event raised when audio has been locked on the browser.
  29963. */
  29964. onAudioLockedObservable: Observable<AudioEngine>;
  29965. /**
  29966. * Gets the current AudioContext if available.
  29967. */
  29968. readonly audioContext: Nullable<AudioContext>;
  29969. private _connectedAnalyser;
  29970. /**
  29971. * Instantiates a new audio engine.
  29972. *
  29973. * There should be only one per page as some browsers restrict the number
  29974. * of audio contexts you can create.
  29975. * @param hostElement defines the host element where to display the mute icon if necessary
  29976. */
  29977. constructor(hostElement?: Nullable<HTMLElement>);
  29978. /**
  29979. * Flags the audio engine in Locked state.
  29980. * This happens due to new browser policies preventing audio to autoplay.
  29981. */
  29982. lock(): void;
  29983. /**
  29984. * Unlocks the audio engine once a user action has been done on the dom.
  29985. * This is helpful to resume play once browser policies have been satisfied.
  29986. */
  29987. unlock(): void;
  29988. private _resumeAudioContext;
  29989. private _initializeAudioContext;
  29990. private _tryToRun;
  29991. private _triggerRunningState;
  29992. private _triggerSuspendedState;
  29993. private _displayMuteButton;
  29994. private _moveButtonToTopLeft;
  29995. private _onResize;
  29996. private _hideMuteButton;
  29997. /**
  29998. * Destroy and release the resources associated with the audio ccontext.
  29999. */
  30000. dispose(): void;
  30001. /**
  30002. * Gets the global volume sets on the master gain.
  30003. * @returns the global volume if set or -1 otherwise
  30004. */
  30005. getGlobalVolume(): number;
  30006. /**
  30007. * Sets the global volume of your experience (sets on the master gain).
  30008. * @param newVolume Defines the new global volume of the application
  30009. */
  30010. setGlobalVolume(newVolume: number): void;
  30011. /**
  30012. * Connect the audio engine to an audio analyser allowing some amazing
  30013. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30015. * @param analyser The analyser to connect to the engine
  30016. */
  30017. connectToAnalyser(analyser: Analyser): void;
  30018. }
  30019. }
  30020. declare module "babylonjs/Loading/loadingScreen" {
  30021. /**
  30022. * Interface used to present a loading screen while loading a scene
  30023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30024. */
  30025. export interface ILoadingScreen {
  30026. /**
  30027. * Function called to display the loading screen
  30028. */
  30029. displayLoadingUI: () => void;
  30030. /**
  30031. * Function called to hide the loading screen
  30032. */
  30033. hideLoadingUI: () => void;
  30034. /**
  30035. * Gets or sets the color to use for the background
  30036. */
  30037. loadingUIBackgroundColor: string;
  30038. /**
  30039. * Gets or sets the text to display while loading
  30040. */
  30041. loadingUIText: string;
  30042. }
  30043. /**
  30044. * Class used for the default loading screen
  30045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30046. */
  30047. export class DefaultLoadingScreen implements ILoadingScreen {
  30048. private _renderingCanvas;
  30049. private _loadingText;
  30050. private _loadingDivBackgroundColor;
  30051. private _loadingDiv;
  30052. private _loadingTextDiv;
  30053. /** Gets or sets the logo url to use for the default loading screen */
  30054. static DefaultLogoUrl: string;
  30055. /** Gets or sets the spinner url to use for the default loading screen */
  30056. static DefaultSpinnerUrl: string;
  30057. /**
  30058. * Creates a new default loading screen
  30059. * @param _renderingCanvas defines the canvas used to render the scene
  30060. * @param _loadingText defines the default text to display
  30061. * @param _loadingDivBackgroundColor defines the default background color
  30062. */
  30063. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30064. /**
  30065. * Function called to display the loading screen
  30066. */
  30067. displayLoadingUI(): void;
  30068. /**
  30069. * Function called to hide the loading screen
  30070. */
  30071. hideLoadingUI(): void;
  30072. /**
  30073. * Gets or sets the text to display while loading
  30074. */
  30075. loadingUIText: string;
  30076. /**
  30077. * Gets or sets the color to use for the background
  30078. */
  30079. loadingUIBackgroundColor: string;
  30080. private _resizeLoadingUI;
  30081. }
  30082. }
  30083. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30084. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30085. import { Engine } from "babylonjs/Engines/engine";
  30086. import { Nullable } from "babylonjs/types";
  30087. /** @hidden */
  30088. export class WebGLPipelineContext implements IPipelineContext {
  30089. engine: Engine;
  30090. program: Nullable<WebGLProgram>;
  30091. context?: WebGLRenderingContext;
  30092. vertexShader?: WebGLShader;
  30093. fragmentShader?: WebGLShader;
  30094. isParallelCompiled: boolean;
  30095. onCompiled?: () => void;
  30096. transformFeedback?: WebGLTransformFeedback | null;
  30097. readonly isAsync: boolean;
  30098. readonly isReady: boolean;
  30099. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30100. }
  30101. }
  30102. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30104. /** @hidden */
  30105. export class WebGLDataBuffer extends DataBuffer {
  30106. private _buffer;
  30107. constructor(resource: WebGLBuffer);
  30108. readonly underlyingResource: any;
  30109. }
  30110. }
  30111. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30112. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30113. /** @hidden */
  30114. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30115. attributeProcessor(attribute: string): string;
  30116. varyingProcessor(varying: string, isFragment: boolean): string;
  30117. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30118. }
  30119. }
  30120. declare module "babylonjs/Misc/perfCounter" {
  30121. /**
  30122. * This class is used to track a performance counter which is number based.
  30123. * The user has access to many properties which give statistics of different nature.
  30124. *
  30125. * The implementer can track two kinds of Performance Counter: time and count.
  30126. * 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.
  30127. * 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.
  30128. */
  30129. export class PerfCounter {
  30130. /**
  30131. * Gets or sets a global boolean to turn on and off all the counters
  30132. */
  30133. static Enabled: boolean;
  30134. /**
  30135. * Returns the smallest value ever
  30136. */
  30137. readonly min: number;
  30138. /**
  30139. * Returns the biggest value ever
  30140. */
  30141. readonly max: number;
  30142. /**
  30143. * Returns the average value since the performance counter is running
  30144. */
  30145. readonly average: number;
  30146. /**
  30147. * Returns the average value of the last second the counter was monitored
  30148. */
  30149. readonly lastSecAverage: number;
  30150. /**
  30151. * Returns the current value
  30152. */
  30153. readonly current: number;
  30154. /**
  30155. * Gets the accumulated total
  30156. */
  30157. readonly total: number;
  30158. /**
  30159. * Gets the total value count
  30160. */
  30161. readonly count: number;
  30162. /**
  30163. * Creates a new counter
  30164. */
  30165. constructor();
  30166. /**
  30167. * Call this method to start monitoring a new frame.
  30168. * 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.
  30169. */
  30170. fetchNewFrame(): void;
  30171. /**
  30172. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30173. * @param newCount the count value to add to the monitored count
  30174. * @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.
  30175. */
  30176. addCount(newCount: number, fetchResult: boolean): void;
  30177. /**
  30178. * Start monitoring this performance counter
  30179. */
  30180. beginMonitoring(): void;
  30181. /**
  30182. * Compute the time lapsed since the previous beginMonitoring() call.
  30183. * @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
  30184. */
  30185. endMonitoring(newFrame?: boolean): void;
  30186. private _fetchResult;
  30187. private _startMonitoringTime;
  30188. private _min;
  30189. private _max;
  30190. private _average;
  30191. private _current;
  30192. private _totalValueCount;
  30193. private _totalAccumulated;
  30194. private _lastSecAverage;
  30195. private _lastSecAccumulated;
  30196. private _lastSecTime;
  30197. private _lastSecValueCount;
  30198. }
  30199. }
  30200. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30201. /**
  30202. * Interface for any object that can request an animation frame
  30203. */
  30204. export interface ICustomAnimationFrameRequester {
  30205. /**
  30206. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30207. */
  30208. renderFunction?: Function;
  30209. /**
  30210. * Called to request the next frame to render to
  30211. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30212. */
  30213. requestAnimationFrame: Function;
  30214. /**
  30215. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30216. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30217. */
  30218. requestID?: number;
  30219. }
  30220. }
  30221. declare module "babylonjs/Materials/Textures/videoTexture" {
  30222. import { Observable } from "babylonjs/Misc/observable";
  30223. import { Nullable } from "babylonjs/types";
  30224. import { Scene } from "babylonjs/scene";
  30225. import { Texture } from "babylonjs/Materials/Textures/texture";
  30226. /**
  30227. * Settings for finer control over video usage
  30228. */
  30229. export interface VideoTextureSettings {
  30230. /**
  30231. * Applies `autoplay` to video, if specified
  30232. */
  30233. autoPlay?: boolean;
  30234. /**
  30235. * Applies `loop` to video, if specified
  30236. */
  30237. loop?: boolean;
  30238. /**
  30239. * Automatically updates internal texture from video at every frame in the render loop
  30240. */
  30241. autoUpdateTexture: boolean;
  30242. /**
  30243. * Image src displayed during the video loading or until the user interacts with the video.
  30244. */
  30245. poster?: string;
  30246. }
  30247. /**
  30248. * If you want to display a video in your scene, this is the special texture for that.
  30249. * This special texture works similar to other textures, with the exception of a few parameters.
  30250. * @see https://doc.babylonjs.com/how_to/video_texture
  30251. */
  30252. export class VideoTexture extends Texture {
  30253. /**
  30254. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30255. */
  30256. readonly autoUpdateTexture: boolean;
  30257. /**
  30258. * The video instance used by the texture internally
  30259. */
  30260. readonly video: HTMLVideoElement;
  30261. private _onUserActionRequestedObservable;
  30262. /**
  30263. * Event triggerd when a dom action is required by the user to play the video.
  30264. * This happens due to recent changes in browser policies preventing video to auto start.
  30265. */
  30266. readonly onUserActionRequestedObservable: Observable<Texture>;
  30267. private _generateMipMaps;
  30268. private _engine;
  30269. private _stillImageCaptured;
  30270. private _displayingPosterTexture;
  30271. private _settings;
  30272. private _createInternalTextureOnEvent;
  30273. /**
  30274. * Creates a video texture.
  30275. * If you want to display a video in your scene, this is the special texture for that.
  30276. * This special texture works similar to other textures, with the exception of a few parameters.
  30277. * @see https://doc.babylonjs.com/how_to/video_texture
  30278. * @param name optional name, will detect from video source, if not defined
  30279. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30280. * @param scene is obviously the current scene.
  30281. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30282. * @param invertY is false by default but can be used to invert video on Y axis
  30283. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30284. * @param settings allows finer control over video usage
  30285. */
  30286. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30287. private _getName;
  30288. private _getVideo;
  30289. private _createInternalTexture;
  30290. private reset;
  30291. /**
  30292. * @hidden Internal method to initiate `update`.
  30293. */
  30294. _rebuild(): void;
  30295. /**
  30296. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30297. */
  30298. update(): void;
  30299. /**
  30300. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30301. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30302. */
  30303. updateTexture(isVisible: boolean): void;
  30304. protected _updateInternalTexture: () => void;
  30305. /**
  30306. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30307. * @param url New url.
  30308. */
  30309. updateURL(url: string): void;
  30310. /**
  30311. * Dispose the texture and release its associated resources.
  30312. */
  30313. dispose(): void;
  30314. /**
  30315. * Creates a video texture straight from a stream.
  30316. * @param scene Define the scene the texture should be created in
  30317. * @param stream Define the stream the texture should be created from
  30318. * @returns The created video texture as a promise
  30319. */
  30320. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30321. /**
  30322. * Creates a video texture straight from your WebCam video feed.
  30323. * @param scene Define the scene the texture should be created in
  30324. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30325. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30326. * @returns The created video texture as a promise
  30327. */
  30328. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30329. minWidth: number;
  30330. maxWidth: number;
  30331. minHeight: number;
  30332. maxHeight: number;
  30333. deviceId: string;
  30334. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30335. /**
  30336. * Creates a video texture straight from your WebCam video feed.
  30337. * @param scene Define the scene the texture should be created in
  30338. * @param onReady Define a callback to triggered once the texture will be ready
  30339. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30340. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30341. */
  30342. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30343. minWidth: number;
  30344. maxWidth: number;
  30345. minHeight: number;
  30346. maxHeight: number;
  30347. deviceId: string;
  30348. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30349. }
  30350. }
  30351. declare module "babylonjs/Engines/engine" {
  30352. import { Observable } from "babylonjs/Misc/observable";
  30353. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30354. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30355. import { Scene } from "babylonjs/scene";
  30356. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30357. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30358. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30359. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30362. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30363. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30364. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30365. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30366. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30367. import { WebRequest } from "babylonjs/Misc/webRequest";
  30368. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30369. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30371. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30372. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30373. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30374. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30375. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30376. import { Material } from "babylonjs/Materials/material";
  30377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30379. /**
  30380. * Defines the interface used by objects containing a viewport (like a camera)
  30381. */
  30382. interface IViewportOwnerLike {
  30383. /**
  30384. * Gets or sets the viewport
  30385. */
  30386. viewport: IViewportLike;
  30387. }
  30388. /**
  30389. * Interface for attribute information associated with buffer instanciation
  30390. */
  30391. export class InstancingAttributeInfo {
  30392. /**
  30393. * Index/offset of the attribute in the vertex shader
  30394. */
  30395. index: number;
  30396. /**
  30397. * size of the attribute, 1, 2, 3 or 4
  30398. */
  30399. attributeSize: number;
  30400. /**
  30401. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30402. * default is FLOAT
  30403. */
  30404. attribyteType: number;
  30405. /**
  30406. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30407. */
  30408. normalized: boolean;
  30409. /**
  30410. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30411. */
  30412. offset: number;
  30413. /**
  30414. * Name of the GLSL attribute, for debugging purpose only
  30415. */
  30416. attributeName: string;
  30417. }
  30418. /**
  30419. * Define options used to create a depth texture
  30420. */
  30421. export class DepthTextureCreationOptions {
  30422. /** Specifies whether or not a stencil should be allocated in the texture */
  30423. generateStencil?: boolean;
  30424. /** Specifies whether or not bilinear filtering is enable on the texture */
  30425. bilinearFiltering?: boolean;
  30426. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30427. comparisonFunction?: number;
  30428. /** Specifies if the created texture is a cube texture */
  30429. isCube?: boolean;
  30430. }
  30431. /**
  30432. * Class used to describe the capabilities of the engine relatively to the current browser
  30433. */
  30434. export class EngineCapabilities {
  30435. /** Maximum textures units per fragment shader */
  30436. maxTexturesImageUnits: number;
  30437. /** Maximum texture units per vertex shader */
  30438. maxVertexTextureImageUnits: number;
  30439. /** Maximum textures units in the entire pipeline */
  30440. maxCombinedTexturesImageUnits: number;
  30441. /** Maximum texture size */
  30442. maxTextureSize: number;
  30443. /** Maximum cube texture size */
  30444. maxCubemapTextureSize: number;
  30445. /** Maximum render texture size */
  30446. maxRenderTextureSize: number;
  30447. /** Maximum number of vertex attributes */
  30448. maxVertexAttribs: number;
  30449. /** Maximum number of varyings */
  30450. maxVaryingVectors: number;
  30451. /** Maximum number of uniforms per vertex shader */
  30452. maxVertexUniformVectors: number;
  30453. /** Maximum number of uniforms per fragment shader */
  30454. maxFragmentUniformVectors: number;
  30455. /** Defines if standard derivates (dx/dy) are supported */
  30456. standardDerivatives: boolean;
  30457. /** Defines if s3tc texture compression is supported */
  30458. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30459. /** Defines if pvrtc texture compression is supported */
  30460. pvrtc: any;
  30461. /** Defines if etc1 texture compression is supported */
  30462. etc1: any;
  30463. /** Defines if etc2 texture compression is supported */
  30464. etc2: any;
  30465. /** Defines if astc texture compression is supported */
  30466. astc: any;
  30467. /** Defines if float textures are supported */
  30468. textureFloat: boolean;
  30469. /** Defines if vertex array objects are supported */
  30470. vertexArrayObject: boolean;
  30471. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30472. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30473. /** Gets the maximum level of anisotropy supported */
  30474. maxAnisotropy: number;
  30475. /** Defines if instancing is supported */
  30476. instancedArrays: boolean;
  30477. /** Defines if 32 bits indices are supported */
  30478. uintIndices: boolean;
  30479. /** Defines if high precision shaders are supported */
  30480. highPrecisionShaderSupported: boolean;
  30481. /** Defines if depth reading in the fragment shader is supported */
  30482. fragmentDepthSupported: boolean;
  30483. /** Defines if float texture linear filtering is supported*/
  30484. textureFloatLinearFiltering: boolean;
  30485. /** Defines if rendering to float textures is supported */
  30486. textureFloatRender: boolean;
  30487. /** Defines if half float textures are supported*/
  30488. textureHalfFloat: boolean;
  30489. /** Defines if half float texture linear filtering is supported*/
  30490. textureHalfFloatLinearFiltering: boolean;
  30491. /** Defines if rendering to half float textures is supported */
  30492. textureHalfFloatRender: boolean;
  30493. /** Defines if textureLOD shader command is supported */
  30494. textureLOD: boolean;
  30495. /** Defines if draw buffers extension is supported */
  30496. drawBuffersExtension: boolean;
  30497. /** Defines if depth textures are supported */
  30498. depthTextureExtension: boolean;
  30499. /** Defines if float color buffer are supported */
  30500. colorBufferFloat: boolean;
  30501. /** Gets disjoint timer query extension (null if not supported) */
  30502. timerQuery: EXT_disjoint_timer_query;
  30503. /** Defines if timestamp can be used with timer query */
  30504. canUseTimestampForTimerQuery: boolean;
  30505. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30506. multiview: any;
  30507. /** Function used to let the system compiles shaders in background */
  30508. parallelShaderCompile: {
  30509. COMPLETION_STATUS_KHR: number;
  30510. };
  30511. /** Max number of texture samples for MSAA */
  30512. maxMSAASamples: number;
  30513. }
  30514. /** Interface defining initialization parameters for Engine class */
  30515. export interface EngineOptions extends WebGLContextAttributes {
  30516. /**
  30517. * Defines if the engine should no exceed a specified device ratio
  30518. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30519. */
  30520. limitDeviceRatio?: number;
  30521. /**
  30522. * Defines if webvr should be enabled automatically
  30523. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30524. */
  30525. autoEnableWebVR?: boolean;
  30526. /**
  30527. * Defines if webgl2 should be turned off even if supported
  30528. * @see http://doc.babylonjs.com/features/webgl2
  30529. */
  30530. disableWebGL2Support?: boolean;
  30531. /**
  30532. * Defines if webaudio should be initialized as well
  30533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30534. */
  30535. audioEngine?: boolean;
  30536. /**
  30537. * Defines if animations should run using a deterministic lock step
  30538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30539. */
  30540. deterministicLockstep?: boolean;
  30541. /** Defines the maximum steps to use with deterministic lock step mode */
  30542. lockstepMaxSteps?: number;
  30543. /**
  30544. * Defines that engine should ignore context lost events
  30545. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30546. */
  30547. doNotHandleContextLost?: boolean;
  30548. /**
  30549. * Defines that engine should ignore modifying touch action attribute and style
  30550. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30551. */
  30552. doNotHandleTouchAction?: boolean;
  30553. /**
  30554. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30555. */
  30556. useHighPrecisionFloats?: boolean;
  30557. }
  30558. /**
  30559. * Defines the interface used by display changed events
  30560. */
  30561. export interface IDisplayChangedEventArgs {
  30562. /** Gets the vrDisplay object (if any) */
  30563. vrDisplay: Nullable<any>;
  30564. /** Gets a boolean indicating if webVR is supported */
  30565. vrSupported: boolean;
  30566. }
  30567. /**
  30568. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30569. */
  30570. export class Engine {
  30571. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30572. static ExceptionList: ({
  30573. key: string;
  30574. capture: string;
  30575. captureConstraint: number;
  30576. targets: string[];
  30577. } | {
  30578. key: string;
  30579. capture: null;
  30580. captureConstraint: null;
  30581. targets: string[];
  30582. })[];
  30583. /** Gets the list of created engines */
  30584. static readonly Instances: Engine[];
  30585. /**
  30586. * Gets the latest created engine
  30587. */
  30588. static readonly LastCreatedEngine: Nullable<Engine>;
  30589. /**
  30590. * Gets the latest created scene
  30591. */
  30592. static readonly LastCreatedScene: Nullable<Scene>;
  30593. /**
  30594. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30595. * @param flag defines which part of the materials must be marked as dirty
  30596. * @param predicate defines a predicate used to filter which materials should be affected
  30597. */
  30598. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30599. /** @hidden */
  30600. static _TextureLoaders: IInternalTextureLoader[];
  30601. /** Defines that alpha blending is disabled */
  30602. static readonly ALPHA_DISABLE: number;
  30603. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30604. static readonly ALPHA_ADD: number;
  30605. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30606. static readonly ALPHA_COMBINE: number;
  30607. /** Defines that alpha blending to DEST - SRC * DEST */
  30608. static readonly ALPHA_SUBTRACT: number;
  30609. /** Defines that alpha blending to SRC * DEST */
  30610. static readonly ALPHA_MULTIPLY: number;
  30611. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30612. static readonly ALPHA_MAXIMIZED: number;
  30613. /** Defines that alpha blending to SRC + DEST */
  30614. static readonly ALPHA_ONEONE: number;
  30615. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30616. static readonly ALPHA_PREMULTIPLIED: number;
  30617. /**
  30618. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30619. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30620. */
  30621. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30622. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30623. static readonly ALPHA_INTERPOLATE: number;
  30624. /**
  30625. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30626. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30627. */
  30628. static readonly ALPHA_SCREENMODE: number;
  30629. /** Defines that the ressource is not delayed*/
  30630. static readonly DELAYLOADSTATE_NONE: number;
  30631. /** Defines that the ressource was successfully delay loaded */
  30632. static readonly DELAYLOADSTATE_LOADED: number;
  30633. /** Defines that the ressource is currently delay loading */
  30634. static readonly DELAYLOADSTATE_LOADING: number;
  30635. /** Defines that the ressource is delayed and has not started loading */
  30636. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30638. static readonly NEVER: number;
  30639. /** 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 */
  30640. static readonly ALWAYS: number;
  30641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30642. static readonly LESS: number;
  30643. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30644. static readonly EQUAL: number;
  30645. /** 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 */
  30646. static readonly LEQUAL: number;
  30647. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30648. static readonly GREATER: number;
  30649. /** 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 */
  30650. static readonly GEQUAL: number;
  30651. /** 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 */
  30652. static readonly NOTEQUAL: number;
  30653. /** Passed to stencilOperation to specify that stencil value must be kept */
  30654. static readonly KEEP: number;
  30655. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30656. static readonly REPLACE: number;
  30657. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30658. static readonly INCR: number;
  30659. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30660. static readonly DECR: number;
  30661. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30662. static readonly INVERT: number;
  30663. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30664. static readonly INCR_WRAP: number;
  30665. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30666. static readonly DECR_WRAP: number;
  30667. /** Texture is not repeating outside of 0..1 UVs */
  30668. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30669. /** Texture is repeating outside of 0..1 UVs */
  30670. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30671. /** Texture is repeating and mirrored */
  30672. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30673. /** ALPHA */
  30674. static readonly TEXTUREFORMAT_ALPHA: number;
  30675. /** LUMINANCE */
  30676. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30677. /** LUMINANCE_ALPHA */
  30678. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30679. /** RGB */
  30680. static readonly TEXTUREFORMAT_RGB: number;
  30681. /** RGBA */
  30682. static readonly TEXTUREFORMAT_RGBA: number;
  30683. /** RED */
  30684. static readonly TEXTUREFORMAT_RED: number;
  30685. /** RED (2nd reference) */
  30686. static readonly TEXTUREFORMAT_R: number;
  30687. /** RG */
  30688. static readonly TEXTUREFORMAT_RG: number;
  30689. /** RED_INTEGER */
  30690. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30691. /** RED_INTEGER (2nd reference) */
  30692. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30693. /** RG_INTEGER */
  30694. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30695. /** RGB_INTEGER */
  30696. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30697. /** RGBA_INTEGER */
  30698. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30699. /** UNSIGNED_BYTE */
  30700. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30701. /** UNSIGNED_BYTE (2nd reference) */
  30702. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30703. /** FLOAT */
  30704. static readonly TEXTURETYPE_FLOAT: number;
  30705. /** HALF_FLOAT */
  30706. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30707. /** BYTE */
  30708. static readonly TEXTURETYPE_BYTE: number;
  30709. /** SHORT */
  30710. static readonly TEXTURETYPE_SHORT: number;
  30711. /** UNSIGNED_SHORT */
  30712. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30713. /** INT */
  30714. static readonly TEXTURETYPE_INT: number;
  30715. /** UNSIGNED_INT */
  30716. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30717. /** UNSIGNED_SHORT_4_4_4_4 */
  30718. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30719. /** UNSIGNED_SHORT_5_5_5_1 */
  30720. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30721. /** UNSIGNED_SHORT_5_6_5 */
  30722. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30723. /** UNSIGNED_INT_2_10_10_10_REV */
  30724. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30725. /** UNSIGNED_INT_24_8 */
  30726. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30727. /** UNSIGNED_INT_10F_11F_11F_REV */
  30728. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30729. /** UNSIGNED_INT_5_9_9_9_REV */
  30730. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30731. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30732. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30733. /** nearest is mag = nearest and min = nearest and mip = linear */
  30734. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30735. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30736. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30737. /** Trilinear is mag = linear and min = linear and mip = linear */
  30738. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30739. /** nearest is mag = nearest and min = nearest and mip = linear */
  30740. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30741. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30742. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30743. /** Trilinear is mag = linear and min = linear and mip = linear */
  30744. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30745. /** mag = nearest and min = nearest and mip = nearest */
  30746. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30747. /** mag = nearest and min = linear and mip = nearest */
  30748. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30749. /** mag = nearest and min = linear and mip = linear */
  30750. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30751. /** mag = nearest and min = linear and mip = none */
  30752. static readonly TEXTURE_NEAREST_LINEAR: number;
  30753. /** mag = nearest and min = nearest and mip = none */
  30754. static readonly TEXTURE_NEAREST_NEAREST: number;
  30755. /** mag = linear and min = nearest and mip = nearest */
  30756. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30757. /** mag = linear and min = nearest and mip = linear */
  30758. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30759. /** mag = linear and min = linear and mip = none */
  30760. static readonly TEXTURE_LINEAR_LINEAR: number;
  30761. /** mag = linear and min = nearest and mip = none */
  30762. static readonly TEXTURE_LINEAR_NEAREST: number;
  30763. /** Explicit coordinates mode */
  30764. static readonly TEXTURE_EXPLICIT_MODE: number;
  30765. /** Spherical coordinates mode */
  30766. static readonly TEXTURE_SPHERICAL_MODE: number;
  30767. /** Planar coordinates mode */
  30768. static readonly TEXTURE_PLANAR_MODE: number;
  30769. /** Cubic coordinates mode */
  30770. static readonly TEXTURE_CUBIC_MODE: number;
  30771. /** Projection coordinates mode */
  30772. static readonly TEXTURE_PROJECTION_MODE: number;
  30773. /** Skybox coordinates mode */
  30774. static readonly TEXTURE_SKYBOX_MODE: number;
  30775. /** Inverse Cubic coordinates mode */
  30776. static readonly TEXTURE_INVCUBIC_MODE: number;
  30777. /** Equirectangular coordinates mode */
  30778. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30779. /** Equirectangular Fixed coordinates mode */
  30780. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30781. /** Equirectangular Fixed Mirrored coordinates mode */
  30782. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30783. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30784. static readonly SCALEMODE_FLOOR: number;
  30785. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30786. static readonly SCALEMODE_NEAREST: number;
  30787. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30788. static readonly SCALEMODE_CEILING: number;
  30789. /**
  30790. * Returns the current npm package of the sdk
  30791. */
  30792. static readonly NpmPackage: string;
  30793. /**
  30794. * Returns the current version of the framework
  30795. */
  30796. static readonly Version: string;
  30797. /**
  30798. * Returns a string describing the current engine
  30799. */
  30800. readonly description: string;
  30801. /**
  30802. * Gets or sets the epsilon value used by collision engine
  30803. */
  30804. static CollisionsEpsilon: number;
  30805. /**
  30806. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30807. */
  30808. static ShadersRepository: string;
  30809. /**
  30810. * Method called to create the default loading screen.
  30811. * This can be overriden in your own app.
  30812. * @param canvas The rendering canvas element
  30813. * @returns The loading screen
  30814. */
  30815. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30816. /**
  30817. * Method called to create the default rescale post process on each engine.
  30818. */
  30819. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30820. /** @hidden */
  30821. _shaderProcessor: IShaderProcessor;
  30822. /**
  30823. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30824. */
  30825. forcePOTTextures: boolean;
  30826. /**
  30827. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30828. */
  30829. isFullscreen: boolean;
  30830. /**
  30831. * Gets a boolean indicating if the pointer is currently locked
  30832. */
  30833. isPointerLock: boolean;
  30834. /**
  30835. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30836. */
  30837. cullBackFaces: boolean;
  30838. /**
  30839. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30840. */
  30841. renderEvenInBackground: boolean;
  30842. /**
  30843. * Gets or sets a boolean indicating that cache can be kept between frames
  30844. */
  30845. preventCacheWipeBetweenFrames: boolean;
  30846. /**
  30847. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30848. **/
  30849. enableOfflineSupport: boolean;
  30850. /**
  30851. * 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)
  30852. **/
  30853. disableManifestCheck: boolean;
  30854. /**
  30855. * Gets the list of created scenes
  30856. */
  30857. scenes: Scene[];
  30858. /**
  30859. * Event raised when a new scene is created
  30860. */
  30861. onNewSceneAddedObservable: Observable<Scene>;
  30862. /**
  30863. * Gets the list of created postprocesses
  30864. */
  30865. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30866. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30867. validateShaderPrograms: boolean;
  30868. /**
  30869. * Observable event triggered each time the rendering canvas is resized
  30870. */
  30871. onResizeObservable: Observable<Engine>;
  30872. /**
  30873. * Observable event triggered each time the canvas loses focus
  30874. */
  30875. onCanvasBlurObservable: Observable<Engine>;
  30876. /**
  30877. * Observable event triggered each time the canvas gains focus
  30878. */
  30879. onCanvasFocusObservable: Observable<Engine>;
  30880. /**
  30881. * Observable event triggered each time the canvas receives pointerout event
  30882. */
  30883. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30884. /**
  30885. * Observable event triggered before each texture is initialized
  30886. */
  30887. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30888. /**
  30889. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30890. */
  30891. disableUniformBuffers: boolean;
  30892. /** @hidden */
  30893. _uniformBuffers: UniformBuffer[];
  30894. /**
  30895. * Gets a boolean indicating that the engine supports uniform buffers
  30896. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30897. */
  30898. readonly supportsUniformBuffers: boolean;
  30899. /**
  30900. * Observable raised when the engine begins a new frame
  30901. */
  30902. onBeginFrameObservable: Observable<Engine>;
  30903. /**
  30904. * If set, will be used to request the next animation frame for the render loop
  30905. */
  30906. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30907. /**
  30908. * Observable raised when the engine ends the current frame
  30909. */
  30910. onEndFrameObservable: Observable<Engine>;
  30911. /**
  30912. * Observable raised when the engine is about to compile a shader
  30913. */
  30914. onBeforeShaderCompilationObservable: Observable<Engine>;
  30915. /**
  30916. * Observable raised when the engine has jsut compiled a shader
  30917. */
  30918. onAfterShaderCompilationObservable: Observable<Engine>;
  30919. /** @hidden */
  30920. _gl: WebGLRenderingContext;
  30921. private _renderingCanvas;
  30922. private _windowIsBackground;
  30923. private _webGLVersion;
  30924. protected _highPrecisionShadersAllowed: boolean;
  30925. /** @hidden */
  30926. readonly _shouldUseHighPrecisionShader: boolean;
  30927. /**
  30928. * Gets a boolean indicating that only power of 2 textures are supported
  30929. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30930. */
  30931. readonly needPOTTextures: boolean;
  30932. /** @hidden */
  30933. _badOS: boolean;
  30934. /** @hidden */
  30935. _badDesktopOS: boolean;
  30936. /**
  30937. * Gets the audio engine
  30938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30939. * @ignorenaming
  30940. */
  30941. static audioEngine: IAudioEngine;
  30942. /**
  30943. * Default AudioEngine factory responsible of creating the Audio Engine.
  30944. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30945. */
  30946. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30947. /**
  30948. * Default offline support factory responsible of creating a tool used to store data locally.
  30949. * By default, this will create a Database object if the workload has been embedded.
  30950. */
  30951. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30952. private _onFocus;
  30953. private _onBlur;
  30954. private _onCanvasPointerOut;
  30955. private _onCanvasBlur;
  30956. private _onCanvasFocus;
  30957. private _onFullscreenChange;
  30958. private _onPointerLockChange;
  30959. private _hardwareScalingLevel;
  30960. /** @hidden */
  30961. _caps: EngineCapabilities;
  30962. private _pointerLockRequested;
  30963. private _isStencilEnable;
  30964. private _colorWrite;
  30965. private _loadingScreen;
  30966. /** @hidden */
  30967. _drawCalls: PerfCounter;
  30968. private _glVersion;
  30969. private _glRenderer;
  30970. private _glVendor;
  30971. private _videoTextureSupported;
  30972. private _renderingQueueLaunched;
  30973. private _activeRenderLoops;
  30974. private _deterministicLockstep;
  30975. private _lockstepMaxSteps;
  30976. /**
  30977. * Observable signaled when a context lost event is raised
  30978. */
  30979. onContextLostObservable: Observable<Engine>;
  30980. /**
  30981. * Observable signaled when a context restored event is raised
  30982. */
  30983. onContextRestoredObservable: Observable<Engine>;
  30984. private _onContextLost;
  30985. private _onContextRestored;
  30986. private _contextWasLost;
  30987. /** @hidden */
  30988. _doNotHandleContextLost: boolean;
  30989. /**
  30990. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30992. */
  30993. doNotHandleContextLost: boolean;
  30994. private _performanceMonitor;
  30995. private _fps;
  30996. private _deltaTime;
  30997. /**
  30998. * Turn this value on if you want to pause FPS computation when in background
  30999. */
  31000. disablePerformanceMonitorInBackground: boolean;
  31001. /**
  31002. * Gets the performance monitor attached to this engine
  31003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31004. */
  31005. readonly performanceMonitor: PerformanceMonitor;
  31006. /**
  31007. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31008. */
  31009. disableVertexArrayObjects: boolean;
  31010. /** @hidden */
  31011. protected _depthCullingState: _DepthCullingState;
  31012. /** @hidden */
  31013. protected _stencilState: _StencilState;
  31014. /** @hidden */
  31015. protected _alphaState: _AlphaState;
  31016. /** @hidden */
  31017. protected _alphaMode: number;
  31018. /** @hidden */
  31019. _internalTexturesCache: InternalTexture[];
  31020. /** @hidden */
  31021. protected _activeChannel: number;
  31022. private _currentTextureChannel;
  31023. /** @hidden */
  31024. protected _boundTexturesCache: {
  31025. [key: string]: Nullable<InternalTexture>;
  31026. };
  31027. /** @hidden */
  31028. protected _currentEffect: Nullable<Effect>;
  31029. /** @hidden */
  31030. protected _currentProgram: Nullable<WebGLProgram>;
  31031. private _compiledEffects;
  31032. private _vertexAttribArraysEnabled;
  31033. /** @hidden */
  31034. protected _cachedViewport: Nullable<IViewportLike>;
  31035. private _cachedVertexArrayObject;
  31036. /** @hidden */
  31037. protected _cachedVertexBuffers: any;
  31038. /** @hidden */
  31039. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31040. /** @hidden */
  31041. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31042. /** @hidden */
  31043. _currentRenderTarget: Nullable<InternalTexture>;
  31044. private _uintIndicesCurrentlySet;
  31045. private _currentBoundBuffer;
  31046. /** @hidden */
  31047. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31048. private _currentBufferPointers;
  31049. private _currentInstanceLocations;
  31050. private _currentInstanceBuffers;
  31051. private _textureUnits;
  31052. /** @hidden */
  31053. _workingCanvas: Nullable<HTMLCanvasElement>;
  31054. /** @hidden */
  31055. _workingContext: Nullable<CanvasRenderingContext2D>;
  31056. private _rescalePostProcess;
  31057. private _dummyFramebuffer;
  31058. private _externalData;
  31059. /** @hidden */
  31060. _bindedRenderFunction: any;
  31061. private _vaoRecordInProgress;
  31062. private _mustWipeVertexAttributes;
  31063. private _emptyTexture;
  31064. private _emptyCubeTexture;
  31065. private _emptyTexture3D;
  31066. /** @hidden */
  31067. _frameHandler: number;
  31068. private _nextFreeTextureSlots;
  31069. private _maxSimultaneousTextures;
  31070. private _activeRequests;
  31071. private _texturesSupported;
  31072. /** @hidden */
  31073. _textureFormatInUse: Nullable<string>;
  31074. /**
  31075. * Gets the list of texture formats supported
  31076. */
  31077. readonly texturesSupported: Array<string>;
  31078. /**
  31079. * Gets the list of texture formats in use
  31080. */
  31081. readonly textureFormatInUse: Nullable<string>;
  31082. /**
  31083. * Gets the current viewport
  31084. */
  31085. readonly currentViewport: Nullable<IViewportLike>;
  31086. /**
  31087. * Gets the default empty texture
  31088. */
  31089. readonly emptyTexture: InternalTexture;
  31090. /**
  31091. * Gets the default empty 3D texture
  31092. */
  31093. readonly emptyTexture3D: InternalTexture;
  31094. /**
  31095. * Gets the default empty cube texture
  31096. */
  31097. readonly emptyCubeTexture: InternalTexture;
  31098. /**
  31099. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31100. */
  31101. readonly premultipliedAlpha: boolean;
  31102. /**
  31103. * Creates a new engine
  31104. * @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
  31105. * @param antialias defines enable antialiasing (default: false)
  31106. * @param options defines further options to be sent to the getContext() function
  31107. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31108. */
  31109. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31110. /**
  31111. * Initializes a webVR display and starts listening to display change events
  31112. * The onVRDisplayChangedObservable will be notified upon these changes
  31113. * @returns The onVRDisplayChangedObservable
  31114. */
  31115. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31116. /** @hidden */
  31117. _prepareVRComponent(): void;
  31118. /** @hidden */
  31119. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31120. /** @hidden */
  31121. _submitVRFrame(): void;
  31122. /**
  31123. * Call this function to leave webVR mode
  31124. * Will do nothing if webVR is not supported or if there is no webVR device
  31125. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31126. */
  31127. disableVR(): void;
  31128. /**
  31129. * Gets a boolean indicating that the system is in VR mode and is presenting
  31130. * @returns true if VR mode is engaged
  31131. */
  31132. isVRPresenting(): boolean;
  31133. /** @hidden */
  31134. _requestVRFrame(): void;
  31135. private _disableTouchAction;
  31136. private _rebuildInternalTextures;
  31137. private _rebuildEffects;
  31138. /**
  31139. * Gets a boolean indicating if all created effects are ready
  31140. * @returns true if all effects are ready
  31141. */
  31142. areAllEffectsReady(): boolean;
  31143. private _rebuildBuffers;
  31144. private _initGLContext;
  31145. /**
  31146. * Gets version of the current webGL context
  31147. */
  31148. readonly webGLVersion: number;
  31149. /**
  31150. * Gets a string idenfifying the name of the class
  31151. * @returns "Engine" string
  31152. */
  31153. getClassName(): string;
  31154. /**
  31155. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31156. */
  31157. readonly isStencilEnable: boolean;
  31158. /** @hidden */
  31159. _prepareWorkingCanvas(): void;
  31160. /**
  31161. * Reset the texture cache to empty state
  31162. */
  31163. resetTextureCache(): void;
  31164. /**
  31165. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31167. * @returns true if engine is in deterministic lock step mode
  31168. */
  31169. isDeterministicLockStep(): boolean;
  31170. /**
  31171. * Gets the max steps when engine is running in deterministic lock step
  31172. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31173. * @returns the max steps
  31174. */
  31175. getLockstepMaxSteps(): number;
  31176. /**
  31177. * Gets an object containing information about the current webGL context
  31178. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31179. */
  31180. getGlInfo(): {
  31181. vendor: string;
  31182. renderer: string;
  31183. version: string;
  31184. };
  31185. /**
  31186. * Gets current aspect ratio
  31187. * @param viewportOwner defines the camera to use to get the aspect ratio
  31188. * @param useScreen defines if screen size must be used (or the current render target if any)
  31189. * @returns a number defining the aspect ratio
  31190. */
  31191. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31192. /**
  31193. * Gets current screen aspect ratio
  31194. * @returns a number defining the aspect ratio
  31195. */
  31196. getScreenAspectRatio(): number;
  31197. /**
  31198. * Gets the current render width
  31199. * @param useScreen defines if screen size must be used (or the current render target if any)
  31200. * @returns a number defining the current render width
  31201. */
  31202. getRenderWidth(useScreen?: boolean): number;
  31203. /**
  31204. * Gets the current render height
  31205. * @param useScreen defines if screen size must be used (or the current render target if any)
  31206. * @returns a number defining the current render height
  31207. */
  31208. getRenderHeight(useScreen?: boolean): number;
  31209. /**
  31210. * Gets the HTML canvas attached with the current webGL context
  31211. * @returns a HTML canvas
  31212. */
  31213. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31214. /**
  31215. * Gets host window
  31216. * @returns the host window object
  31217. */
  31218. getHostWindow(): Window;
  31219. /**
  31220. * Gets host document
  31221. * @returns the host document object
  31222. */
  31223. getHostDocument(): Document;
  31224. /**
  31225. * Gets the client rect of the HTML canvas attached with the current webGL context
  31226. * @returns a client rectanglee
  31227. */
  31228. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31229. /**
  31230. * Defines the hardware scaling level.
  31231. * By default the hardware scaling level is computed from the window device ratio.
  31232. * 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.
  31233. * @param level defines the level to use
  31234. */
  31235. setHardwareScalingLevel(level: number): void;
  31236. /**
  31237. * Gets the current hardware scaling level.
  31238. * By default the hardware scaling level is computed from the window device ratio.
  31239. * 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.
  31240. * @returns a number indicating the current hardware scaling level
  31241. */
  31242. getHardwareScalingLevel(): number;
  31243. /**
  31244. * Gets the list of loaded textures
  31245. * @returns an array containing all loaded textures
  31246. */
  31247. getLoadedTexturesCache(): InternalTexture[];
  31248. /**
  31249. * Gets the object containing all engine capabilities
  31250. * @returns the EngineCapabilities object
  31251. */
  31252. getCaps(): EngineCapabilities;
  31253. /**
  31254. * Gets the current depth function
  31255. * @returns a number defining the depth function
  31256. */
  31257. getDepthFunction(): Nullable<number>;
  31258. /**
  31259. * Sets the current depth function
  31260. * @param depthFunc defines the function to use
  31261. */
  31262. setDepthFunction(depthFunc: number): void;
  31263. /**
  31264. * Sets the current depth function to GREATER
  31265. */
  31266. setDepthFunctionToGreater(): void;
  31267. /**
  31268. * Sets the current depth function to GEQUAL
  31269. */
  31270. setDepthFunctionToGreaterOrEqual(): void;
  31271. /**
  31272. * Sets the current depth function to LESS
  31273. */
  31274. setDepthFunctionToLess(): void;
  31275. private _cachedStencilBuffer;
  31276. private _cachedStencilFunction;
  31277. private _cachedStencilMask;
  31278. private _cachedStencilOperationPass;
  31279. private _cachedStencilOperationFail;
  31280. private _cachedStencilOperationDepthFail;
  31281. private _cachedStencilReference;
  31282. /**
  31283. * Caches the the state of the stencil buffer
  31284. */
  31285. cacheStencilState(): void;
  31286. /**
  31287. * Restores the state of the stencil buffer
  31288. */
  31289. restoreStencilState(): void;
  31290. /**
  31291. * Sets the current depth function to LEQUAL
  31292. */
  31293. setDepthFunctionToLessOrEqual(): void;
  31294. /**
  31295. * Gets a boolean indicating if stencil buffer is enabled
  31296. * @returns the current stencil buffer state
  31297. */
  31298. getStencilBuffer(): boolean;
  31299. /**
  31300. * Enable or disable the stencil buffer
  31301. * @param enable defines if the stencil buffer must be enabled or disabled
  31302. */
  31303. setStencilBuffer(enable: boolean): void;
  31304. /**
  31305. * Gets the current stencil mask
  31306. * @returns a number defining the new stencil mask to use
  31307. */
  31308. getStencilMask(): number;
  31309. /**
  31310. * Sets the current stencil mask
  31311. * @param mask defines the new stencil mask to use
  31312. */
  31313. setStencilMask(mask: number): void;
  31314. /**
  31315. * Gets the current stencil function
  31316. * @returns a number defining the stencil function to use
  31317. */
  31318. getStencilFunction(): number;
  31319. /**
  31320. * Gets the current stencil reference value
  31321. * @returns a number defining the stencil reference value to use
  31322. */
  31323. getStencilFunctionReference(): number;
  31324. /**
  31325. * Gets the current stencil mask
  31326. * @returns a number defining the stencil mask to use
  31327. */
  31328. getStencilFunctionMask(): number;
  31329. /**
  31330. * Sets the current stencil function
  31331. * @param stencilFunc defines the new stencil function to use
  31332. */
  31333. setStencilFunction(stencilFunc: number): void;
  31334. /**
  31335. * Sets the current stencil reference
  31336. * @param reference defines the new stencil reference to use
  31337. */
  31338. setStencilFunctionReference(reference: number): void;
  31339. /**
  31340. * Sets the current stencil mask
  31341. * @param mask defines the new stencil mask to use
  31342. */
  31343. setStencilFunctionMask(mask: number): void;
  31344. /**
  31345. * Gets the current stencil operation when stencil fails
  31346. * @returns a number defining stencil operation to use when stencil fails
  31347. */
  31348. getStencilOperationFail(): number;
  31349. /**
  31350. * Gets the current stencil operation when depth fails
  31351. * @returns a number defining stencil operation to use when depth fails
  31352. */
  31353. getStencilOperationDepthFail(): number;
  31354. /**
  31355. * Gets the current stencil operation when stencil passes
  31356. * @returns a number defining stencil operation to use when stencil passes
  31357. */
  31358. getStencilOperationPass(): number;
  31359. /**
  31360. * Sets the stencil operation to use when stencil fails
  31361. * @param operation defines the stencil operation to use when stencil fails
  31362. */
  31363. setStencilOperationFail(operation: number): void;
  31364. /**
  31365. * Sets the stencil operation to use when depth fails
  31366. * @param operation defines the stencil operation to use when depth fails
  31367. */
  31368. setStencilOperationDepthFail(operation: number): void;
  31369. /**
  31370. * Sets the stencil operation to use when stencil passes
  31371. * @param operation defines the stencil operation to use when stencil passes
  31372. */
  31373. setStencilOperationPass(operation: number): void;
  31374. /**
  31375. * Sets a boolean indicating if the dithering state is enabled or disabled
  31376. * @param value defines the dithering state
  31377. */
  31378. setDitheringState(value: boolean): void;
  31379. /**
  31380. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31381. * @param value defines the rasterizer state
  31382. */
  31383. setRasterizerState(value: boolean): void;
  31384. /**
  31385. * stop executing a render loop function and remove it from the execution array
  31386. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31387. */
  31388. stopRenderLoop(renderFunction?: () => void): void;
  31389. /** @hidden */
  31390. _renderLoop(): void;
  31391. /**
  31392. * Register and execute a render loop. The engine can have more than one render function
  31393. * @param renderFunction defines the function to continuously execute
  31394. */
  31395. runRenderLoop(renderFunction: () => void): void;
  31396. /**
  31397. * Toggle full screen mode
  31398. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31399. */
  31400. switchFullscreen(requestPointerLock: boolean): void;
  31401. /**
  31402. * Enters full screen mode
  31403. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31404. */
  31405. enterFullscreen(requestPointerLock: boolean): void;
  31406. /**
  31407. * Exits full screen mode
  31408. */
  31409. exitFullscreen(): void;
  31410. /**
  31411. * Enters Pointerlock mode
  31412. */
  31413. enterPointerlock(): void;
  31414. /**
  31415. * Exits Pointerlock mode
  31416. */
  31417. exitPointerlock(): void;
  31418. /**
  31419. * Clear the current render buffer or the current render target (if any is set up)
  31420. * @param color defines the color to use
  31421. * @param backBuffer defines if the back buffer must be cleared
  31422. * @param depth defines if the depth buffer must be cleared
  31423. * @param stencil defines if the stencil buffer must be cleared
  31424. */
  31425. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31426. /**
  31427. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31428. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31429. * @param y defines the y-coordinate of the corner of the clear rectangle
  31430. * @param width defines the width of the clear rectangle
  31431. * @param height defines the height of the clear rectangle
  31432. * @param clearColor defines the clear color
  31433. */
  31434. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31435. /**
  31436. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31437. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31438. * @param y defines the y-coordinate of the corner of the clear rectangle
  31439. * @param width defines the width of the clear rectangle
  31440. * @param height defines the height of the clear rectangle
  31441. */
  31442. enableScissor(x: number, y: number, width: number, height: number): void;
  31443. /**
  31444. * Disable previously set scissor test rectangle
  31445. */
  31446. disableScissor(): void;
  31447. private _viewportCached;
  31448. /** @hidden */
  31449. _viewport(x: number, y: number, width: number, height: number): void;
  31450. /**
  31451. * Set the WebGL's viewport
  31452. * @param viewport defines the viewport element to be used
  31453. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31454. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31455. */
  31456. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31457. /**
  31458. * Directly set the WebGL Viewport
  31459. * @param x defines the x coordinate of the viewport (in screen space)
  31460. * @param y defines the y coordinate of the viewport (in screen space)
  31461. * @param width defines the width of the viewport (in screen space)
  31462. * @param height defines the height of the viewport (in screen space)
  31463. * @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
  31464. */
  31465. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31466. /**
  31467. * Begin a new frame
  31468. */
  31469. beginFrame(): void;
  31470. /**
  31471. * Enf the current frame
  31472. */
  31473. endFrame(): void;
  31474. /**
  31475. * Resize the view according to the canvas' size
  31476. */
  31477. resize(): void;
  31478. /**
  31479. * Force a specific size of the canvas
  31480. * @param width defines the new canvas' width
  31481. * @param height defines the new canvas' height
  31482. */
  31483. setSize(width: number, height: number): void;
  31484. /**
  31485. * Binds the frame buffer to the specified texture.
  31486. * @param texture The texture to render to or null for the default canvas
  31487. * @param faceIndex The face of the texture to render to in case of cube texture
  31488. * @param requiredWidth The width of the target to render to
  31489. * @param requiredHeight The height of the target to render to
  31490. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31491. * @param depthStencilTexture The depth stencil texture to use to render
  31492. * @param lodLevel defines le lod level to bind to the frame buffer
  31493. */
  31494. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31495. /** @hidden */
  31496. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31497. /**
  31498. * Unbind the current render target texture from the webGL context
  31499. * @param texture defines the render target texture to unbind
  31500. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31501. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31502. */
  31503. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31504. /**
  31505. * Force the mipmap generation for the given render target texture
  31506. * @param texture defines the render target texture to use
  31507. */
  31508. generateMipMapsForCubemap(texture: InternalTexture): void;
  31509. /**
  31510. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31511. */
  31512. flushFramebuffer(): void;
  31513. /**
  31514. * Unbind the current render target and bind the default framebuffer
  31515. */
  31516. restoreDefaultFramebuffer(): void;
  31517. /**
  31518. * Create an uniform buffer
  31519. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31520. * @param elements defines the content of the uniform buffer
  31521. * @returns the webGL uniform buffer
  31522. */
  31523. createUniformBuffer(elements: FloatArray): DataBuffer;
  31524. /**
  31525. * Create a dynamic uniform buffer
  31526. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31527. * @param elements defines the content of the uniform buffer
  31528. * @returns the webGL uniform buffer
  31529. */
  31530. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31531. /**
  31532. * Update an existing uniform buffer
  31533. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31534. * @param uniformBuffer defines the target uniform buffer
  31535. * @param elements defines the content to update
  31536. * @param offset defines the offset in the uniform buffer where update should start
  31537. * @param count defines the size of the data to update
  31538. */
  31539. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31540. private _resetVertexBufferBinding;
  31541. /**
  31542. * Creates a vertex buffer
  31543. * @param data the data for the vertex buffer
  31544. * @returns the new WebGL static buffer
  31545. */
  31546. createVertexBuffer(data: DataArray): DataBuffer;
  31547. /**
  31548. * Creates a dynamic vertex buffer
  31549. * @param data the data for the dynamic vertex buffer
  31550. * @returns the new WebGL dynamic buffer
  31551. */
  31552. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31553. /**
  31554. * Update a dynamic index buffer
  31555. * @param indexBuffer defines the target index buffer
  31556. * @param indices defines the data to update
  31557. * @param offset defines the offset in the target index buffer where update should start
  31558. */
  31559. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31560. /**
  31561. * Updates a dynamic vertex buffer.
  31562. * @param vertexBuffer the vertex buffer to update
  31563. * @param data the data used to update the vertex buffer
  31564. * @param byteOffset the byte offset of the data
  31565. * @param byteLength the byte length of the data
  31566. */
  31567. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31568. private _resetIndexBufferBinding;
  31569. /**
  31570. * Creates a new index buffer
  31571. * @param indices defines the content of the index buffer
  31572. * @param updatable defines if the index buffer must be updatable
  31573. * @returns a new webGL buffer
  31574. */
  31575. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31576. /**
  31577. * Bind a webGL buffer to the webGL context
  31578. * @param buffer defines the buffer to bind
  31579. */
  31580. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31581. /**
  31582. * Bind an uniform buffer to the current webGL context
  31583. * @param buffer defines the buffer to bind
  31584. */
  31585. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31586. /**
  31587. * Bind a buffer to the current webGL context at a given location
  31588. * @param buffer defines the buffer to bind
  31589. * @param location defines the index where to bind the buffer
  31590. */
  31591. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31592. /**
  31593. * Bind a specific block at a given index in a specific shader program
  31594. * @param pipelineContext defines the pipeline context to use
  31595. * @param blockName defines the block name
  31596. * @param index defines the index where to bind the block
  31597. */
  31598. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31599. private bindIndexBuffer;
  31600. private bindBuffer;
  31601. /**
  31602. * update the bound buffer with the given data
  31603. * @param data defines the data to update
  31604. */
  31605. updateArrayBuffer(data: Float32Array): void;
  31606. private _vertexAttribPointer;
  31607. private _bindIndexBufferWithCache;
  31608. private _bindVertexBuffersAttributes;
  31609. /**
  31610. * Records a vertex array object
  31611. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31612. * @param vertexBuffers defines the list of vertex buffers to store
  31613. * @param indexBuffer defines the index buffer to store
  31614. * @param effect defines the effect to store
  31615. * @returns the new vertex array object
  31616. */
  31617. recordVertexArrayObject(vertexBuffers: {
  31618. [key: string]: VertexBuffer;
  31619. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31620. /**
  31621. * Bind a specific vertex array object
  31622. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31623. * @param vertexArrayObject defines the vertex array object to bind
  31624. * @param indexBuffer defines the index buffer to bind
  31625. */
  31626. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31627. /**
  31628. * Bind webGl buffers directly to the webGL context
  31629. * @param vertexBuffer defines the vertex buffer to bind
  31630. * @param indexBuffer defines the index buffer to bind
  31631. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31632. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31633. * @param effect defines the effect associated with the vertex buffer
  31634. */
  31635. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31636. private _unbindVertexArrayObject;
  31637. /**
  31638. * Bind a list of vertex buffers to the webGL context
  31639. * @param vertexBuffers defines the list of vertex buffers to bind
  31640. * @param indexBuffer defines the index buffer to bind
  31641. * @param effect defines the effect associated with the vertex buffers
  31642. */
  31643. bindBuffers(vertexBuffers: {
  31644. [key: string]: Nullable<VertexBuffer>;
  31645. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31646. /**
  31647. * Unbind all instance attributes
  31648. */
  31649. unbindInstanceAttributes(): void;
  31650. /**
  31651. * Release and free the memory of a vertex array object
  31652. * @param vao defines the vertex array object to delete
  31653. */
  31654. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31655. /** @hidden */
  31656. _releaseBuffer(buffer: DataBuffer): boolean;
  31657. /**
  31658. * Creates a webGL buffer to use with instanciation
  31659. * @param capacity defines the size of the buffer
  31660. * @returns the webGL buffer
  31661. */
  31662. createInstancesBuffer(capacity: number): DataBuffer;
  31663. /**
  31664. * Delete a webGL buffer used with instanciation
  31665. * @param buffer defines the webGL buffer to delete
  31666. */
  31667. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31668. /**
  31669. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31670. * @param instancesBuffer defines the webGL buffer to update and bind
  31671. * @param data defines the data to store in the buffer
  31672. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31673. */
  31674. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31675. /**
  31676. * Apply all cached states (depth, culling, stencil and alpha)
  31677. */
  31678. applyStates(): void;
  31679. /**
  31680. * Send a draw order
  31681. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31682. * @param indexStart defines the starting index
  31683. * @param indexCount defines the number of index to draw
  31684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31685. */
  31686. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31687. /**
  31688. * Draw a list of points
  31689. * @param verticesStart defines the index of first vertex to draw
  31690. * @param verticesCount defines the count of vertices to draw
  31691. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31692. */
  31693. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31694. /**
  31695. * Draw a list of unindexed primitives
  31696. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31697. * @param verticesStart defines the index of first vertex to draw
  31698. * @param verticesCount defines the count of vertices to draw
  31699. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31700. */
  31701. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31702. /**
  31703. * Draw a list of indexed primitives
  31704. * @param fillMode defines the primitive to use
  31705. * @param indexStart defines the starting index
  31706. * @param indexCount defines the number of index to draw
  31707. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31708. */
  31709. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31710. /**
  31711. * Draw a list of unindexed primitives
  31712. * @param fillMode defines the primitive to use
  31713. * @param verticesStart defines the index of first vertex to draw
  31714. * @param verticesCount defines the count of vertices to draw
  31715. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31716. */
  31717. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31718. private _drawMode;
  31719. /** @hidden */
  31720. _releaseEffect(effect: Effect): void;
  31721. /** @hidden */
  31722. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31723. /**
  31724. * Create a new effect (used to store vertex/fragment shaders)
  31725. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31726. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31727. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31728. * @param samplers defines an array of string used to represent textures
  31729. * @param defines defines the string containing the defines to use to compile the shaders
  31730. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31731. * @param onCompiled defines a function to call when the effect creation is successful
  31732. * @param onError defines a function to call when the effect creation has failed
  31733. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31734. * @returns the new Effect
  31735. */
  31736. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31737. private _compileShader;
  31738. private _compileRawShader;
  31739. /**
  31740. * Directly creates a webGL program
  31741. * @param pipelineContext defines the pipeline context to attach to
  31742. * @param vertexCode defines the vertex shader code to use
  31743. * @param fragmentCode defines the fragment shader code to use
  31744. * @param context defines the webGL context to use (if not set, the current one will be used)
  31745. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31746. * @returns the new webGL program
  31747. */
  31748. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31749. /**
  31750. * Creates a webGL program
  31751. * @param pipelineContext defines the pipeline context to attach to
  31752. * @param vertexCode defines the vertex shader code to use
  31753. * @param fragmentCode defines the fragment shader code to use
  31754. * @param defines defines the string containing the defines to use to compile the shaders
  31755. * @param context defines the webGL context to use (if not set, the current one will be used)
  31756. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31757. * @returns the new webGL program
  31758. */
  31759. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31760. /**
  31761. * Creates a new pipeline context
  31762. * @returns the new pipeline
  31763. */
  31764. createPipelineContext(): WebGLPipelineContext;
  31765. private _createShaderProgram;
  31766. private _finalizePipelineContext;
  31767. /** @hidden */
  31768. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31769. /** @hidden */
  31770. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31771. /** @hidden */
  31772. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31773. /**
  31774. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31775. * @param pipelineContext defines the pipeline context to use
  31776. * @param uniformsNames defines the list of uniform names
  31777. * @returns an array of webGL uniform locations
  31778. */
  31779. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31780. /**
  31781. * Gets the lsit of active attributes for a given webGL program
  31782. * @param pipelineContext defines the pipeline context to use
  31783. * @param attributesNames defines the list of attribute names to get
  31784. * @returns an array of indices indicating the offset of each attribute
  31785. */
  31786. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31787. /**
  31788. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31789. * @param effect defines the effect to activate
  31790. */
  31791. enableEffect(effect: Nullable<Effect>): void;
  31792. /**
  31793. * Set the value of an uniform to an array of int32
  31794. * @param uniform defines the webGL uniform location where to store the value
  31795. * @param array defines the array of int32 to store
  31796. */
  31797. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31798. /**
  31799. * Set the value of an uniform to an array of int32 (stored as vec2)
  31800. * @param uniform defines the webGL uniform location where to store the value
  31801. * @param array defines the array of int32 to store
  31802. */
  31803. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31804. /**
  31805. * Set the value of an uniform to an array of int32 (stored as vec3)
  31806. * @param uniform defines the webGL uniform location where to store the value
  31807. * @param array defines the array of int32 to store
  31808. */
  31809. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31810. /**
  31811. * Set the value of an uniform to an array of int32 (stored as vec4)
  31812. * @param uniform defines the webGL uniform location where to store the value
  31813. * @param array defines the array of int32 to store
  31814. */
  31815. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31816. /**
  31817. * Set the value of an uniform to an array of float32
  31818. * @param uniform defines the webGL uniform location where to store the value
  31819. * @param array defines the array of float32 to store
  31820. */
  31821. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31822. /**
  31823. * Set the value of an uniform to an array of float32 (stored as vec2)
  31824. * @param uniform defines the webGL uniform location where to store the value
  31825. * @param array defines the array of float32 to store
  31826. */
  31827. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31828. /**
  31829. * Set the value of an uniform to an array of float32 (stored as vec3)
  31830. * @param uniform defines the webGL uniform location where to store the value
  31831. * @param array defines the array of float32 to store
  31832. */
  31833. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31834. /**
  31835. * Set the value of an uniform to an array of float32 (stored as vec4)
  31836. * @param uniform defines the webGL uniform location where to store the value
  31837. * @param array defines the array of float32 to store
  31838. */
  31839. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31840. /**
  31841. * Set the value of an uniform to an array of number
  31842. * @param uniform defines the webGL uniform location where to store the value
  31843. * @param array defines the array of number to store
  31844. */
  31845. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31846. /**
  31847. * Set the value of an uniform to an array of number (stored as vec2)
  31848. * @param uniform defines the webGL uniform location where to store the value
  31849. * @param array defines the array of number to store
  31850. */
  31851. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31852. /**
  31853. * Set the value of an uniform to an array of number (stored as vec3)
  31854. * @param uniform defines the webGL uniform location where to store the value
  31855. * @param array defines the array of number to store
  31856. */
  31857. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31858. /**
  31859. * Set the value of an uniform to an array of number (stored as vec4)
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param array defines the array of number to store
  31862. */
  31863. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31864. /**
  31865. * Set the value of an uniform to an array of float32 (stored as matrices)
  31866. * @param uniform defines the webGL uniform location where to store the value
  31867. * @param matrices defines the array of float32 to store
  31868. */
  31869. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31870. /**
  31871. * Set the value of an uniform to a matrix (3x3)
  31872. * @param uniform defines the webGL uniform location where to store the value
  31873. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31874. */
  31875. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31876. /**
  31877. * Set the value of an uniform to a matrix (2x2)
  31878. * @param uniform defines the webGL uniform location where to store the value
  31879. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31880. */
  31881. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31882. /**
  31883. * Set the value of an uniform to a number (int)
  31884. * @param uniform defines the webGL uniform location where to store the value
  31885. * @param value defines the int number to store
  31886. */
  31887. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31888. /**
  31889. * Set the value of an uniform to a number (float)
  31890. * @param uniform defines the webGL uniform location where to store the value
  31891. * @param value defines the float number to store
  31892. */
  31893. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31894. /**
  31895. * Set the value of an uniform to a vec2
  31896. * @param uniform defines the webGL uniform location where to store the value
  31897. * @param x defines the 1st component of the value
  31898. * @param y defines the 2nd component of the value
  31899. */
  31900. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31901. /**
  31902. * Set the value of an uniform to a vec3
  31903. * @param uniform defines the webGL uniform location where to store the value
  31904. * @param x defines the 1st component of the value
  31905. * @param y defines the 2nd component of the value
  31906. * @param z defines the 3rd component of the value
  31907. */
  31908. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31909. /**
  31910. * Set the value of an uniform to a boolean
  31911. * @param uniform defines the webGL uniform location where to store the value
  31912. * @param bool defines the boolean to store
  31913. */
  31914. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31915. /**
  31916. * Set the value of an uniform to a vec4
  31917. * @param uniform defines the webGL uniform location where to store the value
  31918. * @param x defines the 1st component of the value
  31919. * @param y defines the 2nd component of the value
  31920. * @param z defines the 3rd component of the value
  31921. * @param w defines the 4th component of the value
  31922. */
  31923. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31924. /**
  31925. * Sets a Color4 on a uniform variable
  31926. * @param uniform defines the uniform location
  31927. * @param color4 defines the value to be set
  31928. */
  31929. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31930. /**
  31931. * Set various states to the webGL context
  31932. * @param culling defines backface culling state
  31933. * @param zOffset defines the value to apply to zOffset (0 by default)
  31934. * @param force defines if states must be applied even if cache is up to date
  31935. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31936. */
  31937. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31938. /**
  31939. * Set the z offset to apply to current rendering
  31940. * @param value defines the offset to apply
  31941. */
  31942. setZOffset(value: number): void;
  31943. /**
  31944. * Gets the current value of the zOffset
  31945. * @returns the current zOffset state
  31946. */
  31947. getZOffset(): number;
  31948. /**
  31949. * Enable or disable depth buffering
  31950. * @param enable defines the state to set
  31951. */
  31952. setDepthBuffer(enable: boolean): void;
  31953. /**
  31954. * Gets a boolean indicating if depth writing is enabled
  31955. * @returns the current depth writing state
  31956. */
  31957. getDepthWrite(): boolean;
  31958. /**
  31959. * Enable or disable depth writing
  31960. * @param enable defines the state to set
  31961. */
  31962. setDepthWrite(enable: boolean): void;
  31963. /**
  31964. * Enable or disable color writing
  31965. * @param enable defines the state to set
  31966. */
  31967. setColorWrite(enable: boolean): void;
  31968. /**
  31969. * Gets a boolean indicating if color writing is enabled
  31970. * @returns the current color writing state
  31971. */
  31972. getColorWrite(): boolean;
  31973. /**
  31974. * Sets alpha constants used by some alpha blending modes
  31975. * @param r defines the red component
  31976. * @param g defines the green component
  31977. * @param b defines the blue component
  31978. * @param a defines the alpha component
  31979. */
  31980. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31981. /**
  31982. * Sets the current alpha mode
  31983. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31984. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31985. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31986. */
  31987. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31988. /**
  31989. * Gets the current alpha mode
  31990. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31991. * @returns the current alpha mode
  31992. */
  31993. getAlphaMode(): number;
  31994. /**
  31995. * Clears the list of texture accessible through engine.
  31996. * This can help preventing texture load conflict due to name collision.
  31997. */
  31998. clearInternalTexturesCache(): void;
  31999. /**
  32000. * Force the entire cache to be cleared
  32001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32003. */
  32004. wipeCaches(bruteForce?: boolean): void;
  32005. /**
  32006. * Set the compressed texture format to use, based on the formats you have, and the formats
  32007. * supported by the hardware / browser.
  32008. *
  32009. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32010. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32011. * to API arguments needed to compressed textures. This puts the burden on the container
  32012. * generator to house the arcane code for determining these for current & future formats.
  32013. *
  32014. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32015. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32016. *
  32017. * Note: The result of this call is not taken into account when a texture is base64.
  32018. *
  32019. * @param formatsAvailable defines the list of those format families you have created
  32020. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32021. *
  32022. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32023. * @returns The extension selected.
  32024. */
  32025. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32026. /** @hidden */
  32027. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32028. min: number;
  32029. mag: number;
  32030. };
  32031. /** @hidden */
  32032. _createTexture(): WebGLTexture;
  32033. /**
  32034. * Usually called from Texture.ts.
  32035. * Passed information to create a WebGLTexture
  32036. * @param urlArg defines a value which contains one of the following:
  32037. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32038. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32039. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32041. * @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)
  32042. * @param scene needed for loading to the correct scene
  32043. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32044. * @param onLoad optional callback to be called upon successful completion
  32045. * @param onError optional callback to be called upon failure
  32046. * @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
  32047. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32048. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32049. * @param forcedExtension defines the extension to use to pick the right loader
  32050. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32052. */
  32053. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32054. /**
  32055. * @hidden
  32056. * Rescales a texture
  32057. * @param source input texutre
  32058. * @param destination destination texture
  32059. * @param scene scene to use to render the resize
  32060. * @param internalFormat format to use when resizing
  32061. * @param onComplete callback to be called when resize has completed
  32062. */
  32063. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32064. private _unpackFlipYCached;
  32065. /**
  32066. * In case you are sharing the context with other applications, it might
  32067. * be interested to not cache the unpack flip y state to ensure a consistent
  32068. * value would be set.
  32069. */
  32070. enableUnpackFlipYCached: boolean;
  32071. /** @hidden */
  32072. _unpackFlipY(value: boolean): void;
  32073. /** @hidden */
  32074. _getUnpackAlignement(): number;
  32075. /**
  32076. * Creates a dynamic texture
  32077. * @param width defines the width of the texture
  32078. * @param height defines the height of the texture
  32079. * @param generateMipMaps defines if the engine should generate the mip levels
  32080. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32081. * @returns the dynamic texture inside an InternalTexture
  32082. */
  32083. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32084. /**
  32085. * Update the sampling mode of a given texture
  32086. * @param samplingMode defines the required sampling mode
  32087. * @param texture defines the texture to update
  32088. */
  32089. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32090. /**
  32091. * Update the content of a dynamic texture
  32092. * @param texture defines the texture to update
  32093. * @param canvas defines the canvas containing the source
  32094. * @param invertY defines if data must be stored with Y axis inverted
  32095. * @param premulAlpha defines if alpha is stored as premultiplied
  32096. * @param format defines the format of the data
  32097. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32098. */
  32099. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32100. /**
  32101. * Update a video texture
  32102. * @param texture defines the texture to update
  32103. * @param video defines the video element to use
  32104. * @param invertY defines if data must be stored with Y axis inverted
  32105. */
  32106. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32107. /**
  32108. * Updates a depth texture Comparison Mode and Function.
  32109. * If the comparison Function is equal to 0, the mode will be set to none.
  32110. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32111. * @param texture The texture to set the comparison function for
  32112. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32113. */
  32114. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32115. /** @hidden */
  32116. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32117. width: number;
  32118. height: number;
  32119. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32120. /**
  32121. * Creates a depth stencil texture.
  32122. * This is only available in WebGL 2 or with the depth texture extension available.
  32123. * @param size The size of face edge in the texture.
  32124. * @param options The options defining the texture.
  32125. * @returns The texture
  32126. */
  32127. createDepthStencilTexture(size: number | {
  32128. width: number;
  32129. height: number;
  32130. }, options: DepthTextureCreationOptions): InternalTexture;
  32131. /**
  32132. * Creates a depth stencil texture.
  32133. * This is only available in WebGL 2 or with the depth texture extension available.
  32134. * @param size The size of face edge in the texture.
  32135. * @param options The options defining the texture.
  32136. * @returns The texture
  32137. */
  32138. private _createDepthStencilTexture;
  32139. /**
  32140. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32141. * @param renderTarget The render target to set the frame buffer for
  32142. */
  32143. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32144. /**
  32145. * Creates a new render target texture
  32146. * @param size defines the size of the texture
  32147. * @param options defines the options used to create the texture
  32148. * @returns a new render target texture stored in an InternalTexture
  32149. */
  32150. createRenderTargetTexture(size: number | {
  32151. width: number;
  32152. height: number;
  32153. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32154. /** @hidden */
  32155. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32156. /**
  32157. * Updates the sample count of a render target texture
  32158. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32159. * @param texture defines the texture to update
  32160. * @param samples defines the sample count to set
  32161. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32162. */
  32163. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32164. /** @hidden */
  32165. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32166. /** @hidden */
  32167. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32168. /** @hidden */
  32169. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32170. /** @hidden */
  32171. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32172. /**
  32173. * @hidden
  32174. */
  32175. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32176. private _prepareWebGLTextureContinuation;
  32177. private _prepareWebGLTexture;
  32178. /** @hidden */
  32179. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32180. /** @hidden */
  32181. _releaseFramebufferObjects(texture: InternalTexture): void;
  32182. /** @hidden */
  32183. _releaseTexture(texture: InternalTexture): void;
  32184. private setProgram;
  32185. private _boundUniforms;
  32186. /**
  32187. * Binds an effect to the webGL context
  32188. * @param effect defines the effect to bind
  32189. */
  32190. bindSamplers(effect: Effect): void;
  32191. private _activateCurrentTexture;
  32192. /** @hidden */
  32193. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32194. /** @hidden */
  32195. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32196. /**
  32197. * Sets a texture to the webGL context from a postprocess
  32198. * @param channel defines the channel to use
  32199. * @param postProcess defines the source postprocess
  32200. */
  32201. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32202. /**
  32203. * Binds the output of the passed in post process to the texture channel specified
  32204. * @param channel The channel the texture should be bound to
  32205. * @param postProcess The post process which's output should be bound
  32206. */
  32207. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32208. /**
  32209. * Unbind all textures from the webGL context
  32210. */
  32211. unbindAllTextures(): void;
  32212. /**
  32213. * Sets a texture to the according uniform.
  32214. * @param channel The texture channel
  32215. * @param uniform The uniform to set
  32216. * @param texture The texture to apply
  32217. */
  32218. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32219. /**
  32220. * Sets a depth stencil texture from a render target to the according uniform.
  32221. * @param channel The texture channel
  32222. * @param uniform The uniform to set
  32223. * @param texture The render target texture containing the depth stencil texture to apply
  32224. */
  32225. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32226. private _bindSamplerUniformToChannel;
  32227. private _getTextureWrapMode;
  32228. private _setTexture;
  32229. /**
  32230. * Sets an array of texture to the webGL context
  32231. * @param channel defines the channel where the texture array must be set
  32232. * @param uniform defines the associated uniform location
  32233. * @param textures defines the array of textures to bind
  32234. */
  32235. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32236. /** @hidden */
  32237. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32238. private _setTextureParameterFloat;
  32239. private _setTextureParameterInteger;
  32240. /**
  32241. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32242. * @param x defines the x coordinate of the rectangle where pixels must be read
  32243. * @param y defines the y coordinate of the rectangle where pixels must be read
  32244. * @param width defines the width of the rectangle where pixels must be read
  32245. * @param height defines the height of the rectangle where pixels must be read
  32246. * @returns a Uint8Array containing RGBA colors
  32247. */
  32248. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32249. /**
  32250. * Add an externaly attached data from its key.
  32251. * This method call will fail and return false, if such key already exists.
  32252. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32253. * @param key the unique key that identifies the data
  32254. * @param data the data object to associate to the key for this Engine instance
  32255. * @return true if no such key were already present and the data was added successfully, false otherwise
  32256. */
  32257. addExternalData<T>(key: string, data: T): boolean;
  32258. /**
  32259. * Get an externaly attached data from its key
  32260. * @param key the unique key that identifies the data
  32261. * @return the associated data, if present (can be null), or undefined if not present
  32262. */
  32263. getExternalData<T>(key: string): T;
  32264. /**
  32265. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32266. * @param key the unique key that identifies the data
  32267. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32268. * @return the associated data, can be null if the factory returned null.
  32269. */
  32270. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32271. /**
  32272. * Remove an externaly attached data from the Engine instance
  32273. * @param key the unique key that identifies the data
  32274. * @return true if the data was successfully removed, false if it doesn't exist
  32275. */
  32276. removeExternalData(key: string): boolean;
  32277. /**
  32278. * Unbind all vertex attributes from the webGL context
  32279. */
  32280. unbindAllAttributes(): void;
  32281. /**
  32282. * 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
  32283. */
  32284. releaseEffects(): void;
  32285. /**
  32286. * Dispose and release all associated resources
  32287. */
  32288. dispose(): void;
  32289. /**
  32290. * Display the loading screen
  32291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32292. */
  32293. displayLoadingUI(): void;
  32294. /**
  32295. * Hide the loading screen
  32296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32297. */
  32298. hideLoadingUI(): void;
  32299. /**
  32300. * Gets the current loading screen object
  32301. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32302. */
  32303. /**
  32304. * Sets the current loading screen object
  32305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32306. */
  32307. loadingScreen: ILoadingScreen;
  32308. /**
  32309. * Sets the current loading screen text
  32310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32311. */
  32312. loadingUIText: string;
  32313. /**
  32314. * Sets the current loading screen background color
  32315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32316. */
  32317. loadingUIBackgroundColor: string;
  32318. /**
  32319. * Attach a new callback raised when context lost event is fired
  32320. * @param callback defines the callback to call
  32321. */
  32322. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32323. /**
  32324. * Attach a new callback raised when context restored event is fired
  32325. * @param callback defines the callback to call
  32326. */
  32327. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32328. /**
  32329. * Gets the source code of the vertex shader associated with a specific webGL program
  32330. * @param program defines the program to use
  32331. * @returns a string containing the source code of the vertex shader associated with the program
  32332. */
  32333. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32334. /**
  32335. * Gets the source code of the fragment shader associated with a specific webGL program
  32336. * @param program defines the program to use
  32337. * @returns a string containing the source code of the fragment shader associated with the program
  32338. */
  32339. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32340. /**
  32341. * Get the current error code of the webGL context
  32342. * @returns the error code
  32343. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32344. */
  32345. getError(): number;
  32346. /**
  32347. * Gets the current framerate
  32348. * @returns a number representing the framerate
  32349. */
  32350. getFps(): number;
  32351. /**
  32352. * Gets the time spent between current and previous frame
  32353. * @returns a number representing the delta time in ms
  32354. */
  32355. getDeltaTime(): number;
  32356. private _measureFps;
  32357. /** @hidden */
  32358. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32359. private _canRenderToFloatFramebuffer;
  32360. private _canRenderToHalfFloatFramebuffer;
  32361. private _canRenderToFramebuffer;
  32362. /** @hidden */
  32363. _getWebGLTextureType(type: number): number;
  32364. /** @hidden */
  32365. _getInternalFormat(format: number): number;
  32366. /** @hidden */
  32367. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32368. /** @hidden */
  32369. _getRGBAMultiSampleBufferFormat(type: number): number;
  32370. /** @hidden */
  32371. _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;
  32372. /** @hidden */
  32373. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32374. /**
  32375. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32376. * @returns true if the engine can be created
  32377. * @ignorenaming
  32378. */
  32379. static isSupported(): boolean;
  32380. /**
  32381. * Find the next highest power of two.
  32382. * @param x Number to start search from.
  32383. * @return Next highest power of two.
  32384. */
  32385. static CeilingPOT(x: number): number;
  32386. /**
  32387. * Find the next lowest power of two.
  32388. * @param x Number to start search from.
  32389. * @return Next lowest power of two.
  32390. */
  32391. static FloorPOT(x: number): number;
  32392. /**
  32393. * Find the nearest power of two.
  32394. * @param x Number to start search from.
  32395. * @return Next nearest power of two.
  32396. */
  32397. static NearestPOT(x: number): number;
  32398. /**
  32399. * Get the closest exponent of two
  32400. * @param value defines the value to approximate
  32401. * @param max defines the maximum value to return
  32402. * @param mode defines how to define the closest value
  32403. * @returns closest exponent of two of the given value
  32404. */
  32405. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32406. /**
  32407. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32408. * @param func - the function to be called
  32409. * @param requester - the object that will request the next frame. Falls back to window.
  32410. * @returns frame number
  32411. */
  32412. static QueueNewFrame(func: () => void, requester?: any): number;
  32413. /**
  32414. * Ask the browser to promote the current element to pointerlock mode
  32415. * @param element defines the DOM element to promote
  32416. */
  32417. static _RequestPointerlock(element: HTMLElement): void;
  32418. /**
  32419. * Asks the browser to exit pointerlock mode
  32420. */
  32421. static _ExitPointerlock(): void;
  32422. /**
  32423. * Ask the browser to promote the current element to fullscreen rendering mode
  32424. * @param element defines the DOM element to promote
  32425. */
  32426. static _RequestFullscreen(element: HTMLElement): void;
  32427. /**
  32428. * Asks the browser to exit fullscreen mode
  32429. */
  32430. static _ExitFullscreen(): void;
  32431. }
  32432. }
  32433. declare module "babylonjs/Engines/engineStore" {
  32434. import { Nullable } from "babylonjs/types";
  32435. import { Engine } from "babylonjs/Engines/engine";
  32436. import { Scene } from "babylonjs/scene";
  32437. /**
  32438. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32439. * during the life time of the application.
  32440. */
  32441. export class EngineStore {
  32442. /** Gets the list of created engines */
  32443. static Instances: import("babylonjs/Engines/engine").Engine[];
  32444. /** @hidden */
  32445. static _LastCreatedScene: Nullable<Scene>;
  32446. /**
  32447. * Gets the latest created engine
  32448. */
  32449. static readonly LastCreatedEngine: Nullable<Engine>;
  32450. /**
  32451. * Gets the latest created scene
  32452. */
  32453. static readonly LastCreatedScene: Nullable<Scene>;
  32454. /**
  32455. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32456. * @ignorenaming
  32457. */
  32458. static UseFallbackTexture: boolean;
  32459. /**
  32460. * Texture content used if a texture cannot loaded
  32461. * @ignorenaming
  32462. */
  32463. static FallbackTexture: string;
  32464. }
  32465. }
  32466. declare module "babylonjs/Misc/promise" {
  32467. /**
  32468. * Helper class that provides a small promise polyfill
  32469. */
  32470. export class PromisePolyfill {
  32471. /**
  32472. * Static function used to check if the polyfill is required
  32473. * If this is the case then the function will inject the polyfill to window.Promise
  32474. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32475. */
  32476. static Apply(force?: boolean): void;
  32477. }
  32478. }
  32479. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32480. /**
  32481. * Interface for screenshot methods with describe argument called `size` as object with options
  32482. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32483. */
  32484. export interface IScreenshotSize {
  32485. /**
  32486. * number in pixels for canvas height
  32487. */
  32488. height?: number;
  32489. /**
  32490. * multiplier allowing render at a higher or lower resolution
  32491. * If value is defined then height and width will be ignored and taken from camera
  32492. */
  32493. precision?: number;
  32494. /**
  32495. * number in pixels for canvas width
  32496. */
  32497. width?: number;
  32498. }
  32499. }
  32500. declare module "babylonjs/Misc/tools" {
  32501. import { Nullable, float } from "babylonjs/types";
  32502. import { DomManagement } from "babylonjs/Misc/domManagement";
  32503. import { WebRequest } from "babylonjs/Misc/webRequest";
  32504. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32505. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32506. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32507. import { Camera } from "babylonjs/Cameras/camera";
  32508. import { Engine } from "babylonjs/Engines/engine";
  32509. interface IColor4Like {
  32510. r: float;
  32511. g: float;
  32512. b: float;
  32513. a: float;
  32514. }
  32515. /**
  32516. * Class containing a set of static utilities functions
  32517. */
  32518. export class Tools {
  32519. /**
  32520. * Gets or sets the base URL to use to load assets
  32521. */
  32522. static BaseUrl: string;
  32523. /**
  32524. * Enable/Disable Custom HTTP Request Headers globally.
  32525. * default = false
  32526. * @see CustomRequestHeaders
  32527. */
  32528. static UseCustomRequestHeaders: boolean;
  32529. /**
  32530. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32531. * i.e. when loading files, where the server/service expects an Authorization header
  32532. */
  32533. static CustomRequestHeaders: {
  32534. [key: string]: string;
  32535. };
  32536. /**
  32537. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32538. */
  32539. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32540. /**
  32541. * Default behaviour for cors in the application.
  32542. * It can be a string if the expected behavior is identical in the entire app.
  32543. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32544. */
  32545. static CorsBehavior: string | ((url: string | string[]) => string);
  32546. /**
  32547. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32548. * @ignorenaming
  32549. */
  32550. static UseFallbackTexture: boolean;
  32551. /**
  32552. * Use this object to register external classes like custom textures or material
  32553. * to allow the laoders to instantiate them
  32554. */
  32555. static RegisteredExternalClasses: {
  32556. [key: string]: Object;
  32557. };
  32558. /**
  32559. * Texture content used if a texture cannot loaded
  32560. * @ignorenaming
  32561. */
  32562. static fallbackTexture: string;
  32563. /**
  32564. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32565. * @param u defines the coordinate on X axis
  32566. * @param v defines the coordinate on Y axis
  32567. * @param width defines the width of the source data
  32568. * @param height defines the height of the source data
  32569. * @param pixels defines the source byte array
  32570. * @param color defines the output color
  32571. */
  32572. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32573. /**
  32574. * Interpolates between a and b via alpha
  32575. * @param a The lower value (returned when alpha = 0)
  32576. * @param b The upper value (returned when alpha = 1)
  32577. * @param alpha The interpolation-factor
  32578. * @return The mixed value
  32579. */
  32580. static Mix(a: number, b: number, alpha: number): number;
  32581. /**
  32582. * Tries to instantiate a new object from a given class name
  32583. * @param className defines the class name to instantiate
  32584. * @returns the new object or null if the system was not able to do the instantiation
  32585. */
  32586. static Instantiate(className: string): any;
  32587. /**
  32588. * Provides a slice function that will work even on IE
  32589. * @param data defines the array to slice
  32590. * @param start defines the start of the data (optional)
  32591. * @param end defines the end of the data (optional)
  32592. * @returns the new sliced array
  32593. */
  32594. static Slice<T>(data: T, start?: number, end?: number): T;
  32595. /**
  32596. * Polyfill for setImmediate
  32597. * @param action defines the action to execute after the current execution block
  32598. */
  32599. static SetImmediate(action: () => void): void;
  32600. /**
  32601. * Function indicating if a number is an exponent of 2
  32602. * @param value defines the value to test
  32603. * @returns true if the value is an exponent of 2
  32604. */
  32605. static IsExponentOfTwo(value: number): boolean;
  32606. private static _tmpFloatArray;
  32607. /**
  32608. * Returns the nearest 32-bit single precision float representation of a Number
  32609. * @param value A Number. If the parameter is of a different type, it will get converted
  32610. * to a number or to NaN if it cannot be converted
  32611. * @returns number
  32612. */
  32613. static FloatRound(value: number): number;
  32614. /**
  32615. * Extracts the filename from a path
  32616. * @param path defines the path to use
  32617. * @returns the filename
  32618. */
  32619. static GetFilename(path: string): string;
  32620. /**
  32621. * Extracts the "folder" part of a path (everything before the filename).
  32622. * @param uri The URI to extract the info from
  32623. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32624. * @returns The "folder" part of the path
  32625. */
  32626. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32627. /**
  32628. * Extracts text content from a DOM element hierarchy
  32629. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32630. */
  32631. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32632. /**
  32633. * Convert an angle in radians to degrees
  32634. * @param angle defines the angle to convert
  32635. * @returns the angle in degrees
  32636. */
  32637. static ToDegrees(angle: number): number;
  32638. /**
  32639. * Convert an angle in degrees to radians
  32640. * @param angle defines the angle to convert
  32641. * @returns the angle in radians
  32642. */
  32643. static ToRadians(angle: number): number;
  32644. /**
  32645. * Encode a buffer to a base64 string
  32646. * @param buffer defines the buffer to encode
  32647. * @returns the encoded string
  32648. */
  32649. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32650. /**
  32651. * Returns an array if obj is not an array
  32652. * @param obj defines the object to evaluate as an array
  32653. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32654. * @returns either obj directly if obj is an array or a new array containing obj
  32655. */
  32656. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32657. /**
  32658. * Gets the pointer prefix to use
  32659. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32660. */
  32661. static GetPointerPrefix(): string;
  32662. /**
  32663. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32664. * @param url define the url we are trying
  32665. * @param element define the dom element where to configure the cors policy
  32666. */
  32667. static SetCorsBehavior(url: string | string[], element: {
  32668. crossOrigin: string | null;
  32669. }): void;
  32670. /**
  32671. * Removes unwanted characters from an url
  32672. * @param url defines the url to clean
  32673. * @returns the cleaned url
  32674. */
  32675. static CleanUrl(url: string): string;
  32676. /**
  32677. * Gets or sets a function used to pre-process url before using them to load assets
  32678. */
  32679. static PreprocessUrl: (url: string) => string;
  32680. /**
  32681. * Loads an image as an HTMLImageElement.
  32682. * @param input url string, ArrayBuffer, or Blob to load
  32683. * @param onLoad callback called when the image successfully loads
  32684. * @param onError callback called when the image fails to load
  32685. * @param offlineProvider offline provider for caching
  32686. * @returns the HTMLImageElement of the loaded image
  32687. */
  32688. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32689. /**
  32690. * Loads a file
  32691. * @param url url string, ArrayBuffer, or Blob to load
  32692. * @param onSuccess callback called when the file successfully loads
  32693. * @param onProgress callback called while file is loading (if the server supports this mode)
  32694. * @param offlineProvider defines the offline provider for caching
  32695. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32696. * @param onError callback called when the file fails to load
  32697. * @returns a file request object
  32698. */
  32699. 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;
  32700. /**
  32701. * Loads a file from a url
  32702. * @param url the file url to load
  32703. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32704. */
  32705. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32706. /**
  32707. * Load a script (identified by an url). When the url returns, the
  32708. * content of this file is added into a new script element, attached to the DOM (body element)
  32709. * @param scriptUrl defines the url of the script to laod
  32710. * @param onSuccess defines the callback called when the script is loaded
  32711. * @param onError defines the callback to call if an error occurs
  32712. * @param scriptId defines the id of the script element
  32713. */
  32714. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32715. /**
  32716. * Load an asynchronous script (identified by an url). When the url returns, the
  32717. * content of this file is added into a new script element, attached to the DOM (body element)
  32718. * @param scriptUrl defines the url of the script to laod
  32719. * @param scriptId defines the id of the script element
  32720. * @returns a promise request object
  32721. */
  32722. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32723. /**
  32724. * Loads a file from a blob
  32725. * @param fileToLoad defines the blob to use
  32726. * @param callback defines the callback to call when data is loaded
  32727. * @param progressCallback defines the callback to call during loading process
  32728. * @returns a file request object
  32729. */
  32730. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32731. /**
  32732. * Loads a file
  32733. * @param fileToLoad defines the file to load
  32734. * @param callback defines the callback to call when data is loaded
  32735. * @param progressCallBack defines the callback to call during loading process
  32736. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32737. * @returns a file request object
  32738. */
  32739. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32740. /**
  32741. * Creates a data url from a given string content
  32742. * @param content defines the content to convert
  32743. * @returns the new data url link
  32744. */
  32745. static FileAsURL(content: string): string;
  32746. /**
  32747. * Format the given number to a specific decimal format
  32748. * @param value defines the number to format
  32749. * @param decimals defines the number of decimals to use
  32750. * @returns the formatted string
  32751. */
  32752. static Format(value: number, decimals?: number): string;
  32753. /**
  32754. * Tries to copy an object by duplicating every property
  32755. * @param source defines the source object
  32756. * @param destination defines the target object
  32757. * @param doNotCopyList defines a list of properties to avoid
  32758. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32759. */
  32760. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32761. /**
  32762. * Gets a boolean indicating if the given object has no own property
  32763. * @param obj defines the object to test
  32764. * @returns true if object has no own property
  32765. */
  32766. static IsEmpty(obj: any): boolean;
  32767. /**
  32768. * Function used to register events at window level
  32769. * @param windowElement defines the Window object to use
  32770. * @param events defines the events to register
  32771. */
  32772. static RegisterTopRootEvents(windowElement: Window, events: {
  32773. name: string;
  32774. handler: Nullable<(e: FocusEvent) => any>;
  32775. }[]): void;
  32776. /**
  32777. * Function used to unregister events from window level
  32778. * @param windowElement defines the Window object to use
  32779. * @param events defines the events to unregister
  32780. */
  32781. static UnregisterTopRootEvents(windowElement: Window, events: {
  32782. name: string;
  32783. handler: Nullable<(e: FocusEvent) => any>;
  32784. }[]): void;
  32785. /**
  32786. * @ignore
  32787. */
  32788. static _ScreenshotCanvas: HTMLCanvasElement;
  32789. /**
  32790. * Dumps the current bound framebuffer
  32791. * @param width defines the rendering width
  32792. * @param height defines the rendering height
  32793. * @param engine defines the hosting engine
  32794. * @param successCallback defines the callback triggered once the data are available
  32795. * @param mimeType defines the mime type of the result
  32796. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32797. */
  32798. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32799. /**
  32800. * Converts the canvas data to blob.
  32801. * This acts as a polyfill for browsers not supporting the to blob function.
  32802. * @param canvas Defines the canvas to extract the data from
  32803. * @param successCallback Defines the callback triggered once the data are available
  32804. * @param mimeType Defines the mime type of the result
  32805. */
  32806. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32807. /**
  32808. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32809. * @param successCallback defines the callback triggered once the data are available
  32810. * @param mimeType defines the mime type of the result
  32811. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32812. */
  32813. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32814. /**
  32815. * Downloads a blob in the browser
  32816. * @param blob defines the blob to download
  32817. * @param fileName defines the name of the downloaded file
  32818. */
  32819. static Download(blob: Blob, fileName: string): void;
  32820. /**
  32821. * Captures a screenshot of the current rendering
  32822. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32823. * @param engine defines the rendering engine
  32824. * @param camera defines the source camera
  32825. * @param size This parameter can be set to a single number or to an object with the
  32826. * following (optional) properties: precision, width, height. If a single number is passed,
  32827. * it will be used for both width and height. If an object is passed, the screenshot size
  32828. * will be derived from the parameters. The precision property is a multiplier allowing
  32829. * rendering at a higher or lower resolution
  32830. * @param successCallback defines the callback receives a single parameter which contains the
  32831. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32832. * src parameter of an <img> to display it
  32833. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32834. * Check your browser for supported MIME types
  32835. */
  32836. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32837. /**
  32838. * Captures a screenshot of the current rendering
  32839. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32840. * @param engine defines the rendering engine
  32841. * @param camera defines the source camera
  32842. * @param size This parameter can be set to a single number or to an object with the
  32843. * following (optional) properties: precision, width, height. If a single number is passed,
  32844. * it will be used for both width and height. If an object is passed, the screenshot size
  32845. * will be derived from the parameters. The precision property is a multiplier allowing
  32846. * rendering at a higher or lower resolution
  32847. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32848. * Check your browser for supported MIME types
  32849. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32850. * to the src parameter of an <img> to display it
  32851. */
  32852. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32853. /**
  32854. * Generates an image screenshot from the specified camera.
  32855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32856. * @param engine The engine to use for rendering
  32857. * @param camera The camera to use for rendering
  32858. * @param size This parameter can be set to a single number or to an object with the
  32859. * following (optional) properties: precision, width, height. If a single number is passed,
  32860. * it will be used for both width and height. If an object is passed, the screenshot size
  32861. * will be derived from the parameters. The precision property is a multiplier allowing
  32862. * rendering at a higher or lower resolution
  32863. * @param successCallback The callback receives a single parameter which contains the
  32864. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32865. * src parameter of an <img> to display it
  32866. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32867. * Check your browser for supported MIME types
  32868. * @param samples Texture samples (default: 1)
  32869. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32870. * @param fileName A name for for the downloaded file.
  32871. */
  32872. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32873. /**
  32874. * Generates an image screenshot from the specified camera.
  32875. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32876. * @param engine The engine to use for rendering
  32877. * @param camera The camera to use for rendering
  32878. * @param size This parameter can be set to a single number or to an object with the
  32879. * following (optional) properties: precision, width, height. If a single number is passed,
  32880. * it will be used for both width and height. If an object is passed, the screenshot size
  32881. * will be derived from the parameters. The precision property is a multiplier allowing
  32882. * rendering at a higher or lower resolution
  32883. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32884. * Check your browser for supported MIME types
  32885. * @param samples Texture samples (default: 1)
  32886. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32887. * @param fileName A name for for the downloaded file.
  32888. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32889. * to the src parameter of an <img> to display it
  32890. */
  32891. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32892. /**
  32893. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32894. * Be aware Math.random() could cause collisions, but:
  32895. * "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"
  32896. * @returns a pseudo random id
  32897. */
  32898. static RandomId(): string;
  32899. /**
  32900. * Test if the given uri is a base64 string
  32901. * @param uri The uri to test
  32902. * @return True if the uri is a base64 string or false otherwise
  32903. */
  32904. static IsBase64(uri: string): boolean;
  32905. /**
  32906. * Decode the given base64 uri.
  32907. * @param uri The uri to decode
  32908. * @return The decoded base64 data.
  32909. */
  32910. static DecodeBase64(uri: string): ArrayBuffer;
  32911. /**
  32912. * Gets the absolute url.
  32913. * @param url the input url
  32914. * @return the absolute url
  32915. */
  32916. static GetAbsoluteUrl(url: string): string;
  32917. /**
  32918. * No log
  32919. */
  32920. static readonly NoneLogLevel: number;
  32921. /**
  32922. * Only message logs
  32923. */
  32924. static readonly MessageLogLevel: number;
  32925. /**
  32926. * Only warning logs
  32927. */
  32928. static readonly WarningLogLevel: number;
  32929. /**
  32930. * Only error logs
  32931. */
  32932. static readonly ErrorLogLevel: number;
  32933. /**
  32934. * All logs
  32935. */
  32936. static readonly AllLogLevel: number;
  32937. /**
  32938. * Gets a value indicating the number of loading errors
  32939. * @ignorenaming
  32940. */
  32941. static readonly errorsCount: number;
  32942. /**
  32943. * Callback called when a new log is added
  32944. */
  32945. static OnNewCacheEntry: (entry: string) => void;
  32946. /**
  32947. * Log a message to the console
  32948. * @param message defines the message to log
  32949. */
  32950. static Log(message: string): void;
  32951. /**
  32952. * Write a warning message to the console
  32953. * @param message defines the message to log
  32954. */
  32955. static Warn(message: string): void;
  32956. /**
  32957. * Write an error message to the console
  32958. * @param message defines the message to log
  32959. */
  32960. static Error(message: string): void;
  32961. /**
  32962. * Gets current log cache (list of logs)
  32963. */
  32964. static readonly LogCache: string;
  32965. /**
  32966. * Clears the log cache
  32967. */
  32968. static ClearLogCache(): void;
  32969. /**
  32970. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32971. */
  32972. static LogLevels: number;
  32973. /**
  32974. * Checks if the window object exists
  32975. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32976. */
  32977. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32978. /**
  32979. * No performance log
  32980. */
  32981. static readonly PerformanceNoneLogLevel: number;
  32982. /**
  32983. * Use user marks to log performance
  32984. */
  32985. static readonly PerformanceUserMarkLogLevel: number;
  32986. /**
  32987. * Log performance to the console
  32988. */
  32989. static readonly PerformanceConsoleLogLevel: number;
  32990. private static _performance;
  32991. /**
  32992. * Sets the current performance log level
  32993. */
  32994. static PerformanceLogLevel: number;
  32995. private static _StartPerformanceCounterDisabled;
  32996. private static _EndPerformanceCounterDisabled;
  32997. private static _StartUserMark;
  32998. private static _EndUserMark;
  32999. private static _StartPerformanceConsole;
  33000. private static _EndPerformanceConsole;
  33001. /**
  33002. * Starts a performance counter
  33003. */
  33004. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33005. /**
  33006. * Ends a specific performance coutner
  33007. */
  33008. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33009. /**
  33010. * Gets either window.performance.now() if supported or Date.now() else
  33011. */
  33012. static readonly Now: number;
  33013. /**
  33014. * This method will return the name of the class used to create the instance of the given object.
  33015. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33016. * @param object the object to get the class name from
  33017. * @param isType defines if the object is actually a type
  33018. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33019. */
  33020. static GetClassName(object: any, isType?: boolean): string;
  33021. /**
  33022. * Gets the first element of an array satisfying a given predicate
  33023. * @param array defines the array to browse
  33024. * @param predicate defines the predicate to use
  33025. * @returns null if not found or the element
  33026. */
  33027. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33028. /**
  33029. * This method will return the name of the full name of the class, including its owning module (if any).
  33030. * 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).
  33031. * @param object the object to get the class name from
  33032. * @param isType defines if the object is actually a type
  33033. * @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.
  33034. * @ignorenaming
  33035. */
  33036. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33037. /**
  33038. * Returns a promise that resolves after the given amount of time.
  33039. * @param delay Number of milliseconds to delay
  33040. * @returns Promise that resolves after the given amount of time
  33041. */
  33042. static DelayAsync(delay: number): Promise<void>;
  33043. }
  33044. /**
  33045. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33046. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33047. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33048. * @param name The name of the class, case should be preserved
  33049. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33050. */
  33051. export function className(name: string, module?: string): (target: Object) => void;
  33052. /**
  33053. * An implementation of a loop for asynchronous functions.
  33054. */
  33055. export class AsyncLoop {
  33056. /**
  33057. * Defines the number of iterations for the loop
  33058. */
  33059. iterations: number;
  33060. /**
  33061. * Defines the current index of the loop.
  33062. */
  33063. index: number;
  33064. private _done;
  33065. private _fn;
  33066. private _successCallback;
  33067. /**
  33068. * Constructor.
  33069. * @param iterations the number of iterations.
  33070. * @param func the function to run each iteration
  33071. * @param successCallback the callback that will be called upon succesful execution
  33072. * @param offset starting offset.
  33073. */
  33074. constructor(
  33075. /**
  33076. * Defines the number of iterations for the loop
  33077. */
  33078. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33079. /**
  33080. * Execute the next iteration. Must be called after the last iteration was finished.
  33081. */
  33082. executeNext(): void;
  33083. /**
  33084. * Break the loop and run the success callback.
  33085. */
  33086. breakLoop(): void;
  33087. /**
  33088. * Create and run an async loop.
  33089. * @param iterations the number of iterations.
  33090. * @param fn the function to run each iteration
  33091. * @param successCallback the callback that will be called upon succesful execution
  33092. * @param offset starting offset.
  33093. * @returns the created async loop object
  33094. */
  33095. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33096. /**
  33097. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33098. * @param iterations total number of iterations
  33099. * @param syncedIterations number of synchronous iterations in each async iteration.
  33100. * @param fn the function to call each iteration.
  33101. * @param callback a success call back that will be called when iterating stops.
  33102. * @param breakFunction a break condition (optional)
  33103. * @param timeout timeout settings for the setTimeout function. default - 0.
  33104. * @returns the created async loop object
  33105. */
  33106. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33107. }
  33108. }
  33109. declare module "babylonjs/Collisions/collisionCoordinator" {
  33110. import { Nullable } from "babylonjs/types";
  33111. import { Scene } from "babylonjs/scene";
  33112. import { Vector3 } from "babylonjs/Maths/math.vector";
  33113. import { Collider } from "babylonjs/Collisions/collider";
  33114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33115. /** @hidden */
  33116. export interface ICollisionCoordinator {
  33117. createCollider(): Collider;
  33118. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33119. init(scene: Scene): void;
  33120. }
  33121. /** @hidden */
  33122. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33123. private _scene;
  33124. private _scaledPosition;
  33125. private _scaledVelocity;
  33126. private _finalPosition;
  33127. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33128. createCollider(): Collider;
  33129. init(scene: Scene): void;
  33130. private _collideWithWorld;
  33131. }
  33132. }
  33133. declare module "babylonjs/Inputs/scene.inputManager" {
  33134. import { Nullable } from "babylonjs/types";
  33135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33136. import { Vector2 } from "babylonjs/Maths/math.vector";
  33137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33138. import { Scene } from "babylonjs/scene";
  33139. /**
  33140. * Class used to manage all inputs for the scene.
  33141. */
  33142. export class InputManager {
  33143. /** The distance in pixel that you have to move to prevent some events */
  33144. static DragMovementThreshold: number;
  33145. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33146. static LongPressDelay: number;
  33147. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33148. static DoubleClickDelay: number;
  33149. /** If you need to check double click without raising a single click at first click, enable this flag */
  33150. static ExclusiveDoubleClickMode: boolean;
  33151. private _wheelEventName;
  33152. private _onPointerMove;
  33153. private _onPointerDown;
  33154. private _onPointerUp;
  33155. private _initClickEvent;
  33156. private _initActionManager;
  33157. private _delayedSimpleClick;
  33158. private _delayedSimpleClickTimeout;
  33159. private _previousDelayedSimpleClickTimeout;
  33160. private _meshPickProceed;
  33161. private _previousButtonPressed;
  33162. private _currentPickResult;
  33163. private _previousPickResult;
  33164. private _totalPointersPressed;
  33165. private _doubleClickOccured;
  33166. private _pointerOverMesh;
  33167. private _pickedDownMesh;
  33168. private _pickedUpMesh;
  33169. private _pointerX;
  33170. private _pointerY;
  33171. private _unTranslatedPointerX;
  33172. private _unTranslatedPointerY;
  33173. private _startingPointerPosition;
  33174. private _previousStartingPointerPosition;
  33175. private _startingPointerTime;
  33176. private _previousStartingPointerTime;
  33177. private _pointerCaptures;
  33178. private _onKeyDown;
  33179. private _onKeyUp;
  33180. private _onCanvasFocusObserver;
  33181. private _onCanvasBlurObserver;
  33182. private _scene;
  33183. /**
  33184. * Creates a new InputManager
  33185. * @param scene defines the hosting scene
  33186. */
  33187. constructor(scene: Scene);
  33188. /**
  33189. * Gets the mesh that is currently under the pointer
  33190. */
  33191. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33192. /**
  33193. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33194. */
  33195. readonly unTranslatedPointer: Vector2;
  33196. /**
  33197. * Gets or sets the current on-screen X position of the pointer
  33198. */
  33199. pointerX: number;
  33200. /**
  33201. * Gets or sets the current on-screen Y position of the pointer
  33202. */
  33203. pointerY: number;
  33204. private _updatePointerPosition;
  33205. private _processPointerMove;
  33206. private _setRayOnPointerInfo;
  33207. private _checkPrePointerObservable;
  33208. /**
  33209. * Use this method to simulate a pointer move on a mesh
  33210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33213. */
  33214. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33215. /**
  33216. * Use this method to simulate a pointer down on a mesh
  33217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33220. */
  33221. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33222. private _processPointerDown;
  33223. /** @hidden */
  33224. _isPointerSwiping(): boolean;
  33225. /**
  33226. * Use this method to simulate a pointer up on a mesh
  33227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33230. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33231. */
  33232. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33233. private _processPointerUp;
  33234. /**
  33235. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33236. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33237. * @returns true if the pointer was captured
  33238. */
  33239. isPointerCaptured(pointerId?: number): boolean;
  33240. /**
  33241. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33242. * @param attachUp defines if you want to attach events to pointerup
  33243. * @param attachDown defines if you want to attach events to pointerdown
  33244. * @param attachMove defines if you want to attach events to pointermove
  33245. */
  33246. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33247. /**
  33248. * Detaches all event handlers
  33249. */
  33250. detachControl(): void;
  33251. /**
  33252. * Force the value of meshUnderPointer
  33253. * @param mesh defines the mesh to use
  33254. */
  33255. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33256. /**
  33257. * Gets the mesh under the pointer
  33258. * @returns a Mesh or null if no mesh is under the pointer
  33259. */
  33260. getPointerOverMesh(): Nullable<AbstractMesh>;
  33261. }
  33262. }
  33263. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33264. /**
  33265. * Helper class used to generate session unique ID
  33266. */
  33267. export class UniqueIdGenerator {
  33268. private static _UniqueIdCounter;
  33269. /**
  33270. * Gets an unique (relatively to the current scene) Id
  33271. */
  33272. static readonly UniqueId: number;
  33273. }
  33274. }
  33275. declare module "babylonjs/Animations/animationGroup" {
  33276. import { Animatable } from "babylonjs/Animations/animatable";
  33277. import { Animation } from "babylonjs/Animations/animation";
  33278. import { Scene, IDisposable } from "babylonjs/scene";
  33279. import { Observable } from "babylonjs/Misc/observable";
  33280. import { Nullable } from "babylonjs/types";
  33281. import "babylonjs/Animations/animatable";
  33282. /**
  33283. * This class defines the direct association between an animation and a target
  33284. */
  33285. export class TargetedAnimation {
  33286. /**
  33287. * Animation to perform
  33288. */
  33289. animation: Animation;
  33290. /**
  33291. * Target to animate
  33292. */
  33293. target: any;
  33294. /**
  33295. * Serialize the object
  33296. * @returns the JSON object representing the current entity
  33297. */
  33298. serialize(): any;
  33299. }
  33300. /**
  33301. * Use this class to create coordinated animations on multiple targets
  33302. */
  33303. export class AnimationGroup implements IDisposable {
  33304. /** The name of the animation group */
  33305. name: string;
  33306. private _scene;
  33307. private _targetedAnimations;
  33308. private _animatables;
  33309. private _from;
  33310. private _to;
  33311. private _isStarted;
  33312. private _isPaused;
  33313. private _speedRatio;
  33314. private _loopAnimation;
  33315. /**
  33316. * Gets or sets the unique id of the node
  33317. */
  33318. uniqueId: number;
  33319. /**
  33320. * This observable will notify when one animation have ended
  33321. */
  33322. onAnimationEndObservable: Observable<TargetedAnimation>;
  33323. /**
  33324. * Observer raised when one animation loops
  33325. */
  33326. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33327. /**
  33328. * This observable will notify when all animations have ended.
  33329. */
  33330. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33331. /**
  33332. * This observable will notify when all animations have paused.
  33333. */
  33334. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33335. /**
  33336. * This observable will notify when all animations are playing.
  33337. */
  33338. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33339. /**
  33340. * Gets the first frame
  33341. */
  33342. readonly from: number;
  33343. /**
  33344. * Gets the last frame
  33345. */
  33346. readonly to: number;
  33347. /**
  33348. * Define if the animations are started
  33349. */
  33350. readonly isStarted: boolean;
  33351. /**
  33352. * Gets a value indicating that the current group is playing
  33353. */
  33354. readonly isPlaying: boolean;
  33355. /**
  33356. * Gets or sets the speed ratio to use for all animations
  33357. */
  33358. /**
  33359. * Gets or sets the speed ratio to use for all animations
  33360. */
  33361. speedRatio: number;
  33362. /**
  33363. * Gets or sets if all animations should loop or not
  33364. */
  33365. loopAnimation: boolean;
  33366. /**
  33367. * Gets the targeted animations for this animation group
  33368. */
  33369. readonly targetedAnimations: Array<TargetedAnimation>;
  33370. /**
  33371. * returning the list of animatables controlled by this animation group.
  33372. */
  33373. readonly animatables: Array<Animatable>;
  33374. /**
  33375. * Instantiates a new Animation Group.
  33376. * This helps managing several animations at once.
  33377. * @see http://doc.babylonjs.com/how_to/group
  33378. * @param name Defines the name of the group
  33379. * @param scene Defines the scene the group belongs to
  33380. */
  33381. constructor(
  33382. /** The name of the animation group */
  33383. name: string, scene?: Nullable<Scene>);
  33384. /**
  33385. * Add an animation (with its target) in the group
  33386. * @param animation defines the animation we want to add
  33387. * @param target defines the target of the animation
  33388. * @returns the TargetedAnimation object
  33389. */
  33390. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33391. /**
  33392. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33393. * It can add constant keys at begin or end
  33394. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33395. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33396. * @returns the animation group
  33397. */
  33398. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33399. /**
  33400. * Start all animations on given targets
  33401. * @param loop defines if animations must loop
  33402. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33403. * @param from defines the from key (optional)
  33404. * @param to defines the to key (optional)
  33405. * @returns the current animation group
  33406. */
  33407. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33408. /**
  33409. * Pause all animations
  33410. * @returns the animation group
  33411. */
  33412. pause(): AnimationGroup;
  33413. /**
  33414. * Play all animations to initial state
  33415. * This function will start() the animations if they were not started or will restart() them if they were paused
  33416. * @param loop defines if animations must loop
  33417. * @returns the animation group
  33418. */
  33419. play(loop?: boolean): AnimationGroup;
  33420. /**
  33421. * Reset all animations to initial state
  33422. * @returns the animation group
  33423. */
  33424. reset(): AnimationGroup;
  33425. /**
  33426. * Restart animations from key 0
  33427. * @returns the animation group
  33428. */
  33429. restart(): AnimationGroup;
  33430. /**
  33431. * Stop all animations
  33432. * @returns the animation group
  33433. */
  33434. stop(): AnimationGroup;
  33435. /**
  33436. * Set animation weight for all animatables
  33437. * @param weight defines the weight to use
  33438. * @return the animationGroup
  33439. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33440. */
  33441. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33442. /**
  33443. * Synchronize and normalize all animatables with a source animatable
  33444. * @param root defines the root animatable to synchronize with
  33445. * @return the animationGroup
  33446. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33447. */
  33448. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33449. /**
  33450. * Goes to a specific frame in this animation group
  33451. * @param frame the frame number to go to
  33452. * @return the animationGroup
  33453. */
  33454. goToFrame(frame: number): AnimationGroup;
  33455. /**
  33456. * Dispose all associated resources
  33457. */
  33458. dispose(): void;
  33459. private _checkAnimationGroupEnded;
  33460. /**
  33461. * Clone the current animation group and returns a copy
  33462. * @param newName defines the name of the new group
  33463. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33464. * @returns the new aniamtion group
  33465. */
  33466. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33467. /**
  33468. * Serializes the animationGroup to an object
  33469. * @returns Serialized object
  33470. */
  33471. serialize(): any;
  33472. /**
  33473. * Returns a new AnimationGroup object parsed from the source provided.
  33474. * @param parsedAnimationGroup defines the source
  33475. * @param scene defines the scene that will receive the animationGroup
  33476. * @returns a new AnimationGroup
  33477. */
  33478. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33479. /**
  33480. * Returns the string "AnimationGroup"
  33481. * @returns "AnimationGroup"
  33482. */
  33483. getClassName(): string;
  33484. /**
  33485. * Creates a detailled string about the object
  33486. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33487. * @returns a string representing the object
  33488. */
  33489. toString(fullDetails?: boolean): string;
  33490. }
  33491. }
  33492. declare module "babylonjs/scene" {
  33493. import { Nullable } from "babylonjs/types";
  33494. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33495. import { Observable } from "babylonjs/Misc/observable";
  33496. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33497. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33498. import { Geometry } from "babylonjs/Meshes/geometry";
  33499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33500. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33502. import { Mesh } from "babylonjs/Meshes/mesh";
  33503. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33504. import { Bone } from "babylonjs/Bones/bone";
  33505. import { Skeleton } from "babylonjs/Bones/skeleton";
  33506. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33507. import { Camera } from "babylonjs/Cameras/camera";
  33508. import { AbstractScene } from "babylonjs/abstractScene";
  33509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33511. import { Material } from "babylonjs/Materials/material";
  33512. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33513. import { Effect } from "babylonjs/Materials/effect";
  33514. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33515. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33516. import { Light } from "babylonjs/Lights/light";
  33517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33518. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33519. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33520. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33522. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33523. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33524. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33525. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33526. import { Engine } from "babylonjs/Engines/engine";
  33527. import { Node } from "babylonjs/node";
  33528. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33529. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33530. import { WebRequest } from "babylonjs/Misc/webRequest";
  33531. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33532. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33533. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33534. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33535. import { Plane } from "babylonjs/Maths/math.plane";
  33536. import { Ray } from "babylonjs/Culling/ray";
  33537. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33538. import { Animation } from "babylonjs/Animations/animation";
  33539. import { Animatable } from "babylonjs/Animations/animatable";
  33540. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33541. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33542. import { Collider } from "babylonjs/Collisions/collider";
  33543. /**
  33544. * Define an interface for all classes that will hold resources
  33545. */
  33546. export interface IDisposable {
  33547. /**
  33548. * Releases all held resources
  33549. */
  33550. dispose(): void;
  33551. }
  33552. /** Interface defining initialization parameters for Scene class */
  33553. export interface SceneOptions {
  33554. /**
  33555. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33556. * It will improve performance when the number of geometries becomes important.
  33557. */
  33558. useGeometryUniqueIdsMap?: boolean;
  33559. /**
  33560. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33561. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33562. */
  33563. useMaterialMeshMap?: boolean;
  33564. /**
  33565. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33566. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33567. */
  33568. useClonedMeshhMap?: boolean;
  33569. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33570. virtual?: boolean;
  33571. }
  33572. /**
  33573. * Represents a scene to be rendered by the engine.
  33574. * @see http://doc.babylonjs.com/features/scene
  33575. */
  33576. export class Scene extends AbstractScene implements IAnimatable {
  33577. /** The fog is deactivated */
  33578. static readonly FOGMODE_NONE: number;
  33579. /** The fog density is following an exponential function */
  33580. static readonly FOGMODE_EXP: number;
  33581. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33582. static readonly FOGMODE_EXP2: number;
  33583. /** The fog density is following a linear function. */
  33584. static readonly FOGMODE_LINEAR: number;
  33585. /**
  33586. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33588. */
  33589. static MinDeltaTime: number;
  33590. /**
  33591. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33593. */
  33594. static MaxDeltaTime: number;
  33595. /**
  33596. * Factory used to create the default material.
  33597. * @param name The name of the material to create
  33598. * @param scene The scene to create the material for
  33599. * @returns The default material
  33600. */
  33601. static DefaultMaterialFactory(scene: Scene): Material;
  33602. /**
  33603. * Factory used to create the a collision coordinator.
  33604. * @returns The collision coordinator
  33605. */
  33606. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33607. /** @hidden */
  33608. _inputManager: InputManager;
  33609. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33610. cameraToUseForPointers: Nullable<Camera>;
  33611. /** @hidden */
  33612. readonly _isScene: boolean;
  33613. /**
  33614. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33615. */
  33616. autoClear: boolean;
  33617. /**
  33618. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33619. */
  33620. autoClearDepthAndStencil: boolean;
  33621. /**
  33622. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33623. */
  33624. clearColor: Color4;
  33625. /**
  33626. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33627. */
  33628. ambientColor: Color3;
  33629. /**
  33630. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33631. * It should only be one of the following (if not the default embedded one):
  33632. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33633. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33634. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33635. * The material properties need to be setup according to the type of texture in use.
  33636. */
  33637. environmentBRDFTexture: BaseTexture;
  33638. /** @hidden */
  33639. protected _environmentTexture: Nullable<BaseTexture>;
  33640. /**
  33641. * Texture used in all pbr material as the reflection texture.
  33642. * As in the majority of the scene they are the same (exception for multi room and so on),
  33643. * this is easier to reference from here than from all the materials.
  33644. */
  33645. /**
  33646. * Texture used in all pbr material as the reflection texture.
  33647. * As in the majority of the scene they are the same (exception for multi room and so on),
  33648. * this is easier to set here than in all the materials.
  33649. */
  33650. environmentTexture: Nullable<BaseTexture>;
  33651. /** @hidden */
  33652. protected _environmentIntensity: number;
  33653. /**
  33654. * Intensity of the environment in all pbr material.
  33655. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33656. * As in the majority of the scene they are the same (exception for multi room and so on),
  33657. * this is easier to reference from here than from all the materials.
  33658. */
  33659. /**
  33660. * Intensity of the environment in all pbr material.
  33661. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33662. * As in the majority of the scene they are the same (exception for multi room and so on),
  33663. * this is easier to set here than in all the materials.
  33664. */
  33665. environmentIntensity: number;
  33666. /** @hidden */
  33667. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33668. /**
  33669. * Default image processing configuration used either in the rendering
  33670. * Forward main pass or through the imageProcessingPostProcess if present.
  33671. * As in the majority of the scene they are the same (exception for multi camera),
  33672. * this is easier to reference from here than from all the materials and post process.
  33673. *
  33674. * No setter as we it is a shared configuration, you can set the values instead.
  33675. */
  33676. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33677. private _forceWireframe;
  33678. /**
  33679. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33680. */
  33681. forceWireframe: boolean;
  33682. private _forcePointsCloud;
  33683. /**
  33684. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33685. */
  33686. forcePointsCloud: boolean;
  33687. /**
  33688. * Gets or sets the active clipplane 1
  33689. */
  33690. clipPlane: Nullable<Plane>;
  33691. /**
  33692. * Gets or sets the active clipplane 2
  33693. */
  33694. clipPlane2: Nullable<Plane>;
  33695. /**
  33696. * Gets or sets the active clipplane 3
  33697. */
  33698. clipPlane3: Nullable<Plane>;
  33699. /**
  33700. * Gets or sets the active clipplane 4
  33701. */
  33702. clipPlane4: Nullable<Plane>;
  33703. /**
  33704. * Gets or sets a boolean indicating if animations are enabled
  33705. */
  33706. animationsEnabled: boolean;
  33707. private _animationPropertiesOverride;
  33708. /**
  33709. * Gets or sets the animation properties override
  33710. */
  33711. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33712. /**
  33713. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33714. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33715. */
  33716. useConstantAnimationDeltaTime: boolean;
  33717. /**
  33718. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33719. * Please note that it requires to run a ray cast through the scene on every frame
  33720. */
  33721. constantlyUpdateMeshUnderPointer: boolean;
  33722. /**
  33723. * Defines the HTML cursor to use when hovering over interactive elements
  33724. */
  33725. hoverCursor: string;
  33726. /**
  33727. * Defines the HTML default cursor to use (empty by default)
  33728. */
  33729. defaultCursor: string;
  33730. /**
  33731. * This is used to call preventDefault() on pointer down
  33732. * in order to block unwanted artifacts like system double clicks
  33733. */
  33734. preventDefaultOnPointerDown: boolean;
  33735. /**
  33736. * This is used to call preventDefault() on pointer up
  33737. * in order to block unwanted artifacts like system double clicks
  33738. */
  33739. preventDefaultOnPointerUp: boolean;
  33740. /**
  33741. * Gets or sets user defined metadata
  33742. */
  33743. metadata: any;
  33744. /**
  33745. * For internal use only. Please do not use.
  33746. */
  33747. reservedDataStore: any;
  33748. /**
  33749. * Gets the name of the plugin used to load this scene (null by default)
  33750. */
  33751. loadingPluginName: string;
  33752. /**
  33753. * Use this array to add regular expressions used to disable offline support for specific urls
  33754. */
  33755. disableOfflineSupportExceptionRules: RegExp[];
  33756. /**
  33757. * An event triggered when the scene is disposed.
  33758. */
  33759. onDisposeObservable: Observable<Scene>;
  33760. private _onDisposeObserver;
  33761. /** Sets a function to be executed when this scene is disposed. */
  33762. onDispose: () => void;
  33763. /**
  33764. * An event triggered before rendering the scene (right after animations and physics)
  33765. */
  33766. onBeforeRenderObservable: Observable<Scene>;
  33767. private _onBeforeRenderObserver;
  33768. /** Sets a function to be executed before rendering this scene */
  33769. beforeRender: Nullable<() => void>;
  33770. /**
  33771. * An event triggered after rendering the scene
  33772. */
  33773. onAfterRenderObservable: Observable<Scene>;
  33774. /**
  33775. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33776. */
  33777. onAfterRenderCameraObservable: Observable<Camera>;
  33778. private _onAfterRenderObserver;
  33779. /** Sets a function to be executed after rendering this scene */
  33780. afterRender: Nullable<() => void>;
  33781. /**
  33782. * An event triggered before animating the scene
  33783. */
  33784. onBeforeAnimationsObservable: Observable<Scene>;
  33785. /**
  33786. * An event triggered after animations processing
  33787. */
  33788. onAfterAnimationsObservable: Observable<Scene>;
  33789. /**
  33790. * An event triggered before draw calls are ready to be sent
  33791. */
  33792. onBeforeDrawPhaseObservable: Observable<Scene>;
  33793. /**
  33794. * An event triggered after draw calls have been sent
  33795. */
  33796. onAfterDrawPhaseObservable: Observable<Scene>;
  33797. /**
  33798. * An event triggered when the scene is ready
  33799. */
  33800. onReadyObservable: Observable<Scene>;
  33801. /**
  33802. * An event triggered before rendering a camera
  33803. */
  33804. onBeforeCameraRenderObservable: Observable<Camera>;
  33805. private _onBeforeCameraRenderObserver;
  33806. /** Sets a function to be executed before rendering a camera*/
  33807. beforeCameraRender: () => void;
  33808. /**
  33809. * An event triggered after rendering a camera
  33810. */
  33811. onAfterCameraRenderObservable: Observable<Camera>;
  33812. private _onAfterCameraRenderObserver;
  33813. /** Sets a function to be executed after rendering a camera*/
  33814. afterCameraRender: () => void;
  33815. /**
  33816. * An event triggered when active meshes evaluation is about to start
  33817. */
  33818. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33819. /**
  33820. * An event triggered when active meshes evaluation is done
  33821. */
  33822. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33823. /**
  33824. * An event triggered when particles rendering is about to start
  33825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33826. */
  33827. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33828. /**
  33829. * An event triggered when particles rendering is done
  33830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33831. */
  33832. onAfterParticlesRenderingObservable: Observable<Scene>;
  33833. /**
  33834. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33835. */
  33836. onDataLoadedObservable: Observable<Scene>;
  33837. /**
  33838. * An event triggered when a camera is created
  33839. */
  33840. onNewCameraAddedObservable: Observable<Camera>;
  33841. /**
  33842. * An event triggered when a camera is removed
  33843. */
  33844. onCameraRemovedObservable: Observable<Camera>;
  33845. /**
  33846. * An event triggered when a light is created
  33847. */
  33848. onNewLightAddedObservable: Observable<Light>;
  33849. /**
  33850. * An event triggered when a light is removed
  33851. */
  33852. onLightRemovedObservable: Observable<Light>;
  33853. /**
  33854. * An event triggered when a geometry is created
  33855. */
  33856. onNewGeometryAddedObservable: Observable<Geometry>;
  33857. /**
  33858. * An event triggered when a geometry is removed
  33859. */
  33860. onGeometryRemovedObservable: Observable<Geometry>;
  33861. /**
  33862. * An event triggered when a transform node is created
  33863. */
  33864. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33865. /**
  33866. * An event triggered when a transform node is removed
  33867. */
  33868. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33869. /**
  33870. * An event triggered when a mesh is created
  33871. */
  33872. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33873. /**
  33874. * An event triggered when a mesh is removed
  33875. */
  33876. onMeshRemovedObservable: Observable<AbstractMesh>;
  33877. /**
  33878. * An event triggered when a skeleton is created
  33879. */
  33880. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33881. /**
  33882. * An event triggered when a skeleton is removed
  33883. */
  33884. onSkeletonRemovedObservable: Observable<Skeleton>;
  33885. /**
  33886. * An event triggered when a material is created
  33887. */
  33888. onNewMaterialAddedObservable: Observable<Material>;
  33889. /**
  33890. * An event triggered when a material is removed
  33891. */
  33892. onMaterialRemovedObservable: Observable<Material>;
  33893. /**
  33894. * An event triggered when a texture is created
  33895. */
  33896. onNewTextureAddedObservable: Observable<BaseTexture>;
  33897. /**
  33898. * An event triggered when a texture is removed
  33899. */
  33900. onTextureRemovedObservable: Observable<BaseTexture>;
  33901. /**
  33902. * An event triggered when render targets are about to be rendered
  33903. * Can happen multiple times per frame.
  33904. */
  33905. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33906. /**
  33907. * An event triggered when render targets were rendered.
  33908. * Can happen multiple times per frame.
  33909. */
  33910. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33911. /**
  33912. * An event triggered before calculating deterministic simulation step
  33913. */
  33914. onBeforeStepObservable: Observable<Scene>;
  33915. /**
  33916. * An event triggered after calculating deterministic simulation step
  33917. */
  33918. onAfterStepObservable: Observable<Scene>;
  33919. /**
  33920. * An event triggered when the activeCamera property is updated
  33921. */
  33922. onActiveCameraChanged: Observable<Scene>;
  33923. /**
  33924. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33925. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33926. * 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)
  33927. */
  33928. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33929. /**
  33930. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33931. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33932. * 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)
  33933. */
  33934. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33935. /**
  33936. * This Observable will when a mesh has been imported into the scene.
  33937. */
  33938. onMeshImportedObservable: Observable<AbstractMesh>;
  33939. /**
  33940. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33941. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33942. */
  33943. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33944. /** @hidden */
  33945. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33946. /**
  33947. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33948. */
  33949. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33950. /**
  33951. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33952. */
  33953. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33954. /**
  33955. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33956. */
  33957. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33958. /** Callback called when a pointer move is detected */
  33959. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33960. /** Callback called when a pointer down is detected */
  33961. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33962. /** Callback called when a pointer up is detected */
  33963. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33964. /** Callback called when a pointer pick is detected */
  33965. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33966. /**
  33967. * 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).
  33968. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33969. */
  33970. onPrePointerObservable: Observable<PointerInfoPre>;
  33971. /**
  33972. * Observable event triggered each time an input event is received from the rendering canvas
  33973. */
  33974. onPointerObservable: Observable<PointerInfo>;
  33975. /**
  33976. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33977. */
  33978. readonly unTranslatedPointer: Vector2;
  33979. /**
  33980. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33981. */
  33982. static DragMovementThreshold: number;
  33983. /**
  33984. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33985. */
  33986. static LongPressDelay: number;
  33987. /**
  33988. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33989. */
  33990. static DoubleClickDelay: number;
  33991. /** If you need to check double click without raising a single click at first click, enable this flag */
  33992. static ExclusiveDoubleClickMode: boolean;
  33993. /** @hidden */
  33994. _mirroredCameraPosition: Nullable<Vector3>;
  33995. /**
  33996. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33997. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33998. */
  33999. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34000. /**
  34001. * Observable event triggered each time an keyboard event is received from the hosting window
  34002. */
  34003. onKeyboardObservable: Observable<KeyboardInfo>;
  34004. private _useRightHandedSystem;
  34005. /**
  34006. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34007. */
  34008. useRightHandedSystem: boolean;
  34009. private _timeAccumulator;
  34010. private _currentStepId;
  34011. private _currentInternalStep;
  34012. /**
  34013. * Sets the step Id used by deterministic lock step
  34014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34015. * @param newStepId defines the step Id
  34016. */
  34017. setStepId(newStepId: number): void;
  34018. /**
  34019. * Gets the step Id used by deterministic lock step
  34020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34021. * @returns the step Id
  34022. */
  34023. getStepId(): number;
  34024. /**
  34025. * Gets the internal step used by deterministic lock step
  34026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34027. * @returns the internal step
  34028. */
  34029. getInternalStep(): number;
  34030. private _fogEnabled;
  34031. /**
  34032. * Gets or sets a boolean indicating if fog is enabled on this scene
  34033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34034. * (Default is true)
  34035. */
  34036. fogEnabled: boolean;
  34037. private _fogMode;
  34038. /**
  34039. * Gets or sets the fog mode to use
  34040. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34041. * | mode | value |
  34042. * | --- | --- |
  34043. * | FOGMODE_NONE | 0 |
  34044. * | FOGMODE_EXP | 1 |
  34045. * | FOGMODE_EXP2 | 2 |
  34046. * | FOGMODE_LINEAR | 3 |
  34047. */
  34048. fogMode: number;
  34049. /**
  34050. * Gets or sets the fog color to use
  34051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34052. * (Default is Color3(0.2, 0.2, 0.3))
  34053. */
  34054. fogColor: Color3;
  34055. /**
  34056. * Gets or sets the fog density to use
  34057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34058. * (Default is 0.1)
  34059. */
  34060. fogDensity: number;
  34061. /**
  34062. * Gets or sets the fog start distance to use
  34063. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34064. * (Default is 0)
  34065. */
  34066. fogStart: number;
  34067. /**
  34068. * Gets or sets the fog end distance to use
  34069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34070. * (Default is 1000)
  34071. */
  34072. fogEnd: number;
  34073. private _shadowsEnabled;
  34074. /**
  34075. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34076. */
  34077. shadowsEnabled: boolean;
  34078. private _lightsEnabled;
  34079. /**
  34080. * Gets or sets a boolean indicating if lights are enabled on this scene
  34081. */
  34082. lightsEnabled: boolean;
  34083. /** All of the active cameras added to this scene. */
  34084. activeCameras: Camera[];
  34085. /** @hidden */
  34086. _activeCamera: Nullable<Camera>;
  34087. /** Gets or sets the current active camera */
  34088. activeCamera: Nullable<Camera>;
  34089. private _defaultMaterial;
  34090. /** The default material used on meshes when no material is affected */
  34091. /** The default material used on meshes when no material is affected */
  34092. defaultMaterial: Material;
  34093. private _texturesEnabled;
  34094. /**
  34095. * Gets or sets a boolean indicating if textures are enabled on this scene
  34096. */
  34097. texturesEnabled: boolean;
  34098. /**
  34099. * Gets or sets a boolean indicating if particles are enabled on this scene
  34100. */
  34101. particlesEnabled: boolean;
  34102. /**
  34103. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34104. */
  34105. spritesEnabled: boolean;
  34106. private _skeletonsEnabled;
  34107. /**
  34108. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34109. */
  34110. skeletonsEnabled: boolean;
  34111. /**
  34112. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34113. */
  34114. lensFlaresEnabled: boolean;
  34115. /**
  34116. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34118. */
  34119. collisionsEnabled: boolean;
  34120. private _collisionCoordinator;
  34121. /** @hidden */
  34122. readonly collisionCoordinator: ICollisionCoordinator;
  34123. /**
  34124. * Defines the gravity applied to this scene (used only for collisions)
  34125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34126. */
  34127. gravity: Vector3;
  34128. /**
  34129. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34130. */
  34131. postProcessesEnabled: boolean;
  34132. /**
  34133. * The list of postprocesses added to the scene
  34134. */
  34135. postProcesses: PostProcess[];
  34136. /**
  34137. * Gets the current postprocess manager
  34138. */
  34139. postProcessManager: PostProcessManager;
  34140. /**
  34141. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34142. */
  34143. renderTargetsEnabled: boolean;
  34144. /**
  34145. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34146. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34147. */
  34148. dumpNextRenderTargets: boolean;
  34149. /**
  34150. * The list of user defined render targets added to the scene
  34151. */
  34152. customRenderTargets: RenderTargetTexture[];
  34153. /**
  34154. * Defines if texture loading must be delayed
  34155. * If true, textures will only be loaded when they need to be rendered
  34156. */
  34157. useDelayedTextureLoading: boolean;
  34158. /**
  34159. * Gets the list of meshes imported to the scene through SceneLoader
  34160. */
  34161. importedMeshesFiles: String[];
  34162. /**
  34163. * Gets or sets a boolean indicating if probes are enabled on this scene
  34164. */
  34165. probesEnabled: boolean;
  34166. /**
  34167. * Gets or sets the current offline provider to use to store scene data
  34168. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34169. */
  34170. offlineProvider: IOfflineProvider;
  34171. /**
  34172. * Gets or sets the action manager associated with the scene
  34173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34174. */
  34175. actionManager: AbstractActionManager;
  34176. private _meshesForIntersections;
  34177. /**
  34178. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34179. */
  34180. proceduralTexturesEnabled: boolean;
  34181. private _engine;
  34182. private _totalVertices;
  34183. /** @hidden */
  34184. _activeIndices: PerfCounter;
  34185. /** @hidden */
  34186. _activeParticles: PerfCounter;
  34187. /** @hidden */
  34188. _activeBones: PerfCounter;
  34189. private _animationRatio;
  34190. /** @hidden */
  34191. _animationTimeLast: number;
  34192. /** @hidden */
  34193. _animationTime: number;
  34194. /**
  34195. * Gets or sets a general scale for animation speed
  34196. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34197. */
  34198. animationTimeScale: number;
  34199. /** @hidden */
  34200. _cachedMaterial: Nullable<Material>;
  34201. /** @hidden */
  34202. _cachedEffect: Nullable<Effect>;
  34203. /** @hidden */
  34204. _cachedVisibility: Nullable<number>;
  34205. private _renderId;
  34206. private _frameId;
  34207. private _executeWhenReadyTimeoutId;
  34208. private _intermediateRendering;
  34209. private _viewUpdateFlag;
  34210. private _projectionUpdateFlag;
  34211. /** @hidden */
  34212. _toBeDisposed: Nullable<IDisposable>[];
  34213. private _activeRequests;
  34214. /** @hidden */
  34215. _pendingData: any[];
  34216. private _isDisposed;
  34217. /**
  34218. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34219. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34220. */
  34221. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34222. private _activeMeshes;
  34223. private _processedMaterials;
  34224. private _renderTargets;
  34225. /** @hidden */
  34226. _activeParticleSystems: SmartArray<IParticleSystem>;
  34227. private _activeSkeletons;
  34228. private _softwareSkinnedMeshes;
  34229. private _renderingManager;
  34230. /** @hidden */
  34231. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34232. private _transformMatrix;
  34233. private _sceneUbo;
  34234. /** @hidden */
  34235. _viewMatrix: Matrix;
  34236. private _projectionMatrix;
  34237. /** @hidden */
  34238. _forcedViewPosition: Nullable<Vector3>;
  34239. /** @hidden */
  34240. _frustumPlanes: Plane[];
  34241. /**
  34242. * Gets the list of frustum planes (built from the active camera)
  34243. */
  34244. readonly frustumPlanes: Plane[];
  34245. /**
  34246. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34247. * This is useful if there are more lights that the maximum simulteanous authorized
  34248. */
  34249. requireLightSorting: boolean;
  34250. /** @hidden */
  34251. readonly useMaterialMeshMap: boolean;
  34252. /** @hidden */
  34253. readonly useClonedMeshhMap: boolean;
  34254. private _externalData;
  34255. private _uid;
  34256. /**
  34257. * @hidden
  34258. * Backing store of defined scene components.
  34259. */
  34260. _components: ISceneComponent[];
  34261. /**
  34262. * @hidden
  34263. * Backing store of defined scene components.
  34264. */
  34265. _serializableComponents: ISceneSerializableComponent[];
  34266. /**
  34267. * List of components to register on the next registration step.
  34268. */
  34269. private _transientComponents;
  34270. /**
  34271. * Registers the transient components if needed.
  34272. */
  34273. private _registerTransientComponents;
  34274. /**
  34275. * @hidden
  34276. * Add a component to the scene.
  34277. * Note that the ccomponent could be registered on th next frame if this is called after
  34278. * the register component stage.
  34279. * @param component Defines the component to add to the scene
  34280. */
  34281. _addComponent(component: ISceneComponent): void;
  34282. /**
  34283. * @hidden
  34284. * Gets a component from the scene.
  34285. * @param name defines the name of the component to retrieve
  34286. * @returns the component or null if not present
  34287. */
  34288. _getComponent(name: string): Nullable<ISceneComponent>;
  34289. /**
  34290. * @hidden
  34291. * Defines the actions happening before camera updates.
  34292. */
  34293. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34294. /**
  34295. * @hidden
  34296. * Defines the actions happening before clear the canvas.
  34297. */
  34298. _beforeClearStage: Stage<SimpleStageAction>;
  34299. /**
  34300. * @hidden
  34301. * Defines the actions when collecting render targets for the frame.
  34302. */
  34303. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34304. /**
  34305. * @hidden
  34306. * Defines the actions happening for one camera in the frame.
  34307. */
  34308. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34309. /**
  34310. * @hidden
  34311. * Defines the actions happening during the per mesh ready checks.
  34312. */
  34313. _isReadyForMeshStage: Stage<MeshStageAction>;
  34314. /**
  34315. * @hidden
  34316. * Defines the actions happening before evaluate active mesh checks.
  34317. */
  34318. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34319. /**
  34320. * @hidden
  34321. * Defines the actions happening during the evaluate sub mesh checks.
  34322. */
  34323. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34324. /**
  34325. * @hidden
  34326. * Defines the actions happening during the active mesh stage.
  34327. */
  34328. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34329. /**
  34330. * @hidden
  34331. * Defines the actions happening during the per camera render target step.
  34332. */
  34333. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34334. /**
  34335. * @hidden
  34336. * Defines the actions happening just before the active camera is drawing.
  34337. */
  34338. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34339. /**
  34340. * @hidden
  34341. * Defines the actions happening just before a render target is drawing.
  34342. */
  34343. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34344. /**
  34345. * @hidden
  34346. * Defines the actions happening just before a rendering group is drawing.
  34347. */
  34348. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34349. /**
  34350. * @hidden
  34351. * Defines the actions happening just before a mesh is drawing.
  34352. */
  34353. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34354. /**
  34355. * @hidden
  34356. * Defines the actions happening just after a mesh has been drawn.
  34357. */
  34358. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34359. /**
  34360. * @hidden
  34361. * Defines the actions happening just after a rendering group has been drawn.
  34362. */
  34363. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34364. /**
  34365. * @hidden
  34366. * Defines the actions happening just after the active camera has been drawn.
  34367. */
  34368. _afterCameraDrawStage: Stage<CameraStageAction>;
  34369. /**
  34370. * @hidden
  34371. * Defines the actions happening just after a render target has been drawn.
  34372. */
  34373. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34374. /**
  34375. * @hidden
  34376. * Defines the actions happening just after rendering all cameras and computing intersections.
  34377. */
  34378. _afterRenderStage: Stage<SimpleStageAction>;
  34379. /**
  34380. * @hidden
  34381. * Defines the actions happening when a pointer move event happens.
  34382. */
  34383. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34384. /**
  34385. * @hidden
  34386. * Defines the actions happening when a pointer down event happens.
  34387. */
  34388. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34389. /**
  34390. * @hidden
  34391. * Defines the actions happening when a pointer up event happens.
  34392. */
  34393. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34394. /**
  34395. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34396. */
  34397. private geometriesByUniqueId;
  34398. /**
  34399. * Creates a new Scene
  34400. * @param engine defines the engine to use to render this scene
  34401. * @param options defines the scene options
  34402. */
  34403. constructor(engine: Engine, options?: SceneOptions);
  34404. /**
  34405. * Gets a string idenfifying the name of the class
  34406. * @returns "Scene" string
  34407. */
  34408. getClassName(): string;
  34409. private _defaultMeshCandidates;
  34410. /**
  34411. * @hidden
  34412. */
  34413. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34414. private _defaultSubMeshCandidates;
  34415. /**
  34416. * @hidden
  34417. */
  34418. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34419. /**
  34420. * Sets the default candidate providers for the scene.
  34421. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34422. * and getCollidingSubMeshCandidates to their default function
  34423. */
  34424. setDefaultCandidateProviders(): void;
  34425. /**
  34426. * Gets the mesh that is currently under the pointer
  34427. */
  34428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34429. /**
  34430. * Gets or sets the current on-screen X position of the pointer
  34431. */
  34432. pointerX: number;
  34433. /**
  34434. * Gets or sets the current on-screen Y position of the pointer
  34435. */
  34436. pointerY: number;
  34437. /**
  34438. * Gets the cached material (ie. the latest rendered one)
  34439. * @returns the cached material
  34440. */
  34441. getCachedMaterial(): Nullable<Material>;
  34442. /**
  34443. * Gets the cached effect (ie. the latest rendered one)
  34444. * @returns the cached effect
  34445. */
  34446. getCachedEffect(): Nullable<Effect>;
  34447. /**
  34448. * Gets the cached visibility state (ie. the latest rendered one)
  34449. * @returns the cached visibility state
  34450. */
  34451. getCachedVisibility(): Nullable<number>;
  34452. /**
  34453. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34454. * @param material defines the current material
  34455. * @param effect defines the current effect
  34456. * @param visibility defines the current visibility state
  34457. * @returns true if one parameter is not cached
  34458. */
  34459. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34460. /**
  34461. * Gets the engine associated with the scene
  34462. * @returns an Engine
  34463. */
  34464. getEngine(): Engine;
  34465. /**
  34466. * Gets the total number of vertices rendered per frame
  34467. * @returns the total number of vertices rendered per frame
  34468. */
  34469. getTotalVertices(): number;
  34470. /**
  34471. * Gets the performance counter for total vertices
  34472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34473. */
  34474. readonly totalVerticesPerfCounter: PerfCounter;
  34475. /**
  34476. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34477. * @returns the total number of active indices rendered per frame
  34478. */
  34479. getActiveIndices(): number;
  34480. /**
  34481. * Gets the performance counter for active indices
  34482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34483. */
  34484. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34485. /**
  34486. * Gets the total number of active particles rendered per frame
  34487. * @returns the total number of active particles rendered per frame
  34488. */
  34489. getActiveParticles(): number;
  34490. /**
  34491. * Gets the performance counter for active particles
  34492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34493. */
  34494. readonly activeParticlesPerfCounter: PerfCounter;
  34495. /**
  34496. * Gets the total number of active bones rendered per frame
  34497. * @returns the total number of active bones rendered per frame
  34498. */
  34499. getActiveBones(): number;
  34500. /**
  34501. * Gets the performance counter for active bones
  34502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34503. */
  34504. readonly activeBonesPerfCounter: PerfCounter;
  34505. /**
  34506. * Gets the array of active meshes
  34507. * @returns an array of AbstractMesh
  34508. */
  34509. getActiveMeshes(): SmartArray<AbstractMesh>;
  34510. /**
  34511. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34512. * @returns a number
  34513. */
  34514. getAnimationRatio(): number;
  34515. /**
  34516. * Gets an unique Id for the current render phase
  34517. * @returns a number
  34518. */
  34519. getRenderId(): number;
  34520. /**
  34521. * Gets an unique Id for the current frame
  34522. * @returns a number
  34523. */
  34524. getFrameId(): number;
  34525. /** Call this function if you want to manually increment the render Id*/
  34526. incrementRenderId(): void;
  34527. private _createUbo;
  34528. /**
  34529. * Use this method to simulate a pointer move on a mesh
  34530. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34531. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34532. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34533. * @returns the current scene
  34534. */
  34535. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34536. /**
  34537. * Use this method to simulate a pointer down on a mesh
  34538. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34539. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34540. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34541. * @returns the current scene
  34542. */
  34543. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34544. /**
  34545. * Use this method to simulate a pointer up on a mesh
  34546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34549. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34550. * @returns the current scene
  34551. */
  34552. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34553. /**
  34554. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34555. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34556. * @returns true if the pointer was captured
  34557. */
  34558. isPointerCaptured(pointerId?: number): boolean;
  34559. /**
  34560. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34561. * @param attachUp defines if you want to attach events to pointerup
  34562. * @param attachDown defines if you want to attach events to pointerdown
  34563. * @param attachMove defines if you want to attach events to pointermove
  34564. */
  34565. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34566. /** Detaches all event handlers*/
  34567. detachControl(): void;
  34568. /**
  34569. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34570. * Delay loaded resources are not taking in account
  34571. * @return true if all required resources are ready
  34572. */
  34573. isReady(): boolean;
  34574. /** Resets all cached information relative to material (including effect and visibility) */
  34575. resetCachedMaterial(): void;
  34576. /**
  34577. * Registers a function to be called before every frame render
  34578. * @param func defines the function to register
  34579. */
  34580. registerBeforeRender(func: () => void): void;
  34581. /**
  34582. * Unregisters a function called before every frame render
  34583. * @param func defines the function to unregister
  34584. */
  34585. unregisterBeforeRender(func: () => void): void;
  34586. /**
  34587. * Registers a function to be called after every frame render
  34588. * @param func defines the function to register
  34589. */
  34590. registerAfterRender(func: () => void): void;
  34591. /**
  34592. * Unregisters a function called after every frame render
  34593. * @param func defines the function to unregister
  34594. */
  34595. unregisterAfterRender(func: () => void): void;
  34596. private _executeOnceBeforeRender;
  34597. /**
  34598. * The provided function will run before render once and will be disposed afterwards.
  34599. * A timeout delay can be provided so that the function will be executed in N ms.
  34600. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34601. * @param func The function to be executed.
  34602. * @param timeout optional delay in ms
  34603. */
  34604. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34605. /** @hidden */
  34606. _addPendingData(data: any): void;
  34607. /** @hidden */
  34608. _removePendingData(data: any): void;
  34609. /**
  34610. * Returns the number of items waiting to be loaded
  34611. * @returns the number of items waiting to be loaded
  34612. */
  34613. getWaitingItemsCount(): number;
  34614. /**
  34615. * Returns a boolean indicating if the scene is still loading data
  34616. */
  34617. readonly isLoading: boolean;
  34618. /**
  34619. * Registers a function to be executed when the scene is ready
  34620. * @param {Function} func - the function to be executed
  34621. */
  34622. executeWhenReady(func: () => void): void;
  34623. /**
  34624. * Returns a promise that resolves when the scene is ready
  34625. * @returns A promise that resolves when the scene is ready
  34626. */
  34627. whenReadyAsync(): Promise<void>;
  34628. /** @hidden */
  34629. _checkIsReady(): void;
  34630. /**
  34631. * Gets all animatable attached to the scene
  34632. */
  34633. readonly animatables: Animatable[];
  34634. /**
  34635. * Resets the last animation time frame.
  34636. * Useful to override when animations start running when loading a scene for the first time.
  34637. */
  34638. resetLastAnimationTimeFrame(): void;
  34639. /**
  34640. * Gets the current view matrix
  34641. * @returns a Matrix
  34642. */
  34643. getViewMatrix(): Matrix;
  34644. /**
  34645. * Gets the current projection matrix
  34646. * @returns a Matrix
  34647. */
  34648. getProjectionMatrix(): Matrix;
  34649. /**
  34650. * Gets the current transform matrix
  34651. * @returns a Matrix made of View * Projection
  34652. */
  34653. getTransformMatrix(): Matrix;
  34654. /**
  34655. * Sets the current transform matrix
  34656. * @param viewL defines the View matrix to use
  34657. * @param projectionL defines the Projection matrix to use
  34658. * @param viewR defines the right View matrix to use (if provided)
  34659. * @param projectionR defines the right Projection matrix to use (if provided)
  34660. */
  34661. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34662. /**
  34663. * Gets the uniform buffer used to store scene data
  34664. * @returns a UniformBuffer
  34665. */
  34666. getSceneUniformBuffer(): UniformBuffer;
  34667. /**
  34668. * Gets an unique (relatively to the current scene) Id
  34669. * @returns an unique number for the scene
  34670. */
  34671. getUniqueId(): number;
  34672. /**
  34673. * Add a mesh to the list of scene's meshes
  34674. * @param newMesh defines the mesh to add
  34675. * @param recursive if all child meshes should also be added to the scene
  34676. */
  34677. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34678. /**
  34679. * Remove a mesh for the list of scene's meshes
  34680. * @param toRemove defines the mesh to remove
  34681. * @param recursive if all child meshes should also be removed from the scene
  34682. * @returns the index where the mesh was in the mesh list
  34683. */
  34684. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34685. /**
  34686. * Add a transform node to the list of scene's transform nodes
  34687. * @param newTransformNode defines the transform node to add
  34688. */
  34689. addTransformNode(newTransformNode: TransformNode): void;
  34690. /**
  34691. * Remove a transform node for the list of scene's transform nodes
  34692. * @param toRemove defines the transform node to remove
  34693. * @returns the index where the transform node was in the transform node list
  34694. */
  34695. removeTransformNode(toRemove: TransformNode): number;
  34696. /**
  34697. * Remove a skeleton for the list of scene's skeletons
  34698. * @param toRemove defines the skeleton to remove
  34699. * @returns the index where the skeleton was in the skeleton list
  34700. */
  34701. removeSkeleton(toRemove: Skeleton): number;
  34702. /**
  34703. * Remove a morph target for the list of scene's morph targets
  34704. * @param toRemove defines the morph target to remove
  34705. * @returns the index where the morph target was in the morph target list
  34706. */
  34707. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34708. /**
  34709. * Remove a light for the list of scene's lights
  34710. * @param toRemove defines the light to remove
  34711. * @returns the index where the light was in the light list
  34712. */
  34713. removeLight(toRemove: Light): number;
  34714. /**
  34715. * Remove a camera for the list of scene's cameras
  34716. * @param toRemove defines the camera to remove
  34717. * @returns the index where the camera was in the camera list
  34718. */
  34719. removeCamera(toRemove: Camera): number;
  34720. /**
  34721. * Remove a particle system for the list of scene's particle systems
  34722. * @param toRemove defines the particle system to remove
  34723. * @returns the index where the particle system was in the particle system list
  34724. */
  34725. removeParticleSystem(toRemove: IParticleSystem): number;
  34726. /**
  34727. * Remove a animation for the list of scene's animations
  34728. * @param toRemove defines the animation to remove
  34729. * @returns the index where the animation was in the animation list
  34730. */
  34731. removeAnimation(toRemove: Animation): number;
  34732. /**
  34733. * Will stop the animation of the given target
  34734. * @param target - the target
  34735. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34736. * @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)
  34737. */
  34738. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34739. /**
  34740. * Removes the given animation group from this scene.
  34741. * @param toRemove The animation group to remove
  34742. * @returns The index of the removed animation group
  34743. */
  34744. removeAnimationGroup(toRemove: AnimationGroup): number;
  34745. /**
  34746. * Removes the given multi-material from this scene.
  34747. * @param toRemove The multi-material to remove
  34748. * @returns The index of the removed multi-material
  34749. */
  34750. removeMultiMaterial(toRemove: MultiMaterial): number;
  34751. /**
  34752. * Removes the given material from this scene.
  34753. * @param toRemove The material to remove
  34754. * @returns The index of the removed material
  34755. */
  34756. removeMaterial(toRemove: Material): number;
  34757. /**
  34758. * Removes the given action manager from this scene.
  34759. * @param toRemove The action manager to remove
  34760. * @returns The index of the removed action manager
  34761. */
  34762. removeActionManager(toRemove: AbstractActionManager): number;
  34763. /**
  34764. * Removes the given texture from this scene.
  34765. * @param toRemove The texture to remove
  34766. * @returns The index of the removed texture
  34767. */
  34768. removeTexture(toRemove: BaseTexture): number;
  34769. /**
  34770. * Adds the given light to this scene
  34771. * @param newLight The light to add
  34772. */
  34773. addLight(newLight: Light): void;
  34774. /**
  34775. * Sorts the list list based on light priorities
  34776. */
  34777. sortLightsByPriority(): void;
  34778. /**
  34779. * Adds the given camera to this scene
  34780. * @param newCamera The camera to add
  34781. */
  34782. addCamera(newCamera: Camera): void;
  34783. /**
  34784. * Adds the given skeleton to this scene
  34785. * @param newSkeleton The skeleton to add
  34786. */
  34787. addSkeleton(newSkeleton: Skeleton): void;
  34788. /**
  34789. * Adds the given particle system to this scene
  34790. * @param newParticleSystem The particle system to add
  34791. */
  34792. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34793. /**
  34794. * Adds the given animation to this scene
  34795. * @param newAnimation The animation to add
  34796. */
  34797. addAnimation(newAnimation: Animation): void;
  34798. /**
  34799. * Adds the given animation group to this scene.
  34800. * @param newAnimationGroup The animation group to add
  34801. */
  34802. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34803. /**
  34804. * Adds the given multi-material to this scene
  34805. * @param newMultiMaterial The multi-material to add
  34806. */
  34807. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34808. /**
  34809. * Adds the given material to this scene
  34810. * @param newMaterial The material to add
  34811. */
  34812. addMaterial(newMaterial: Material): void;
  34813. /**
  34814. * Adds the given morph target to this scene
  34815. * @param newMorphTargetManager The morph target to add
  34816. */
  34817. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34818. /**
  34819. * Adds the given geometry to this scene
  34820. * @param newGeometry The geometry to add
  34821. */
  34822. addGeometry(newGeometry: Geometry): void;
  34823. /**
  34824. * Adds the given action manager to this scene
  34825. * @param newActionManager The action manager to add
  34826. */
  34827. addActionManager(newActionManager: AbstractActionManager): void;
  34828. /**
  34829. * Adds the given texture to this scene.
  34830. * @param newTexture The texture to add
  34831. */
  34832. addTexture(newTexture: BaseTexture): void;
  34833. /**
  34834. * Switch active camera
  34835. * @param newCamera defines the new active camera
  34836. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34837. */
  34838. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34839. /**
  34840. * sets the active camera of the scene using its ID
  34841. * @param id defines the camera's ID
  34842. * @return the new active camera or null if none found.
  34843. */
  34844. setActiveCameraByID(id: string): Nullable<Camera>;
  34845. /**
  34846. * sets the active camera of the scene using its name
  34847. * @param name defines the camera's name
  34848. * @returns the new active camera or null if none found.
  34849. */
  34850. setActiveCameraByName(name: string): Nullable<Camera>;
  34851. /**
  34852. * get an animation group using its name
  34853. * @param name defines the material's name
  34854. * @return the animation group or null if none found.
  34855. */
  34856. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34857. /**
  34858. * Get a material using its unique id
  34859. * @param uniqueId defines the material's unique id
  34860. * @return the material or null if none found.
  34861. */
  34862. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34863. /**
  34864. * get a material using its id
  34865. * @param id defines the material's ID
  34866. * @return the material or null if none found.
  34867. */
  34868. getMaterialByID(id: string): Nullable<Material>;
  34869. /**
  34870. * Gets a the last added material using a given id
  34871. * @param id defines the material's ID
  34872. * @return the last material with the given id or null if none found.
  34873. */
  34874. getLastMaterialByID(id: string): Nullable<Material>;
  34875. /**
  34876. * Gets a material using its name
  34877. * @param name defines the material's name
  34878. * @return the material or null if none found.
  34879. */
  34880. getMaterialByName(name: string): Nullable<Material>;
  34881. /**
  34882. * Get a texture using its unique id
  34883. * @param uniqueId defines the texture's unique id
  34884. * @return the texture or null if none found.
  34885. */
  34886. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34887. /**
  34888. * Gets a camera using its id
  34889. * @param id defines the id to look for
  34890. * @returns the camera or null if not found
  34891. */
  34892. getCameraByID(id: string): Nullable<Camera>;
  34893. /**
  34894. * Gets a camera using its unique id
  34895. * @param uniqueId defines the unique id to look for
  34896. * @returns the camera or null if not found
  34897. */
  34898. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34899. /**
  34900. * Gets a camera using its name
  34901. * @param name defines the camera's name
  34902. * @return the camera or null if none found.
  34903. */
  34904. getCameraByName(name: string): Nullable<Camera>;
  34905. /**
  34906. * Gets a bone using its id
  34907. * @param id defines the bone's id
  34908. * @return the bone or null if not found
  34909. */
  34910. getBoneByID(id: string): Nullable<Bone>;
  34911. /**
  34912. * Gets a bone using its id
  34913. * @param name defines the bone's name
  34914. * @return the bone or null if not found
  34915. */
  34916. getBoneByName(name: string): Nullable<Bone>;
  34917. /**
  34918. * Gets a light node using its name
  34919. * @param name defines the the light's name
  34920. * @return the light or null if none found.
  34921. */
  34922. getLightByName(name: string): Nullable<Light>;
  34923. /**
  34924. * Gets a light node using its id
  34925. * @param id defines the light's id
  34926. * @return the light or null if none found.
  34927. */
  34928. getLightByID(id: string): Nullable<Light>;
  34929. /**
  34930. * Gets a light node using its scene-generated unique ID
  34931. * @param uniqueId defines the light's unique id
  34932. * @return the light or null if none found.
  34933. */
  34934. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34935. /**
  34936. * Gets a particle system by id
  34937. * @param id defines the particle system id
  34938. * @return the corresponding system or null if none found
  34939. */
  34940. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34941. /**
  34942. * Gets a geometry using its ID
  34943. * @param id defines the geometry's id
  34944. * @return the geometry or null if none found.
  34945. */
  34946. getGeometryByID(id: string): Nullable<Geometry>;
  34947. private _getGeometryByUniqueID;
  34948. /**
  34949. * Add a new geometry to this scene
  34950. * @param geometry defines the geometry to be added to the scene.
  34951. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34952. * @return a boolean defining if the geometry was added or not
  34953. */
  34954. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34955. /**
  34956. * Removes an existing geometry
  34957. * @param geometry defines the geometry to be removed from the scene
  34958. * @return a boolean defining if the geometry was removed or not
  34959. */
  34960. removeGeometry(geometry: Geometry): boolean;
  34961. /**
  34962. * Gets the list of geometries attached to the scene
  34963. * @returns an array of Geometry
  34964. */
  34965. getGeometries(): Geometry[];
  34966. /**
  34967. * Gets the first added mesh found of a given ID
  34968. * @param id defines the id to search for
  34969. * @return the mesh found or null if not found at all
  34970. */
  34971. getMeshByID(id: string): Nullable<AbstractMesh>;
  34972. /**
  34973. * Gets a list of meshes using their id
  34974. * @param id defines the id to search for
  34975. * @returns a list of meshes
  34976. */
  34977. getMeshesByID(id: string): Array<AbstractMesh>;
  34978. /**
  34979. * Gets the first added transform node found of a given ID
  34980. * @param id defines the id to search for
  34981. * @return the found transform node or null if not found at all.
  34982. */
  34983. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34984. /**
  34985. * Gets a transform node with its auto-generated unique id
  34986. * @param uniqueId efines the unique id to search for
  34987. * @return the found transform node or null if not found at all.
  34988. */
  34989. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34990. /**
  34991. * Gets a list of transform nodes using their id
  34992. * @param id defines the id to search for
  34993. * @returns a list of transform nodes
  34994. */
  34995. getTransformNodesByID(id: string): Array<TransformNode>;
  34996. /**
  34997. * Gets a mesh with its auto-generated unique id
  34998. * @param uniqueId defines the unique id to search for
  34999. * @return the found mesh or null if not found at all.
  35000. */
  35001. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35002. /**
  35003. * Gets a the last added mesh using a given id
  35004. * @param id defines the id to search for
  35005. * @return the found mesh or null if not found at all.
  35006. */
  35007. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35008. /**
  35009. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35010. * @param id defines the id to search for
  35011. * @return the found node or null if not found at all
  35012. */
  35013. getLastEntryByID(id: string): Nullable<Node>;
  35014. /**
  35015. * Gets a node (Mesh, Camera, Light) using a given id
  35016. * @param id defines the id to search for
  35017. * @return the found node or null if not found at all
  35018. */
  35019. getNodeByID(id: string): Nullable<Node>;
  35020. /**
  35021. * Gets a node (Mesh, Camera, Light) using a given name
  35022. * @param name defines the name to search for
  35023. * @return the found node or null if not found at all.
  35024. */
  35025. getNodeByName(name: string): Nullable<Node>;
  35026. /**
  35027. * Gets a mesh using a given name
  35028. * @param name defines the name to search for
  35029. * @return the found mesh or null if not found at all.
  35030. */
  35031. getMeshByName(name: string): Nullable<AbstractMesh>;
  35032. /**
  35033. * Gets a transform node using a given name
  35034. * @param name defines the name to search for
  35035. * @return the found transform node or null if not found at all.
  35036. */
  35037. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35038. /**
  35039. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35040. * @param id defines the id to search for
  35041. * @return the found skeleton or null if not found at all.
  35042. */
  35043. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35044. /**
  35045. * Gets a skeleton using a given auto generated unique id
  35046. * @param uniqueId defines the unique id to search for
  35047. * @return the found skeleton or null if not found at all.
  35048. */
  35049. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35050. /**
  35051. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35052. * @param id defines the id to search for
  35053. * @return the found skeleton or null if not found at all.
  35054. */
  35055. getSkeletonById(id: string): Nullable<Skeleton>;
  35056. /**
  35057. * Gets a skeleton using a given name
  35058. * @param name defines the name to search for
  35059. * @return the found skeleton or null if not found at all.
  35060. */
  35061. getSkeletonByName(name: string): Nullable<Skeleton>;
  35062. /**
  35063. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35064. * @param id defines the id to search for
  35065. * @return the found morph target manager or null if not found at all.
  35066. */
  35067. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35068. /**
  35069. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35070. * @param id defines the id to search for
  35071. * @return the found morph target or null if not found at all.
  35072. */
  35073. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35074. /**
  35075. * Gets a boolean indicating if the given mesh is active
  35076. * @param mesh defines the mesh to look for
  35077. * @returns true if the mesh is in the active list
  35078. */
  35079. isActiveMesh(mesh: AbstractMesh): boolean;
  35080. /**
  35081. * Return a unique id as a string which can serve as an identifier for the scene
  35082. */
  35083. readonly uid: string;
  35084. /**
  35085. * Add an externaly attached data from its key.
  35086. * This method call will fail and return false, if such key already exists.
  35087. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35088. * @param key the unique key that identifies the data
  35089. * @param data the data object to associate to the key for this Engine instance
  35090. * @return true if no such key were already present and the data was added successfully, false otherwise
  35091. */
  35092. addExternalData<T>(key: string, data: T): boolean;
  35093. /**
  35094. * Get an externaly attached data from its key
  35095. * @param key the unique key that identifies the data
  35096. * @return the associated data, if present (can be null), or undefined if not present
  35097. */
  35098. getExternalData<T>(key: string): Nullable<T>;
  35099. /**
  35100. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35101. * @param key the unique key that identifies the data
  35102. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35103. * @return the associated data, can be null if the factory returned null.
  35104. */
  35105. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35106. /**
  35107. * Remove an externaly attached data from the Engine instance
  35108. * @param key the unique key that identifies the data
  35109. * @return true if the data was successfully removed, false if it doesn't exist
  35110. */
  35111. removeExternalData(key: string): boolean;
  35112. private _evaluateSubMesh;
  35113. /**
  35114. * Clear the processed materials smart array preventing retention point in material dispose.
  35115. */
  35116. freeProcessedMaterials(): void;
  35117. private _preventFreeActiveMeshesAndRenderingGroups;
  35118. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35119. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35120. * when disposing several meshes in a row or a hierarchy of meshes.
  35121. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35122. */
  35123. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35124. /**
  35125. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35126. */
  35127. freeActiveMeshes(): void;
  35128. /**
  35129. * Clear the info related to rendering groups preventing retention points during dispose.
  35130. */
  35131. freeRenderingGroups(): void;
  35132. /** @hidden */
  35133. _isInIntermediateRendering(): boolean;
  35134. /**
  35135. * Lambda returning the list of potentially active meshes.
  35136. */
  35137. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35138. /**
  35139. * Lambda returning the list of potentially active sub meshes.
  35140. */
  35141. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35142. /**
  35143. * Lambda returning the list of potentially intersecting sub meshes.
  35144. */
  35145. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35146. /**
  35147. * Lambda returning the list of potentially colliding sub meshes.
  35148. */
  35149. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35150. private _activeMeshesFrozen;
  35151. /**
  35152. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35153. * @returns the current scene
  35154. */
  35155. freezeActiveMeshes(): Scene;
  35156. /**
  35157. * Use this function to restart evaluating active meshes on every frame
  35158. * @returns the current scene
  35159. */
  35160. unfreezeActiveMeshes(): Scene;
  35161. private _evaluateActiveMeshes;
  35162. private _activeMesh;
  35163. /**
  35164. * Update the transform matrix to update from the current active camera
  35165. * @param force defines a boolean used to force the update even if cache is up to date
  35166. */
  35167. updateTransformMatrix(force?: boolean): void;
  35168. private _bindFrameBuffer;
  35169. /** @hidden */
  35170. _allowPostProcessClearColor: boolean;
  35171. /** @hidden */
  35172. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35173. private _processSubCameras;
  35174. private _checkIntersections;
  35175. /** @hidden */
  35176. _advancePhysicsEngineStep(step: number): void;
  35177. /**
  35178. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35179. */
  35180. getDeterministicFrameTime: () => number;
  35181. /** @hidden */
  35182. _animate(): void;
  35183. /** Execute all animations (for a frame) */
  35184. animate(): void;
  35185. /**
  35186. * Render the scene
  35187. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35188. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35189. */
  35190. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35191. /**
  35192. * Freeze all materials
  35193. * A frozen material will not be updatable but should be faster to render
  35194. */
  35195. freezeMaterials(): void;
  35196. /**
  35197. * Unfreeze all materials
  35198. * A frozen material will not be updatable but should be faster to render
  35199. */
  35200. unfreezeMaterials(): void;
  35201. /**
  35202. * Releases all held ressources
  35203. */
  35204. dispose(): void;
  35205. /**
  35206. * Gets if the scene is already disposed
  35207. */
  35208. readonly isDisposed: boolean;
  35209. /**
  35210. * Call this function to reduce memory footprint of the scene.
  35211. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35212. */
  35213. clearCachedVertexData(): void;
  35214. /**
  35215. * This function will remove the local cached buffer data from texture.
  35216. * It will save memory but will prevent the texture from being rebuilt
  35217. */
  35218. cleanCachedTextureBuffer(): void;
  35219. /**
  35220. * Get the world extend vectors with an optional filter
  35221. *
  35222. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35223. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35224. */
  35225. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35226. min: Vector3;
  35227. max: Vector3;
  35228. };
  35229. /**
  35230. * Creates a ray that can be used to pick in the scene
  35231. * @param x defines the x coordinate of the origin (on-screen)
  35232. * @param y defines the y coordinate of the origin (on-screen)
  35233. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35234. * @param camera defines the camera to use for the picking
  35235. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35236. * @returns a Ray
  35237. */
  35238. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35239. /**
  35240. * Creates a ray that can be used to pick in the scene
  35241. * @param x defines the x coordinate of the origin (on-screen)
  35242. * @param y defines the y coordinate of the origin (on-screen)
  35243. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35244. * @param result defines the ray where to store the picking ray
  35245. * @param camera defines the camera to use for the picking
  35246. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35247. * @returns the current scene
  35248. */
  35249. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35250. /**
  35251. * Creates a ray that can be used to pick in the scene
  35252. * @param x defines the x coordinate of the origin (on-screen)
  35253. * @param y defines the y coordinate of the origin (on-screen)
  35254. * @param camera defines the camera to use for the picking
  35255. * @returns a Ray
  35256. */
  35257. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35258. /**
  35259. * Creates a ray that can be used to pick in the scene
  35260. * @param x defines the x coordinate of the origin (on-screen)
  35261. * @param y defines the y coordinate of the origin (on-screen)
  35262. * @param result defines the ray where to store the picking ray
  35263. * @param camera defines the camera to use for the picking
  35264. * @returns the current scene
  35265. */
  35266. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35267. /** Launch a ray to try to pick a mesh in the scene
  35268. * @param x position on screen
  35269. * @param y position on screen
  35270. * @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
  35271. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35272. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35274. * @returns a PickingInfo
  35275. */
  35276. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35277. /** Use the given ray to pick a mesh in the scene
  35278. * @param ray The ray to use to pick meshes
  35279. * @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
  35280. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35282. * @returns a PickingInfo
  35283. */
  35284. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35285. /**
  35286. * Launch a ray to try to pick a mesh in the scene
  35287. * @param x X position on screen
  35288. * @param y Y position on screen
  35289. * @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
  35290. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35291. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35292. * @returns an array of PickingInfo
  35293. */
  35294. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35295. /**
  35296. * Launch a ray to try to pick a mesh in the scene
  35297. * @param ray Ray to use
  35298. * @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
  35299. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35300. * @returns an array of PickingInfo
  35301. */
  35302. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35303. /**
  35304. * Force the value of meshUnderPointer
  35305. * @param mesh defines the mesh to use
  35306. */
  35307. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35308. /**
  35309. * Gets the mesh under the pointer
  35310. * @returns a Mesh or null if no mesh is under the pointer
  35311. */
  35312. getPointerOverMesh(): Nullable<AbstractMesh>;
  35313. /** @hidden */
  35314. _rebuildGeometries(): void;
  35315. /** @hidden */
  35316. _rebuildTextures(): void;
  35317. private _getByTags;
  35318. /**
  35319. * Get a list of meshes by tags
  35320. * @param tagsQuery defines the tags query to use
  35321. * @param forEach defines a predicate used to filter results
  35322. * @returns an array of Mesh
  35323. */
  35324. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35325. /**
  35326. * Get a list of cameras by tags
  35327. * @param tagsQuery defines the tags query to use
  35328. * @param forEach defines a predicate used to filter results
  35329. * @returns an array of Camera
  35330. */
  35331. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35332. /**
  35333. * Get a list of lights by tags
  35334. * @param tagsQuery defines the tags query to use
  35335. * @param forEach defines a predicate used to filter results
  35336. * @returns an array of Light
  35337. */
  35338. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35339. /**
  35340. * Get a list of materials by tags
  35341. * @param tagsQuery defines the tags query to use
  35342. * @param forEach defines a predicate used to filter results
  35343. * @returns an array of Material
  35344. */
  35345. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35346. /**
  35347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35348. * This allowed control for front to back rendering or reversly depending of the special needs.
  35349. *
  35350. * @param renderingGroupId The rendering group id corresponding to its index
  35351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35354. */
  35355. 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;
  35356. /**
  35357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35358. *
  35359. * @param renderingGroupId The rendering group id corresponding to its index
  35360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35361. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35362. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35363. */
  35364. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35365. /**
  35366. * Gets the current auto clear configuration for one rendering group of the rendering
  35367. * manager.
  35368. * @param index the rendering group index to get the information for
  35369. * @returns The auto clear setup for the requested rendering group
  35370. */
  35371. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35372. private _blockMaterialDirtyMechanism;
  35373. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35374. blockMaterialDirtyMechanism: boolean;
  35375. /**
  35376. * Will flag all materials as dirty to trigger new shader compilation
  35377. * @param flag defines the flag used to specify which material part must be marked as dirty
  35378. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35379. */
  35380. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35381. /** @hidden */
  35382. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35383. /** @hidden */
  35384. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35385. }
  35386. }
  35387. declare module "babylonjs/assetContainer" {
  35388. import { AbstractScene } from "babylonjs/abstractScene";
  35389. import { Scene } from "babylonjs/scene";
  35390. import { Mesh } from "babylonjs/Meshes/mesh";
  35391. /**
  35392. * Set of assets to keep when moving a scene into an asset container.
  35393. */
  35394. export class KeepAssets extends AbstractScene {
  35395. }
  35396. /**
  35397. * Container with a set of assets that can be added or removed from a scene.
  35398. */
  35399. export class AssetContainer extends AbstractScene {
  35400. /**
  35401. * The scene the AssetContainer belongs to.
  35402. */
  35403. scene: Scene;
  35404. /**
  35405. * Instantiates an AssetContainer.
  35406. * @param scene The scene the AssetContainer belongs to.
  35407. */
  35408. constructor(scene: Scene);
  35409. /**
  35410. * Adds all the assets from the container to the scene.
  35411. */
  35412. addAllToScene(): void;
  35413. /**
  35414. * Removes all the assets in the container from the scene
  35415. */
  35416. removeAllFromScene(): void;
  35417. /**
  35418. * Disposes all the assets in the container
  35419. */
  35420. dispose(): void;
  35421. private _moveAssets;
  35422. /**
  35423. * Removes all the assets contained in the scene and adds them to the container.
  35424. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35425. */
  35426. moveAllFromScene(keepAssets?: KeepAssets): void;
  35427. /**
  35428. * 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.
  35429. * @returns the root mesh
  35430. */
  35431. createRootMesh(): Mesh;
  35432. }
  35433. }
  35434. declare module "babylonjs/abstractScene" {
  35435. import { Scene } from "babylonjs/scene";
  35436. import { Nullable } from "babylonjs/types";
  35437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35438. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35439. import { Geometry } from "babylonjs/Meshes/geometry";
  35440. import { Skeleton } from "babylonjs/Bones/skeleton";
  35441. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35442. import { AssetContainer } from "babylonjs/assetContainer";
  35443. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35444. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35446. import { Material } from "babylonjs/Materials/material";
  35447. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35448. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35449. import { Camera } from "babylonjs/Cameras/camera";
  35450. import { Light } from "babylonjs/Lights/light";
  35451. import { Node } from "babylonjs/node";
  35452. import { Animation } from "babylonjs/Animations/animation";
  35453. /**
  35454. * Defines how the parser contract is defined.
  35455. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35456. */
  35457. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35458. /**
  35459. * Defines how the individual parser contract is defined.
  35460. * These parser can parse an individual asset
  35461. */
  35462. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35463. /**
  35464. * Base class of the scene acting as a container for the different elements composing a scene.
  35465. * This class is dynamically extended by the different components of the scene increasing
  35466. * flexibility and reducing coupling
  35467. */
  35468. export abstract class AbstractScene {
  35469. /**
  35470. * Stores the list of available parsers in the application.
  35471. */
  35472. private static _BabylonFileParsers;
  35473. /**
  35474. * Stores the list of available individual parsers in the application.
  35475. */
  35476. private static _IndividualBabylonFileParsers;
  35477. /**
  35478. * Adds a parser in the list of available ones
  35479. * @param name Defines the name of the parser
  35480. * @param parser Defines the parser to add
  35481. */
  35482. static AddParser(name: string, parser: BabylonFileParser): void;
  35483. /**
  35484. * Gets a general parser from the list of avaialble ones
  35485. * @param name Defines the name of the parser
  35486. * @returns the requested parser or null
  35487. */
  35488. static GetParser(name: string): Nullable<BabylonFileParser>;
  35489. /**
  35490. * Adds n individual parser in the list of available ones
  35491. * @param name Defines the name of the parser
  35492. * @param parser Defines the parser to add
  35493. */
  35494. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35495. /**
  35496. * Gets an individual parser from the list of avaialble ones
  35497. * @param name Defines the name of the parser
  35498. * @returns the requested parser or null
  35499. */
  35500. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35501. /**
  35502. * Parser json data and populate both a scene and its associated container object
  35503. * @param jsonData Defines the data to parse
  35504. * @param scene Defines the scene to parse the data for
  35505. * @param container Defines the container attached to the parsing sequence
  35506. * @param rootUrl Defines the root url of the data
  35507. */
  35508. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35509. /**
  35510. * Gets the list of root nodes (ie. nodes with no parent)
  35511. */
  35512. rootNodes: Node[];
  35513. /** All of the cameras added to this scene
  35514. * @see http://doc.babylonjs.com/babylon101/cameras
  35515. */
  35516. cameras: Camera[];
  35517. /**
  35518. * All of the lights added to this scene
  35519. * @see http://doc.babylonjs.com/babylon101/lights
  35520. */
  35521. lights: Light[];
  35522. /**
  35523. * All of the (abstract) meshes added to this scene
  35524. */
  35525. meshes: AbstractMesh[];
  35526. /**
  35527. * The list of skeletons added to the scene
  35528. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35529. */
  35530. skeletons: Skeleton[];
  35531. /**
  35532. * All of the particle systems added to this scene
  35533. * @see http://doc.babylonjs.com/babylon101/particles
  35534. */
  35535. particleSystems: IParticleSystem[];
  35536. /**
  35537. * Gets a list of Animations associated with the scene
  35538. */
  35539. animations: Animation[];
  35540. /**
  35541. * All of the animation groups added to this scene
  35542. * @see http://doc.babylonjs.com/how_to/group
  35543. */
  35544. animationGroups: AnimationGroup[];
  35545. /**
  35546. * All of the multi-materials added to this scene
  35547. * @see http://doc.babylonjs.com/how_to/multi_materials
  35548. */
  35549. multiMaterials: MultiMaterial[];
  35550. /**
  35551. * All of the materials added to this scene
  35552. * In the context of a Scene, it is not supposed to be modified manually.
  35553. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35554. * Note also that the order of the Material wihin the array is not significant and might change.
  35555. * @see http://doc.babylonjs.com/babylon101/materials
  35556. */
  35557. materials: Material[];
  35558. /**
  35559. * The list of morph target managers added to the scene
  35560. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35561. */
  35562. morphTargetManagers: MorphTargetManager[];
  35563. /**
  35564. * The list of geometries used in the scene.
  35565. */
  35566. geometries: Geometry[];
  35567. /**
  35568. * All of the tranform nodes added to this scene
  35569. * In the context of a Scene, it is not supposed to be modified manually.
  35570. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35571. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35572. * @see http://doc.babylonjs.com/how_to/transformnode
  35573. */
  35574. transformNodes: TransformNode[];
  35575. /**
  35576. * ActionManagers available on the scene.
  35577. */
  35578. actionManagers: AbstractActionManager[];
  35579. /**
  35580. * Textures to keep.
  35581. */
  35582. textures: BaseTexture[];
  35583. /**
  35584. * Environment texture for the scene
  35585. */
  35586. environmentTexture: Nullable<BaseTexture>;
  35587. }
  35588. }
  35589. declare module "babylonjs/Audio/sound" {
  35590. import { Observable } from "babylonjs/Misc/observable";
  35591. import { Vector3 } from "babylonjs/Maths/math.vector";
  35592. import { Nullable } from "babylonjs/types";
  35593. import { Scene } from "babylonjs/scene";
  35594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35595. /**
  35596. * Interface used to define options for Sound class
  35597. */
  35598. export interface ISoundOptions {
  35599. /**
  35600. * Does the sound autoplay once loaded.
  35601. */
  35602. autoplay?: boolean;
  35603. /**
  35604. * Does the sound loop after it finishes playing once.
  35605. */
  35606. loop?: boolean;
  35607. /**
  35608. * Sound's volume
  35609. */
  35610. volume?: number;
  35611. /**
  35612. * Is it a spatial sound?
  35613. */
  35614. spatialSound?: boolean;
  35615. /**
  35616. * Maximum distance to hear that sound
  35617. */
  35618. maxDistance?: number;
  35619. /**
  35620. * Uses user defined attenuation function
  35621. */
  35622. useCustomAttenuation?: boolean;
  35623. /**
  35624. * Define the roll off factor of spatial sounds.
  35625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35626. */
  35627. rolloffFactor?: number;
  35628. /**
  35629. * Define the reference distance the sound should be heard perfectly.
  35630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35631. */
  35632. refDistance?: number;
  35633. /**
  35634. * Define the distance attenuation model the sound will follow.
  35635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35636. */
  35637. distanceModel?: string;
  35638. /**
  35639. * Defines the playback speed (1 by default)
  35640. */
  35641. playbackRate?: number;
  35642. /**
  35643. * Defines if the sound is from a streaming source
  35644. */
  35645. streaming?: boolean;
  35646. /**
  35647. * Defines an optional length (in seconds) inside the sound file
  35648. */
  35649. length?: number;
  35650. /**
  35651. * Defines an optional offset (in seconds) inside the sound file
  35652. */
  35653. offset?: number;
  35654. /**
  35655. * If true, URLs will not be required to state the audio file codec to use.
  35656. */
  35657. skipCodecCheck?: boolean;
  35658. }
  35659. /**
  35660. * Defines a sound that can be played in the application.
  35661. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35663. */
  35664. export class Sound {
  35665. /**
  35666. * The name of the sound in the scene.
  35667. */
  35668. name: string;
  35669. /**
  35670. * Does the sound autoplay once loaded.
  35671. */
  35672. autoplay: boolean;
  35673. /**
  35674. * Does the sound loop after it finishes playing once.
  35675. */
  35676. loop: boolean;
  35677. /**
  35678. * Does the sound use a custom attenuation curve to simulate the falloff
  35679. * happening when the source gets further away from the camera.
  35680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35681. */
  35682. useCustomAttenuation: boolean;
  35683. /**
  35684. * The sound track id this sound belongs to.
  35685. */
  35686. soundTrackId: number;
  35687. /**
  35688. * Is this sound currently played.
  35689. */
  35690. isPlaying: boolean;
  35691. /**
  35692. * Is this sound currently paused.
  35693. */
  35694. isPaused: boolean;
  35695. /**
  35696. * Does this sound enables spatial sound.
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35698. */
  35699. spatialSound: boolean;
  35700. /**
  35701. * Define the reference distance the sound should be heard perfectly.
  35702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35703. */
  35704. refDistance: number;
  35705. /**
  35706. * Define the roll off factor of spatial sounds.
  35707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35708. */
  35709. rolloffFactor: number;
  35710. /**
  35711. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35713. */
  35714. maxDistance: number;
  35715. /**
  35716. * Define the distance attenuation model the sound will follow.
  35717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35718. */
  35719. distanceModel: string;
  35720. /**
  35721. * @hidden
  35722. * Back Compat
  35723. **/
  35724. onended: () => any;
  35725. /**
  35726. * Observable event when the current playing sound finishes.
  35727. */
  35728. onEndedObservable: Observable<Sound>;
  35729. private _panningModel;
  35730. private _playbackRate;
  35731. private _streaming;
  35732. private _startTime;
  35733. private _startOffset;
  35734. private _position;
  35735. /** @hidden */
  35736. _positionInEmitterSpace: boolean;
  35737. private _localDirection;
  35738. private _volume;
  35739. private _isReadyToPlay;
  35740. private _isDirectional;
  35741. private _readyToPlayCallback;
  35742. private _audioBuffer;
  35743. private _soundSource;
  35744. private _streamingSource;
  35745. private _soundPanner;
  35746. private _soundGain;
  35747. private _inputAudioNode;
  35748. private _outputAudioNode;
  35749. private _coneInnerAngle;
  35750. private _coneOuterAngle;
  35751. private _coneOuterGain;
  35752. private _scene;
  35753. private _connectedTransformNode;
  35754. private _customAttenuationFunction;
  35755. private _registerFunc;
  35756. private _isOutputConnected;
  35757. private _htmlAudioElement;
  35758. private _urlType;
  35759. private _length?;
  35760. private _offset?;
  35761. /** @hidden */
  35762. static _SceneComponentInitialization: (scene: Scene) => void;
  35763. /**
  35764. * Create a sound and attach it to a scene
  35765. * @param name Name of your sound
  35766. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35767. * @param scene defines the scene the sound belongs to
  35768. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35769. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35770. */
  35771. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35772. /**
  35773. * Release the sound and its associated resources
  35774. */
  35775. dispose(): void;
  35776. /**
  35777. * Gets if the sounds is ready to be played or not.
  35778. * @returns true if ready, otherwise false
  35779. */
  35780. isReady(): boolean;
  35781. private _soundLoaded;
  35782. /**
  35783. * Sets the data of the sound from an audiobuffer
  35784. * @param audioBuffer The audioBuffer containing the data
  35785. */
  35786. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35787. /**
  35788. * Updates the current sounds options such as maxdistance, loop...
  35789. * @param options A JSON object containing values named as the object properties
  35790. */
  35791. updateOptions(options: ISoundOptions): void;
  35792. private _createSpatialParameters;
  35793. private _updateSpatialParameters;
  35794. /**
  35795. * Switch the panning model to HRTF:
  35796. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35798. */
  35799. switchPanningModelToHRTF(): void;
  35800. /**
  35801. * Switch the panning model to Equal Power:
  35802. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35804. */
  35805. switchPanningModelToEqualPower(): void;
  35806. private _switchPanningModel;
  35807. /**
  35808. * Connect this sound to a sound track audio node like gain...
  35809. * @param soundTrackAudioNode the sound track audio node to connect to
  35810. */
  35811. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35812. /**
  35813. * Transform this sound into a directional source
  35814. * @param coneInnerAngle Size of the inner cone in degree
  35815. * @param coneOuterAngle Size of the outer cone in degree
  35816. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35817. */
  35818. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35819. /**
  35820. * Gets or sets the inner angle for the directional cone.
  35821. */
  35822. /**
  35823. * Gets or sets the inner angle for the directional cone.
  35824. */
  35825. directionalConeInnerAngle: number;
  35826. /**
  35827. * Gets or sets the outer angle for the directional cone.
  35828. */
  35829. /**
  35830. * Gets or sets the outer angle for the directional cone.
  35831. */
  35832. directionalConeOuterAngle: number;
  35833. /**
  35834. * Sets the position of the emitter if spatial sound is enabled
  35835. * @param newPosition Defines the new posisiton
  35836. */
  35837. setPosition(newPosition: Vector3): void;
  35838. /**
  35839. * Sets the local direction of the emitter if spatial sound is enabled
  35840. * @param newLocalDirection Defines the new local direction
  35841. */
  35842. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35843. private _updateDirection;
  35844. /** @hidden */
  35845. updateDistanceFromListener(): void;
  35846. /**
  35847. * Sets a new custom attenuation function for the sound.
  35848. * @param callback Defines the function used for the attenuation
  35849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35850. */
  35851. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35852. /**
  35853. * Play the sound
  35854. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35855. * @param offset (optional) Start the sound at a specific time in seconds
  35856. * @param length (optional) Sound duration (in seconds)
  35857. */
  35858. play(time?: number, offset?: number, length?: number): void;
  35859. private _onended;
  35860. /**
  35861. * Stop the sound
  35862. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35863. */
  35864. stop(time?: number): void;
  35865. /**
  35866. * Put the sound in pause
  35867. */
  35868. pause(): void;
  35869. /**
  35870. * Sets a dedicated volume for this sounds
  35871. * @param newVolume Define the new volume of the sound
  35872. * @param time Define time for gradual change to new volume
  35873. */
  35874. setVolume(newVolume: number, time?: number): void;
  35875. /**
  35876. * Set the sound play back rate
  35877. * @param newPlaybackRate Define the playback rate the sound should be played at
  35878. */
  35879. setPlaybackRate(newPlaybackRate: number): void;
  35880. /**
  35881. * Gets the volume of the sound.
  35882. * @returns the volume of the sound
  35883. */
  35884. getVolume(): number;
  35885. /**
  35886. * Attach the sound to a dedicated mesh
  35887. * @param transformNode The transform node to connect the sound with
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35889. */
  35890. attachToMesh(transformNode: TransformNode): void;
  35891. /**
  35892. * Detach the sound from the previously attached mesh
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35894. */
  35895. detachFromMesh(): void;
  35896. private _onRegisterAfterWorldMatrixUpdate;
  35897. /**
  35898. * Clone the current sound in the scene.
  35899. * @returns the new sound clone
  35900. */
  35901. clone(): Nullable<Sound>;
  35902. /**
  35903. * Gets the current underlying audio buffer containing the data
  35904. * @returns the audio buffer
  35905. */
  35906. getAudioBuffer(): Nullable<AudioBuffer>;
  35907. /**
  35908. * Serializes the Sound in a JSON representation
  35909. * @returns the JSON representation of the sound
  35910. */
  35911. serialize(): any;
  35912. /**
  35913. * Parse a JSON representation of a sound to innstantiate in a given scene
  35914. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35915. * @param scene Define the scene the new parsed sound should be created in
  35916. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35917. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35918. * @returns the newly parsed sound
  35919. */
  35920. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35921. }
  35922. }
  35923. declare module "babylonjs/Actions/directAudioActions" {
  35924. import { Action } from "babylonjs/Actions/action";
  35925. import { Condition } from "babylonjs/Actions/condition";
  35926. import { Sound } from "babylonjs/Audio/sound";
  35927. /**
  35928. * This defines an action helpful to play a defined sound on a triggered action.
  35929. */
  35930. export class PlaySoundAction extends Action {
  35931. private _sound;
  35932. /**
  35933. * Instantiate the action
  35934. * @param triggerOptions defines the trigger options
  35935. * @param sound defines the sound to play
  35936. * @param condition defines the trigger related conditions
  35937. */
  35938. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35939. /** @hidden */
  35940. _prepare(): void;
  35941. /**
  35942. * Execute the action and play the sound.
  35943. */
  35944. execute(): void;
  35945. /**
  35946. * Serializes the actions and its related information.
  35947. * @param parent defines the object to serialize in
  35948. * @returns the serialized object
  35949. */
  35950. serialize(parent: any): any;
  35951. }
  35952. /**
  35953. * This defines an action helpful to stop a defined sound on a triggered action.
  35954. */
  35955. export class StopSoundAction extends Action {
  35956. private _sound;
  35957. /**
  35958. * Instantiate the action
  35959. * @param triggerOptions defines the trigger options
  35960. * @param sound defines the sound to stop
  35961. * @param condition defines the trigger related conditions
  35962. */
  35963. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35964. /** @hidden */
  35965. _prepare(): void;
  35966. /**
  35967. * Execute the action and stop the sound.
  35968. */
  35969. execute(): void;
  35970. /**
  35971. * Serializes the actions and its related information.
  35972. * @param parent defines the object to serialize in
  35973. * @returns the serialized object
  35974. */
  35975. serialize(parent: any): any;
  35976. }
  35977. }
  35978. declare module "babylonjs/Actions/interpolateValueAction" {
  35979. import { Action } from "babylonjs/Actions/action";
  35980. import { Condition } from "babylonjs/Actions/condition";
  35981. import { Observable } from "babylonjs/Misc/observable";
  35982. /**
  35983. * This defines an action responsible to change the value of a property
  35984. * by interpolating between its current value and the newly set one once triggered.
  35985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35986. */
  35987. export class InterpolateValueAction extends Action {
  35988. /**
  35989. * Defines the path of the property where the value should be interpolated
  35990. */
  35991. propertyPath: string;
  35992. /**
  35993. * Defines the target value at the end of the interpolation.
  35994. */
  35995. value: any;
  35996. /**
  35997. * Defines the time it will take for the property to interpolate to the value.
  35998. */
  35999. duration: number;
  36000. /**
  36001. * Defines if the other scene animations should be stopped when the action has been triggered
  36002. */
  36003. stopOtherAnimations?: boolean;
  36004. /**
  36005. * Defines a callback raised once the interpolation animation has been done.
  36006. */
  36007. onInterpolationDone?: () => void;
  36008. /**
  36009. * Observable triggered once the interpolation animation has been done.
  36010. */
  36011. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36012. private _target;
  36013. private _effectiveTarget;
  36014. private _property;
  36015. /**
  36016. * Instantiate the action
  36017. * @param triggerOptions defines the trigger options
  36018. * @param target defines the object containing the value to interpolate
  36019. * @param propertyPath defines the path to the property in the target object
  36020. * @param value defines the target value at the end of the interpolation
  36021. * @param duration deines the time it will take for the property to interpolate to the value.
  36022. * @param condition defines the trigger related conditions
  36023. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36024. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36025. */
  36026. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36027. /** @hidden */
  36028. _prepare(): void;
  36029. /**
  36030. * Execute the action starts the value interpolation.
  36031. */
  36032. execute(): void;
  36033. /**
  36034. * Serializes the actions and its related information.
  36035. * @param parent defines the object to serialize in
  36036. * @returns the serialized object
  36037. */
  36038. serialize(parent: any): any;
  36039. }
  36040. }
  36041. declare module "babylonjs/Actions/index" {
  36042. export * from "babylonjs/Actions/action";
  36043. export * from "babylonjs/Actions/actionEvent";
  36044. export * from "babylonjs/Actions/actionManager";
  36045. export * from "babylonjs/Actions/condition";
  36046. export * from "babylonjs/Actions/directActions";
  36047. export * from "babylonjs/Actions/directAudioActions";
  36048. export * from "babylonjs/Actions/interpolateValueAction";
  36049. }
  36050. declare module "babylonjs/Animations/index" {
  36051. export * from "babylonjs/Animations/animatable";
  36052. export * from "babylonjs/Animations/animation";
  36053. export * from "babylonjs/Animations/animationGroup";
  36054. export * from "babylonjs/Animations/animationPropertiesOverride";
  36055. export * from "babylonjs/Animations/easing";
  36056. export * from "babylonjs/Animations/runtimeAnimation";
  36057. export * from "babylonjs/Animations/animationEvent";
  36058. export * from "babylonjs/Animations/animationGroup";
  36059. export * from "babylonjs/Animations/animationKey";
  36060. export * from "babylonjs/Animations/animationRange";
  36061. export * from "babylonjs/Animations/animatable.interface";
  36062. }
  36063. declare module "babylonjs/Audio/soundTrack" {
  36064. import { Sound } from "babylonjs/Audio/sound";
  36065. import { Analyser } from "babylonjs/Audio/analyser";
  36066. import { Scene } from "babylonjs/scene";
  36067. /**
  36068. * Options allowed during the creation of a sound track.
  36069. */
  36070. export interface ISoundTrackOptions {
  36071. /**
  36072. * The volume the sound track should take during creation
  36073. */
  36074. volume?: number;
  36075. /**
  36076. * Define if the sound track is the main sound track of the scene
  36077. */
  36078. mainTrack?: boolean;
  36079. }
  36080. /**
  36081. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36082. * It will be also used in a future release to apply effects on a specific track.
  36083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36084. */
  36085. export class SoundTrack {
  36086. /**
  36087. * The unique identifier of the sound track in the scene.
  36088. */
  36089. id: number;
  36090. /**
  36091. * The list of sounds included in the sound track.
  36092. */
  36093. soundCollection: Array<Sound>;
  36094. private _outputAudioNode;
  36095. private _scene;
  36096. private _isMainTrack;
  36097. private _connectedAnalyser;
  36098. private _options;
  36099. private _isInitialized;
  36100. /**
  36101. * Creates a new sound track.
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36103. * @param scene Define the scene the sound track belongs to
  36104. * @param options
  36105. */
  36106. constructor(scene: Scene, options?: ISoundTrackOptions);
  36107. private _initializeSoundTrackAudioGraph;
  36108. /**
  36109. * Release the sound track and its associated resources
  36110. */
  36111. dispose(): void;
  36112. /**
  36113. * Adds a sound to this sound track
  36114. * @param sound define the cound to add
  36115. * @ignoreNaming
  36116. */
  36117. AddSound(sound: Sound): void;
  36118. /**
  36119. * Removes a sound to this sound track
  36120. * @param sound define the cound to remove
  36121. * @ignoreNaming
  36122. */
  36123. RemoveSound(sound: Sound): void;
  36124. /**
  36125. * Set a global volume for the full sound track.
  36126. * @param newVolume Define the new volume of the sound track
  36127. */
  36128. setVolume(newVolume: number): void;
  36129. /**
  36130. * Switch the panning model to HRTF:
  36131. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36133. */
  36134. switchPanningModelToHRTF(): void;
  36135. /**
  36136. * Switch the panning model to Equal Power:
  36137. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36139. */
  36140. switchPanningModelToEqualPower(): void;
  36141. /**
  36142. * Connect the sound track to an audio analyser allowing some amazing
  36143. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36145. * @param analyser The analyser to connect to the engine
  36146. */
  36147. connectToAnalyser(analyser: Analyser): void;
  36148. }
  36149. }
  36150. declare module "babylonjs/Audio/audioSceneComponent" {
  36151. import { Sound } from "babylonjs/Audio/sound";
  36152. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36153. import { Nullable } from "babylonjs/types";
  36154. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36155. import { Scene } from "babylonjs/scene";
  36156. import { AbstractScene } from "babylonjs/abstractScene";
  36157. import "babylonjs/Audio/audioEngine";
  36158. module "babylonjs/abstractScene" {
  36159. interface AbstractScene {
  36160. /**
  36161. * The list of sounds used in the scene.
  36162. */
  36163. sounds: Nullable<Array<Sound>>;
  36164. }
  36165. }
  36166. module "babylonjs/scene" {
  36167. interface Scene {
  36168. /**
  36169. * @hidden
  36170. * Backing field
  36171. */
  36172. _mainSoundTrack: SoundTrack;
  36173. /**
  36174. * The main sound track played by the scene.
  36175. * It cotains your primary collection of sounds.
  36176. */
  36177. mainSoundTrack: SoundTrack;
  36178. /**
  36179. * The list of sound tracks added to the scene
  36180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36181. */
  36182. soundTracks: Nullable<Array<SoundTrack>>;
  36183. /**
  36184. * Gets a sound using a given name
  36185. * @param name defines the name to search for
  36186. * @return the found sound or null if not found at all.
  36187. */
  36188. getSoundByName(name: string): Nullable<Sound>;
  36189. /**
  36190. * Gets or sets if audio support is enabled
  36191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36192. */
  36193. audioEnabled: boolean;
  36194. /**
  36195. * Gets or sets if audio will be output to headphones
  36196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36197. */
  36198. headphone: boolean;
  36199. }
  36200. }
  36201. /**
  36202. * Defines the sound scene component responsible to manage any sounds
  36203. * in a given scene.
  36204. */
  36205. export class AudioSceneComponent implements ISceneSerializableComponent {
  36206. /**
  36207. * The component name helpfull to identify the component in the list of scene components.
  36208. */
  36209. readonly name: string;
  36210. /**
  36211. * The scene the component belongs to.
  36212. */
  36213. scene: Scene;
  36214. private _audioEnabled;
  36215. /**
  36216. * Gets whether audio is enabled or not.
  36217. * Please use related enable/disable method to switch state.
  36218. */
  36219. readonly audioEnabled: boolean;
  36220. private _headphone;
  36221. /**
  36222. * Gets whether audio is outputing to headphone or not.
  36223. * Please use the according Switch methods to change output.
  36224. */
  36225. readonly headphone: boolean;
  36226. /**
  36227. * Creates a new instance of the component for the given scene
  36228. * @param scene Defines the scene to register the component in
  36229. */
  36230. constructor(scene: Scene);
  36231. /**
  36232. * Registers the component in a given scene
  36233. */
  36234. register(): void;
  36235. /**
  36236. * Rebuilds the elements related to this component in case of
  36237. * context lost for instance.
  36238. */
  36239. rebuild(): void;
  36240. /**
  36241. * Serializes the component data to the specified json object
  36242. * @param serializationObject The object to serialize to
  36243. */
  36244. serialize(serializationObject: any): void;
  36245. /**
  36246. * Adds all the elements from the container to the scene
  36247. * @param container the container holding the elements
  36248. */
  36249. addFromContainer(container: AbstractScene): void;
  36250. /**
  36251. * Removes all the elements in the container from the scene
  36252. * @param container contains the elements to remove
  36253. * @param dispose if the removed element should be disposed (default: false)
  36254. */
  36255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36256. /**
  36257. * Disposes the component and the associated ressources.
  36258. */
  36259. dispose(): void;
  36260. /**
  36261. * Disables audio in the associated scene.
  36262. */
  36263. disableAudio(): void;
  36264. /**
  36265. * Enables audio in the associated scene.
  36266. */
  36267. enableAudio(): void;
  36268. /**
  36269. * Switch audio to headphone output.
  36270. */
  36271. switchAudioModeForHeadphones(): void;
  36272. /**
  36273. * Switch audio to normal speakers.
  36274. */
  36275. switchAudioModeForNormalSpeakers(): void;
  36276. private _afterRender;
  36277. }
  36278. }
  36279. declare module "babylonjs/Audio/weightedsound" {
  36280. import { Sound } from "babylonjs/Audio/sound";
  36281. /**
  36282. * Wraps one or more Sound objects and selects one with random weight for playback.
  36283. */
  36284. export class WeightedSound {
  36285. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36286. loop: boolean;
  36287. private _coneInnerAngle;
  36288. private _coneOuterAngle;
  36289. private _volume;
  36290. /** A Sound is currently playing. */
  36291. isPlaying: boolean;
  36292. /** A Sound is currently paused. */
  36293. isPaused: boolean;
  36294. private _sounds;
  36295. private _weights;
  36296. private _currentIndex?;
  36297. /**
  36298. * Creates a new WeightedSound from the list of sounds given.
  36299. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36300. * @param sounds Array of Sounds that will be selected from.
  36301. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36302. */
  36303. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36304. /**
  36305. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36306. */
  36307. /**
  36308. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36309. */
  36310. directionalConeInnerAngle: number;
  36311. /**
  36312. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36313. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36314. */
  36315. /**
  36316. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36317. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36318. */
  36319. directionalConeOuterAngle: number;
  36320. /**
  36321. * Playback volume.
  36322. */
  36323. /**
  36324. * Playback volume.
  36325. */
  36326. volume: number;
  36327. private _onended;
  36328. /**
  36329. * Suspend playback
  36330. */
  36331. pause(): void;
  36332. /**
  36333. * Stop playback
  36334. */
  36335. stop(): void;
  36336. /**
  36337. * Start playback.
  36338. * @param startOffset Position the clip head at a specific time in seconds.
  36339. */
  36340. play(startOffset?: number): void;
  36341. }
  36342. }
  36343. declare module "babylonjs/Audio/index" {
  36344. export * from "babylonjs/Audio/analyser";
  36345. export * from "babylonjs/Audio/audioEngine";
  36346. export * from "babylonjs/Audio/audioSceneComponent";
  36347. export * from "babylonjs/Audio/sound";
  36348. export * from "babylonjs/Audio/soundTrack";
  36349. export * from "babylonjs/Audio/weightedsound";
  36350. }
  36351. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36352. import { Behavior } from "babylonjs/Behaviors/behavior";
  36353. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36354. import { BackEase } from "babylonjs/Animations/easing";
  36355. /**
  36356. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36357. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36358. */
  36359. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36360. /**
  36361. * Gets the name of the behavior.
  36362. */
  36363. readonly name: string;
  36364. /**
  36365. * The easing function used by animations
  36366. */
  36367. static EasingFunction: BackEase;
  36368. /**
  36369. * The easing mode used by animations
  36370. */
  36371. static EasingMode: number;
  36372. /**
  36373. * The duration of the animation, in milliseconds
  36374. */
  36375. transitionDuration: number;
  36376. /**
  36377. * Length of the distance animated by the transition when lower radius is reached
  36378. */
  36379. lowerRadiusTransitionRange: number;
  36380. /**
  36381. * Length of the distance animated by the transition when upper radius is reached
  36382. */
  36383. upperRadiusTransitionRange: number;
  36384. private _autoTransitionRange;
  36385. /**
  36386. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36387. */
  36388. /**
  36389. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36390. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36391. */
  36392. autoTransitionRange: boolean;
  36393. private _attachedCamera;
  36394. private _onAfterCheckInputsObserver;
  36395. private _onMeshTargetChangedObserver;
  36396. /**
  36397. * Initializes the behavior.
  36398. */
  36399. init(): void;
  36400. /**
  36401. * Attaches the behavior to its arc rotate camera.
  36402. * @param camera Defines the camera to attach the behavior to
  36403. */
  36404. attach(camera: ArcRotateCamera): void;
  36405. /**
  36406. * Detaches the behavior from its current arc rotate camera.
  36407. */
  36408. detach(): void;
  36409. private _radiusIsAnimating;
  36410. private _radiusBounceTransition;
  36411. private _animatables;
  36412. private _cachedWheelPrecision;
  36413. /**
  36414. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36415. * @param radiusLimit The limit to check against.
  36416. * @return Bool to indicate if at limit.
  36417. */
  36418. private _isRadiusAtLimit;
  36419. /**
  36420. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36421. * @param radiusDelta The delta by which to animate to. Can be negative.
  36422. */
  36423. private _applyBoundRadiusAnimation;
  36424. /**
  36425. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36426. */
  36427. protected _clearAnimationLocks(): void;
  36428. /**
  36429. * Stops and removes all animations that have been applied to the camera
  36430. */
  36431. stopAllAnimations(): void;
  36432. }
  36433. }
  36434. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36435. import { Behavior } from "babylonjs/Behaviors/behavior";
  36436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36437. import { ExponentialEase } from "babylonjs/Animations/easing";
  36438. import { Nullable } from "babylonjs/types";
  36439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36440. import { Vector3 } from "babylonjs/Maths/math.vector";
  36441. /**
  36442. * 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.
  36443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36444. */
  36445. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36446. /**
  36447. * Gets the name of the behavior.
  36448. */
  36449. readonly name: string;
  36450. private _mode;
  36451. private _radiusScale;
  36452. private _positionScale;
  36453. private _defaultElevation;
  36454. private _elevationReturnTime;
  36455. private _elevationReturnWaitTime;
  36456. private _zoomStopsAnimation;
  36457. private _framingTime;
  36458. /**
  36459. * The easing function used by animations
  36460. */
  36461. static EasingFunction: ExponentialEase;
  36462. /**
  36463. * The easing mode used by animations
  36464. */
  36465. static EasingMode: number;
  36466. /**
  36467. * Sets the current mode used by the behavior
  36468. */
  36469. /**
  36470. * Gets current mode used by the behavior.
  36471. */
  36472. mode: number;
  36473. /**
  36474. * Sets the scale applied to the radius (1 by default)
  36475. */
  36476. /**
  36477. * Gets the scale applied to the radius
  36478. */
  36479. radiusScale: number;
  36480. /**
  36481. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36482. */
  36483. /**
  36484. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36485. */
  36486. positionScale: number;
  36487. /**
  36488. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36489. * behaviour is triggered, in radians.
  36490. */
  36491. /**
  36492. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36493. * behaviour is triggered, in radians.
  36494. */
  36495. defaultElevation: number;
  36496. /**
  36497. * Sets the time (in milliseconds) taken to return to the default beta position.
  36498. * Negative value indicates camera should not return to default.
  36499. */
  36500. /**
  36501. * Gets the time (in milliseconds) taken to return to the default beta position.
  36502. * Negative value indicates camera should not return to default.
  36503. */
  36504. elevationReturnTime: number;
  36505. /**
  36506. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36507. */
  36508. /**
  36509. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36510. */
  36511. elevationReturnWaitTime: number;
  36512. /**
  36513. * Sets the flag that indicates if user zooming should stop animation.
  36514. */
  36515. /**
  36516. * Gets the flag that indicates if user zooming should stop animation.
  36517. */
  36518. zoomStopsAnimation: boolean;
  36519. /**
  36520. * Sets the transition time when framing the mesh, in milliseconds
  36521. */
  36522. /**
  36523. * Gets the transition time when framing the mesh, in milliseconds
  36524. */
  36525. framingTime: number;
  36526. /**
  36527. * Define if the behavior should automatically change the configured
  36528. * camera limits and sensibilities.
  36529. */
  36530. autoCorrectCameraLimitsAndSensibility: boolean;
  36531. private _onPrePointerObservableObserver;
  36532. private _onAfterCheckInputsObserver;
  36533. private _onMeshTargetChangedObserver;
  36534. private _attachedCamera;
  36535. private _isPointerDown;
  36536. private _lastInteractionTime;
  36537. /**
  36538. * Initializes the behavior.
  36539. */
  36540. init(): void;
  36541. /**
  36542. * Attaches the behavior to its arc rotate camera.
  36543. * @param camera Defines the camera to attach the behavior to
  36544. */
  36545. attach(camera: ArcRotateCamera): void;
  36546. /**
  36547. * Detaches the behavior from its current arc rotate camera.
  36548. */
  36549. detach(): void;
  36550. private _animatables;
  36551. private _betaIsAnimating;
  36552. private _betaTransition;
  36553. private _radiusTransition;
  36554. private _vectorTransition;
  36555. /**
  36556. * Targets the given mesh and updates zoom level accordingly.
  36557. * @param mesh The mesh to target.
  36558. * @param radius Optional. If a cached radius position already exists, overrides default.
  36559. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36560. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36561. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36562. */
  36563. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36564. /**
  36565. * Targets the given mesh with its children and updates zoom level accordingly.
  36566. * @param mesh The mesh to target.
  36567. * @param radius Optional. If a cached radius position already exists, overrides default.
  36568. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36569. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36570. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36571. */
  36572. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36573. /**
  36574. * Targets the given meshes with their children and updates zoom level accordingly.
  36575. * @param meshes The mesh to target.
  36576. * @param radius Optional. If a cached radius position already exists, overrides default.
  36577. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36578. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36579. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36580. */
  36581. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36582. /**
  36583. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36584. * @param minimumWorld Determines the smaller position of the bounding box extend
  36585. * @param maximumWorld Determines the bigger position of the bounding box extend
  36586. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36587. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36588. */
  36589. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36590. /**
  36591. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36592. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36593. * frustum width.
  36594. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36595. * to fully enclose the mesh in the viewing frustum.
  36596. */
  36597. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36598. /**
  36599. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36600. * is automatically returned to its default position (expected to be above ground plane).
  36601. */
  36602. private _maintainCameraAboveGround;
  36603. /**
  36604. * Returns the frustum slope based on the canvas ratio and camera FOV
  36605. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36606. */
  36607. private _getFrustumSlope;
  36608. /**
  36609. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36610. */
  36611. private _clearAnimationLocks;
  36612. /**
  36613. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36614. */
  36615. private _applyUserInteraction;
  36616. /**
  36617. * Stops and removes all animations that have been applied to the camera
  36618. */
  36619. stopAllAnimations(): void;
  36620. /**
  36621. * Gets a value indicating if the user is moving the camera
  36622. */
  36623. readonly isUserIsMoving: boolean;
  36624. /**
  36625. * The camera can move all the way towards the mesh.
  36626. */
  36627. static IgnoreBoundsSizeMode: number;
  36628. /**
  36629. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36630. */
  36631. static FitFrustumSidesMode: number;
  36632. }
  36633. }
  36634. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36635. import { Nullable } from "babylonjs/types";
  36636. import { Camera } from "babylonjs/Cameras/camera";
  36637. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36638. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36639. /**
  36640. * Base class for Camera Pointer Inputs.
  36641. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36642. * for example usage.
  36643. */
  36644. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36645. /**
  36646. * Defines the camera the input is attached to.
  36647. */
  36648. abstract camera: Camera;
  36649. /**
  36650. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36651. */
  36652. protected _altKey: boolean;
  36653. protected _ctrlKey: boolean;
  36654. protected _metaKey: boolean;
  36655. protected _shiftKey: boolean;
  36656. /**
  36657. * Which mouse buttons were pressed at time of last mouse event.
  36658. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36659. */
  36660. protected _buttonsPressed: number;
  36661. /**
  36662. * Defines the buttons associated with the input to handle camera move.
  36663. */
  36664. buttons: number[];
  36665. /**
  36666. * Attach the input controls to a specific dom element to get the input from.
  36667. * @param element Defines the element the controls should be listened from
  36668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36669. */
  36670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36671. /**
  36672. * Detach the current controls from the specified dom element.
  36673. * @param element Defines the element to stop listening the inputs from
  36674. */
  36675. detachControl(element: Nullable<HTMLElement>): void;
  36676. /**
  36677. * Gets the class name of the current input.
  36678. * @returns the class name
  36679. */
  36680. getClassName(): string;
  36681. /**
  36682. * Get the friendly name associated with the input class.
  36683. * @returns the input friendly name
  36684. */
  36685. getSimpleName(): string;
  36686. /**
  36687. * Called on pointer POINTERDOUBLETAP event.
  36688. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36689. */
  36690. protected onDoubleTap(type: string): void;
  36691. /**
  36692. * Called on pointer POINTERMOVE event if only a single touch is active.
  36693. * Override this method to provide functionality.
  36694. */
  36695. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36696. /**
  36697. * Called on pointer POINTERMOVE event if multiple touches are active.
  36698. * Override this method to provide functionality.
  36699. */
  36700. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36701. /**
  36702. * Called on JS contextmenu event.
  36703. * Override this method to provide functionality.
  36704. */
  36705. protected onContextMenu(evt: PointerEvent): void;
  36706. /**
  36707. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36708. * press.
  36709. * Override this method to provide functionality.
  36710. */
  36711. protected onButtonDown(evt: PointerEvent): void;
  36712. /**
  36713. * Called each time a new POINTERUP event occurs. Ie, for each button
  36714. * release.
  36715. * Override this method to provide functionality.
  36716. */
  36717. protected onButtonUp(evt: PointerEvent): void;
  36718. /**
  36719. * Called when window becomes inactive.
  36720. * Override this method to provide functionality.
  36721. */
  36722. protected onLostFocus(): void;
  36723. private _pointerInput;
  36724. private _observer;
  36725. private _onLostFocus;
  36726. private pointA;
  36727. private pointB;
  36728. }
  36729. }
  36730. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36731. import { Nullable } from "babylonjs/types";
  36732. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36733. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36734. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36735. /**
  36736. * Manage the pointers inputs to control an arc rotate camera.
  36737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36738. */
  36739. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36740. /**
  36741. * Defines the camera the input is attached to.
  36742. */
  36743. camera: ArcRotateCamera;
  36744. /**
  36745. * Gets the class name of the current input.
  36746. * @returns the class name
  36747. */
  36748. getClassName(): string;
  36749. /**
  36750. * Defines the buttons associated with the input to handle camera move.
  36751. */
  36752. buttons: number[];
  36753. /**
  36754. * Defines the pointer angular sensibility along the X axis or how fast is
  36755. * the camera rotating.
  36756. */
  36757. angularSensibilityX: number;
  36758. /**
  36759. * Defines the pointer angular sensibility along the Y axis or how fast is
  36760. * the camera rotating.
  36761. */
  36762. angularSensibilityY: number;
  36763. /**
  36764. * Defines the pointer pinch precision or how fast is the camera zooming.
  36765. */
  36766. pinchPrecision: number;
  36767. /**
  36768. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36769. * from 0.
  36770. * It defines the percentage of current camera.radius to use as delta when
  36771. * pinch zoom is used.
  36772. */
  36773. pinchDeltaPercentage: number;
  36774. /**
  36775. * Defines the pointer panning sensibility or how fast is the camera moving.
  36776. */
  36777. panningSensibility: number;
  36778. /**
  36779. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36780. */
  36781. multiTouchPanning: boolean;
  36782. /**
  36783. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36784. * zoom (pinch) through multitouch.
  36785. */
  36786. multiTouchPanAndZoom: boolean;
  36787. /**
  36788. * Revers pinch action direction.
  36789. */
  36790. pinchInwards: boolean;
  36791. private _isPanClick;
  36792. private _twoFingerActivityCount;
  36793. private _isPinching;
  36794. /**
  36795. * Called on pointer POINTERMOVE event if only a single touch is active.
  36796. */
  36797. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36798. /**
  36799. * Called on pointer POINTERDOUBLETAP event.
  36800. */
  36801. protected onDoubleTap(type: string): void;
  36802. /**
  36803. * Called on pointer POINTERMOVE event if multiple touches are active.
  36804. */
  36805. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36806. /**
  36807. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36808. * press.
  36809. */
  36810. protected onButtonDown(evt: PointerEvent): void;
  36811. /**
  36812. * Called each time a new POINTERUP event occurs. Ie, for each button
  36813. * release.
  36814. */
  36815. protected onButtonUp(evt: PointerEvent): void;
  36816. /**
  36817. * Called when window becomes inactive.
  36818. */
  36819. protected onLostFocus(): void;
  36820. }
  36821. }
  36822. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36823. import { Nullable } from "babylonjs/types";
  36824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36825. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36826. /**
  36827. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36829. */
  36830. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36831. /**
  36832. * Defines the camera the input is attached to.
  36833. */
  36834. camera: ArcRotateCamera;
  36835. /**
  36836. * Defines the list of key codes associated with the up action (increase alpha)
  36837. */
  36838. keysUp: number[];
  36839. /**
  36840. * Defines the list of key codes associated with the down action (decrease alpha)
  36841. */
  36842. keysDown: number[];
  36843. /**
  36844. * Defines the list of key codes associated with the left action (increase beta)
  36845. */
  36846. keysLeft: number[];
  36847. /**
  36848. * Defines the list of key codes associated with the right action (decrease beta)
  36849. */
  36850. keysRight: number[];
  36851. /**
  36852. * Defines the list of key codes associated with the reset action.
  36853. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36854. */
  36855. keysReset: number[];
  36856. /**
  36857. * Defines the panning sensibility of the inputs.
  36858. * (How fast is the camera paning)
  36859. */
  36860. panningSensibility: number;
  36861. /**
  36862. * Defines the zooming sensibility of the inputs.
  36863. * (How fast is the camera zooming)
  36864. */
  36865. zoomingSensibility: number;
  36866. /**
  36867. * Defines wether maintaining the alt key down switch the movement mode from
  36868. * orientation to zoom.
  36869. */
  36870. useAltToZoom: boolean;
  36871. /**
  36872. * Rotation speed of the camera
  36873. */
  36874. angularSpeed: number;
  36875. private _keys;
  36876. private _ctrlPressed;
  36877. private _altPressed;
  36878. private _onCanvasBlurObserver;
  36879. private _onKeyboardObserver;
  36880. private _engine;
  36881. private _scene;
  36882. /**
  36883. * Attach the input controls to a specific dom element to get the input from.
  36884. * @param element Defines the element the controls should be listened from
  36885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36886. */
  36887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36888. /**
  36889. * Detach the current controls from the specified dom element.
  36890. * @param element Defines the element to stop listening the inputs from
  36891. */
  36892. detachControl(element: Nullable<HTMLElement>): void;
  36893. /**
  36894. * Update the current camera state depending on the inputs that have been used this frame.
  36895. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36896. */
  36897. checkInputs(): void;
  36898. /**
  36899. * Gets the class name of the current intput.
  36900. * @returns the class name
  36901. */
  36902. getClassName(): string;
  36903. /**
  36904. * Get the friendly name associated with the input class.
  36905. * @returns the input friendly name
  36906. */
  36907. getSimpleName(): string;
  36908. }
  36909. }
  36910. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36911. import { Nullable } from "babylonjs/types";
  36912. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36914. /**
  36915. * Manage the mouse wheel inputs to control an arc rotate camera.
  36916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36917. */
  36918. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36919. /**
  36920. * Defines the camera the input is attached to.
  36921. */
  36922. camera: ArcRotateCamera;
  36923. /**
  36924. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36925. */
  36926. wheelPrecision: number;
  36927. /**
  36928. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36929. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36930. */
  36931. wheelDeltaPercentage: number;
  36932. private _wheel;
  36933. private _observer;
  36934. private computeDeltaFromMouseWheelLegacyEvent;
  36935. /**
  36936. * Attach the input controls to a specific dom element to get the input from.
  36937. * @param element Defines the element the controls should be listened from
  36938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36939. */
  36940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36941. /**
  36942. * Detach the current controls from the specified dom element.
  36943. * @param element Defines the element to stop listening the inputs from
  36944. */
  36945. detachControl(element: Nullable<HTMLElement>): void;
  36946. /**
  36947. * Gets the class name of the current intput.
  36948. * @returns the class name
  36949. */
  36950. getClassName(): string;
  36951. /**
  36952. * Get the friendly name associated with the input class.
  36953. * @returns the input friendly name
  36954. */
  36955. getSimpleName(): string;
  36956. }
  36957. }
  36958. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36959. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36960. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36961. /**
  36962. * Default Inputs manager for the ArcRotateCamera.
  36963. * It groups all the default supported inputs for ease of use.
  36964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36965. */
  36966. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36967. /**
  36968. * Instantiates a new ArcRotateCameraInputsManager.
  36969. * @param camera Defines the camera the inputs belong to
  36970. */
  36971. constructor(camera: ArcRotateCamera);
  36972. /**
  36973. * Add mouse wheel input support to the input manager.
  36974. * @returns the current input manager
  36975. */
  36976. addMouseWheel(): ArcRotateCameraInputsManager;
  36977. /**
  36978. * Add pointers input support to the input manager.
  36979. * @returns the current input manager
  36980. */
  36981. addPointers(): ArcRotateCameraInputsManager;
  36982. /**
  36983. * Add keyboard input support to the input manager.
  36984. * @returns the current input manager
  36985. */
  36986. addKeyboard(): ArcRotateCameraInputsManager;
  36987. }
  36988. }
  36989. declare module "babylonjs/Cameras/arcRotateCamera" {
  36990. import { Observable } from "babylonjs/Misc/observable";
  36991. import { Nullable } from "babylonjs/types";
  36992. import { Scene } from "babylonjs/scene";
  36993. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36995. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36996. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36997. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36998. import { Camera } from "babylonjs/Cameras/camera";
  36999. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37000. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37001. import { Collider } from "babylonjs/Collisions/collider";
  37002. /**
  37003. * This represents an orbital type of camera.
  37004. *
  37005. * 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.
  37006. * 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.
  37007. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37008. */
  37009. export class ArcRotateCamera extends TargetCamera {
  37010. /**
  37011. * Defines the rotation angle of the camera along the longitudinal axis.
  37012. */
  37013. alpha: number;
  37014. /**
  37015. * Defines the rotation angle of the camera along the latitudinal axis.
  37016. */
  37017. beta: number;
  37018. /**
  37019. * Defines the radius of the camera from it s target point.
  37020. */
  37021. radius: number;
  37022. protected _target: Vector3;
  37023. protected _targetHost: Nullable<AbstractMesh>;
  37024. /**
  37025. * Defines the target point of the camera.
  37026. * The camera looks towards it form the radius distance.
  37027. */
  37028. target: Vector3;
  37029. /**
  37030. * Define the current local position of the camera in the scene
  37031. */
  37032. position: Vector3;
  37033. protected _upVector: Vector3;
  37034. protected _upToYMatrix: Matrix;
  37035. protected _YToUpMatrix: Matrix;
  37036. /**
  37037. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37038. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37039. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37040. */
  37041. upVector: Vector3;
  37042. /**
  37043. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37044. */
  37045. setMatUp(): void;
  37046. /**
  37047. * Current inertia value on the longitudinal axis.
  37048. * The bigger this number the longer it will take for the camera to stop.
  37049. */
  37050. inertialAlphaOffset: number;
  37051. /**
  37052. * Current inertia value on the latitudinal axis.
  37053. * The bigger this number the longer it will take for the camera to stop.
  37054. */
  37055. inertialBetaOffset: number;
  37056. /**
  37057. * Current inertia value on the radius axis.
  37058. * The bigger this number the longer it will take for the camera to stop.
  37059. */
  37060. inertialRadiusOffset: number;
  37061. /**
  37062. * Minimum allowed angle on the longitudinal axis.
  37063. * This can help limiting how the Camera is able to move in the scene.
  37064. */
  37065. lowerAlphaLimit: Nullable<number>;
  37066. /**
  37067. * Maximum allowed angle on the longitudinal axis.
  37068. * This can help limiting how the Camera is able to move in the scene.
  37069. */
  37070. upperAlphaLimit: Nullable<number>;
  37071. /**
  37072. * Minimum allowed angle on the latitudinal axis.
  37073. * This can help limiting how the Camera is able to move in the scene.
  37074. */
  37075. lowerBetaLimit: number;
  37076. /**
  37077. * Maximum allowed angle on the latitudinal axis.
  37078. * This can help limiting how the Camera is able to move in the scene.
  37079. */
  37080. upperBetaLimit: number;
  37081. /**
  37082. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37083. * This can help limiting how the Camera is able to move in the scene.
  37084. */
  37085. lowerRadiusLimit: Nullable<number>;
  37086. /**
  37087. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37088. * This can help limiting how the Camera is able to move in the scene.
  37089. */
  37090. upperRadiusLimit: Nullable<number>;
  37091. /**
  37092. * Defines the current inertia value used during panning of the camera along the X axis.
  37093. */
  37094. inertialPanningX: number;
  37095. /**
  37096. * Defines the current inertia value used during panning of the camera along the Y axis.
  37097. */
  37098. inertialPanningY: number;
  37099. /**
  37100. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37101. * Basically if your fingers moves away from more than this distance you will be considered
  37102. * in pinch mode.
  37103. */
  37104. pinchToPanMaxDistance: number;
  37105. /**
  37106. * Defines the maximum distance the camera can pan.
  37107. * This could help keeping the cammera always in your scene.
  37108. */
  37109. panningDistanceLimit: Nullable<number>;
  37110. /**
  37111. * Defines the target of the camera before paning.
  37112. */
  37113. panningOriginTarget: Vector3;
  37114. /**
  37115. * Defines the value of the inertia used during panning.
  37116. * 0 would mean stop inertia and one would mean no decelleration at all.
  37117. */
  37118. panningInertia: number;
  37119. /**
  37120. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37121. */
  37122. angularSensibilityX: number;
  37123. /**
  37124. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37125. */
  37126. angularSensibilityY: number;
  37127. /**
  37128. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37129. */
  37130. pinchPrecision: number;
  37131. /**
  37132. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37133. * It will be used instead of pinchDeltaPrecision if different from 0.
  37134. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37135. */
  37136. pinchDeltaPercentage: number;
  37137. /**
  37138. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37139. */
  37140. panningSensibility: number;
  37141. /**
  37142. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37143. */
  37144. keysUp: number[];
  37145. /**
  37146. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37147. */
  37148. keysDown: number[];
  37149. /**
  37150. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37151. */
  37152. keysLeft: number[];
  37153. /**
  37154. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37155. */
  37156. keysRight: number[];
  37157. /**
  37158. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37159. */
  37160. wheelPrecision: number;
  37161. /**
  37162. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37163. * It will be used instead of pinchDeltaPrecision if different from 0.
  37164. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37165. */
  37166. wheelDeltaPercentage: number;
  37167. /**
  37168. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37169. */
  37170. zoomOnFactor: number;
  37171. /**
  37172. * Defines a screen offset for the camera position.
  37173. */
  37174. targetScreenOffset: Vector2;
  37175. /**
  37176. * Allows the camera to be completely reversed.
  37177. * If false the camera can not arrive upside down.
  37178. */
  37179. allowUpsideDown: boolean;
  37180. /**
  37181. * Define if double tap/click is used to restore the previously saved state of the camera.
  37182. */
  37183. useInputToRestoreState: boolean;
  37184. /** @hidden */
  37185. _viewMatrix: Matrix;
  37186. /** @hidden */
  37187. _useCtrlForPanning: boolean;
  37188. /** @hidden */
  37189. _panningMouseButton: number;
  37190. /**
  37191. * Defines the input associated to the camera.
  37192. */
  37193. inputs: ArcRotateCameraInputsManager;
  37194. /** @hidden */
  37195. _reset: () => void;
  37196. /**
  37197. * Defines the allowed panning axis.
  37198. */
  37199. panningAxis: Vector3;
  37200. protected _localDirection: Vector3;
  37201. protected _transformedDirection: Vector3;
  37202. private _bouncingBehavior;
  37203. /**
  37204. * Gets the bouncing behavior of the camera if it has been enabled.
  37205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37206. */
  37207. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37208. /**
  37209. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37211. */
  37212. useBouncingBehavior: boolean;
  37213. private _framingBehavior;
  37214. /**
  37215. * Gets the framing behavior of the camera if it has been enabled.
  37216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37217. */
  37218. readonly framingBehavior: Nullable<FramingBehavior>;
  37219. /**
  37220. * Defines if the framing behavior of the camera is enabled on the camera.
  37221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37222. */
  37223. useFramingBehavior: boolean;
  37224. private _autoRotationBehavior;
  37225. /**
  37226. * Gets the auto rotation behavior of the camera if it has been enabled.
  37227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37228. */
  37229. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37230. /**
  37231. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37233. */
  37234. useAutoRotationBehavior: boolean;
  37235. /**
  37236. * Observable triggered when the mesh target has been changed on the camera.
  37237. */
  37238. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37239. /**
  37240. * Event raised when the camera is colliding with a mesh.
  37241. */
  37242. onCollide: (collidedMesh: AbstractMesh) => void;
  37243. /**
  37244. * Defines whether the camera should check collision with the objects oh the scene.
  37245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37246. */
  37247. checkCollisions: boolean;
  37248. /**
  37249. * Defines the collision radius of the camera.
  37250. * This simulates a sphere around the camera.
  37251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37252. */
  37253. collisionRadius: Vector3;
  37254. protected _collider: Collider;
  37255. protected _previousPosition: Vector3;
  37256. protected _collisionVelocity: Vector3;
  37257. protected _newPosition: Vector3;
  37258. protected _previousAlpha: number;
  37259. protected _previousBeta: number;
  37260. protected _previousRadius: number;
  37261. protected _collisionTriggered: boolean;
  37262. protected _targetBoundingCenter: Nullable<Vector3>;
  37263. private _computationVector;
  37264. /**
  37265. * Instantiates a new ArcRotateCamera in a given scene
  37266. * @param name Defines the name of the camera
  37267. * @param alpha Defines the camera rotation along the logitudinal axis
  37268. * @param beta Defines the camera rotation along the latitudinal axis
  37269. * @param radius Defines the camera distance from its target
  37270. * @param target Defines the camera target
  37271. * @param scene Defines the scene the camera belongs to
  37272. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37273. */
  37274. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37275. /** @hidden */
  37276. _initCache(): void;
  37277. /** @hidden */
  37278. _updateCache(ignoreParentClass?: boolean): void;
  37279. protected _getTargetPosition(): Vector3;
  37280. private _storedAlpha;
  37281. private _storedBeta;
  37282. private _storedRadius;
  37283. private _storedTarget;
  37284. /**
  37285. * Stores the current state of the camera (alpha, beta, radius and target)
  37286. * @returns the camera itself
  37287. */
  37288. storeState(): Camera;
  37289. /**
  37290. * @hidden
  37291. * Restored camera state. You must call storeState() first
  37292. */
  37293. _restoreStateValues(): boolean;
  37294. /** @hidden */
  37295. _isSynchronizedViewMatrix(): boolean;
  37296. /**
  37297. * Attached controls to the current camera.
  37298. * @param element Defines the element the controls should be listened from
  37299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37300. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37301. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37302. */
  37303. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37304. /**
  37305. * Detach the current controls from the camera.
  37306. * The camera will stop reacting to inputs.
  37307. * @param element Defines the element to stop listening the inputs from
  37308. */
  37309. detachControl(element: HTMLElement): void;
  37310. /** @hidden */
  37311. _checkInputs(): void;
  37312. protected _checkLimits(): void;
  37313. /**
  37314. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37315. */
  37316. rebuildAnglesAndRadius(): void;
  37317. /**
  37318. * Use a position to define the current camera related information like aplha, beta and radius
  37319. * @param position Defines the position to set the camera at
  37320. */
  37321. setPosition(position: Vector3): void;
  37322. /**
  37323. * Defines the target the camera should look at.
  37324. * This will automatically adapt alpha beta and radius to fit within the new target.
  37325. * @param target Defines the new target as a Vector or a mesh
  37326. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37327. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37328. */
  37329. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37330. /** @hidden */
  37331. _getViewMatrix(): Matrix;
  37332. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37333. /**
  37334. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37335. * @param meshes Defines the mesh to zoom on
  37336. * @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)
  37337. */
  37338. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37339. /**
  37340. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37341. * The target will be changed but the radius
  37342. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37343. * @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)
  37344. */
  37345. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37346. min: Vector3;
  37347. max: Vector3;
  37348. distance: number;
  37349. }, doNotUpdateMaxZ?: boolean): void;
  37350. /**
  37351. * @override
  37352. * Override Camera.createRigCamera
  37353. */
  37354. createRigCamera(name: string, cameraIndex: number): Camera;
  37355. /**
  37356. * @hidden
  37357. * @override
  37358. * Override Camera._updateRigCameras
  37359. */
  37360. _updateRigCameras(): void;
  37361. /**
  37362. * Destroy the camera and release the current resources hold by it.
  37363. */
  37364. dispose(): void;
  37365. /**
  37366. * Gets the current object class name.
  37367. * @return the class name
  37368. */
  37369. getClassName(): string;
  37370. }
  37371. }
  37372. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37373. import { Behavior } from "babylonjs/Behaviors/behavior";
  37374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37375. /**
  37376. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37378. */
  37379. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37380. /**
  37381. * Gets the name of the behavior.
  37382. */
  37383. readonly name: string;
  37384. private _zoomStopsAnimation;
  37385. private _idleRotationSpeed;
  37386. private _idleRotationWaitTime;
  37387. private _idleRotationSpinupTime;
  37388. /**
  37389. * Sets the flag that indicates if user zooming should stop animation.
  37390. */
  37391. /**
  37392. * Gets the flag that indicates if user zooming should stop animation.
  37393. */
  37394. zoomStopsAnimation: boolean;
  37395. /**
  37396. * Sets the default speed at which the camera rotates around the model.
  37397. */
  37398. /**
  37399. * Gets the default speed at which the camera rotates around the model.
  37400. */
  37401. idleRotationSpeed: number;
  37402. /**
  37403. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37404. */
  37405. /**
  37406. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37407. */
  37408. idleRotationWaitTime: number;
  37409. /**
  37410. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37411. */
  37412. /**
  37413. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37414. */
  37415. idleRotationSpinupTime: number;
  37416. /**
  37417. * Gets a value indicating if the camera is currently rotating because of this behavior
  37418. */
  37419. readonly rotationInProgress: boolean;
  37420. private _onPrePointerObservableObserver;
  37421. private _onAfterCheckInputsObserver;
  37422. private _attachedCamera;
  37423. private _isPointerDown;
  37424. private _lastFrameTime;
  37425. private _lastInteractionTime;
  37426. private _cameraRotationSpeed;
  37427. /**
  37428. * Initializes the behavior.
  37429. */
  37430. init(): void;
  37431. /**
  37432. * Attaches the behavior to its arc rotate camera.
  37433. * @param camera Defines the camera to attach the behavior to
  37434. */
  37435. attach(camera: ArcRotateCamera): void;
  37436. /**
  37437. * Detaches the behavior from its current arc rotate camera.
  37438. */
  37439. detach(): void;
  37440. /**
  37441. * Returns true if user is scrolling.
  37442. * @return true if user is scrolling.
  37443. */
  37444. private _userIsZooming;
  37445. private _lastFrameRadius;
  37446. private _shouldAnimationStopForInteraction;
  37447. /**
  37448. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37449. */
  37450. private _applyUserInteraction;
  37451. private _userIsMoving;
  37452. }
  37453. }
  37454. declare module "babylonjs/Behaviors/Cameras/index" {
  37455. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37456. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37457. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37458. }
  37459. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37460. import { Mesh } from "babylonjs/Meshes/mesh";
  37461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37462. import { Behavior } from "babylonjs/Behaviors/behavior";
  37463. /**
  37464. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37465. */
  37466. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37467. private ui;
  37468. /**
  37469. * The name of the behavior
  37470. */
  37471. name: string;
  37472. /**
  37473. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37474. */
  37475. distanceAwayFromFace: number;
  37476. /**
  37477. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37478. */
  37479. distanceAwayFromBottomOfFace: number;
  37480. private _faceVectors;
  37481. private _target;
  37482. private _scene;
  37483. private _onRenderObserver;
  37484. private _tmpMatrix;
  37485. private _tmpVector;
  37486. /**
  37487. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37488. * @param ui The transform node that should be attched to the mesh
  37489. */
  37490. constructor(ui: TransformNode);
  37491. /**
  37492. * Initializes the behavior
  37493. */
  37494. init(): void;
  37495. private _closestFace;
  37496. private _zeroVector;
  37497. private _lookAtTmpMatrix;
  37498. private _lookAtToRef;
  37499. /**
  37500. * Attaches the AttachToBoxBehavior to the passed in mesh
  37501. * @param target The mesh that the specified node will be attached to
  37502. */
  37503. attach(target: Mesh): void;
  37504. /**
  37505. * Detaches the behavior from the mesh
  37506. */
  37507. detach(): void;
  37508. }
  37509. }
  37510. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37511. import { Behavior } from "babylonjs/Behaviors/behavior";
  37512. import { Mesh } from "babylonjs/Meshes/mesh";
  37513. /**
  37514. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37515. */
  37516. export class FadeInOutBehavior implements Behavior<Mesh> {
  37517. /**
  37518. * Time in milliseconds to delay before fading in (Default: 0)
  37519. */
  37520. delay: number;
  37521. /**
  37522. * Time in milliseconds for the mesh to fade in (Default: 300)
  37523. */
  37524. fadeInTime: number;
  37525. private _millisecondsPerFrame;
  37526. private _hovered;
  37527. private _hoverValue;
  37528. private _ownerNode;
  37529. /**
  37530. * Instatiates the FadeInOutBehavior
  37531. */
  37532. constructor();
  37533. /**
  37534. * The name of the behavior
  37535. */
  37536. readonly name: string;
  37537. /**
  37538. * Initializes the behavior
  37539. */
  37540. init(): void;
  37541. /**
  37542. * Attaches the fade behavior on the passed in mesh
  37543. * @param ownerNode The mesh that will be faded in/out once attached
  37544. */
  37545. attach(ownerNode: Mesh): void;
  37546. /**
  37547. * Detaches the behavior from the mesh
  37548. */
  37549. detach(): void;
  37550. /**
  37551. * Triggers the mesh to begin fading in or out
  37552. * @param value if the object should fade in or out (true to fade in)
  37553. */
  37554. fadeIn(value: boolean): void;
  37555. private _update;
  37556. private _setAllVisibility;
  37557. }
  37558. }
  37559. declare module "babylonjs/Misc/pivotTools" {
  37560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37561. /**
  37562. * Class containing a set of static utilities functions for managing Pivots
  37563. * @hidden
  37564. */
  37565. export class PivotTools {
  37566. private static _PivotCached;
  37567. private static _OldPivotPoint;
  37568. private static _PivotTranslation;
  37569. private static _PivotTmpVector;
  37570. /** @hidden */
  37571. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37572. /** @hidden */
  37573. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37574. }
  37575. }
  37576. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37577. import { Scene } from "babylonjs/scene";
  37578. import { Vector4 } from "babylonjs/Maths/math.vector";
  37579. import { Mesh } from "babylonjs/Meshes/mesh";
  37580. import { Nullable } from "babylonjs/types";
  37581. import { Plane } from "babylonjs/Maths/math.plane";
  37582. /**
  37583. * Class containing static functions to help procedurally build meshes
  37584. */
  37585. export class PlaneBuilder {
  37586. /**
  37587. * Creates a plane mesh
  37588. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37589. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37590. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37594. * @param name defines the name of the mesh
  37595. * @param options defines the options used to create the mesh
  37596. * @param scene defines the hosting scene
  37597. * @returns the plane mesh
  37598. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37599. */
  37600. static CreatePlane(name: string, options: {
  37601. size?: number;
  37602. width?: number;
  37603. height?: number;
  37604. sideOrientation?: number;
  37605. frontUVs?: Vector4;
  37606. backUVs?: Vector4;
  37607. updatable?: boolean;
  37608. sourcePlane?: Plane;
  37609. }, scene?: Nullable<Scene>): Mesh;
  37610. }
  37611. }
  37612. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37613. import { Behavior } from "babylonjs/Behaviors/behavior";
  37614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37615. import { Observable } from "babylonjs/Misc/observable";
  37616. import { Vector3 } from "babylonjs/Maths/math.vector";
  37617. import { Ray } from "babylonjs/Culling/ray";
  37618. import "babylonjs/Meshes/Builders/planeBuilder";
  37619. /**
  37620. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37621. */
  37622. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37623. private static _AnyMouseID;
  37624. /**
  37625. * Abstract mesh the behavior is set on
  37626. */
  37627. attachedNode: AbstractMesh;
  37628. private _dragPlane;
  37629. private _scene;
  37630. private _pointerObserver;
  37631. private _beforeRenderObserver;
  37632. private static _planeScene;
  37633. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37634. /**
  37635. * 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)
  37636. */
  37637. maxDragAngle: number;
  37638. /**
  37639. * @hidden
  37640. */
  37641. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37642. /**
  37643. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37644. */
  37645. currentDraggingPointerID: number;
  37646. /**
  37647. * The last position where the pointer hit the drag plane in world space
  37648. */
  37649. lastDragPosition: Vector3;
  37650. /**
  37651. * If the behavior is currently in a dragging state
  37652. */
  37653. dragging: boolean;
  37654. /**
  37655. * 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)
  37656. */
  37657. dragDeltaRatio: number;
  37658. /**
  37659. * If the drag plane orientation should be updated during the dragging (Default: true)
  37660. */
  37661. updateDragPlane: boolean;
  37662. private _debugMode;
  37663. private _moving;
  37664. /**
  37665. * Fires each time the attached mesh is dragged with the pointer
  37666. * * delta between last drag position and current drag position in world space
  37667. * * dragDistance along the drag axis
  37668. * * dragPlaneNormal normal of the current drag plane used during the drag
  37669. * * dragPlanePoint in world space where the drag intersects the drag plane
  37670. */
  37671. onDragObservable: Observable<{
  37672. delta: Vector3;
  37673. dragPlanePoint: Vector3;
  37674. dragPlaneNormal: Vector3;
  37675. dragDistance: number;
  37676. pointerId: number;
  37677. }>;
  37678. /**
  37679. * Fires each time a drag begins (eg. mouse down on mesh)
  37680. */
  37681. onDragStartObservable: Observable<{
  37682. dragPlanePoint: Vector3;
  37683. pointerId: number;
  37684. }>;
  37685. /**
  37686. * Fires each time a drag ends (eg. mouse release after drag)
  37687. */
  37688. onDragEndObservable: Observable<{
  37689. dragPlanePoint: Vector3;
  37690. pointerId: number;
  37691. }>;
  37692. /**
  37693. * If the attached mesh should be moved when dragged
  37694. */
  37695. moveAttached: boolean;
  37696. /**
  37697. * If the drag behavior will react to drag events (Default: true)
  37698. */
  37699. enabled: boolean;
  37700. /**
  37701. * If pointer events should start and release the drag (Default: true)
  37702. */
  37703. startAndReleaseDragOnPointerEvents: boolean;
  37704. /**
  37705. * If camera controls should be detached during the drag
  37706. */
  37707. detachCameraControls: boolean;
  37708. /**
  37709. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37710. */
  37711. useObjectOrienationForDragging: boolean;
  37712. private _options;
  37713. /**
  37714. * Creates a pointer drag behavior that can be attached to a mesh
  37715. * @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)
  37716. */
  37717. constructor(options?: {
  37718. dragAxis?: Vector3;
  37719. dragPlaneNormal?: Vector3;
  37720. });
  37721. /**
  37722. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37723. */
  37724. validateDrag: (targetPosition: Vector3) => boolean;
  37725. /**
  37726. * The name of the behavior
  37727. */
  37728. readonly name: string;
  37729. /**
  37730. * Initializes the behavior
  37731. */
  37732. init(): void;
  37733. private _tmpVector;
  37734. private _alternatePickedPoint;
  37735. private _worldDragAxis;
  37736. private _targetPosition;
  37737. private _attachedElement;
  37738. /**
  37739. * Attaches the drag behavior the passed in mesh
  37740. * @param ownerNode The mesh that will be dragged around once attached
  37741. */
  37742. attach(ownerNode: AbstractMesh): void;
  37743. /**
  37744. * Force relase the drag action by code.
  37745. */
  37746. releaseDrag(): void;
  37747. private _startDragRay;
  37748. private _lastPointerRay;
  37749. /**
  37750. * Simulates the start of a pointer drag event on the behavior
  37751. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37752. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37753. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37754. */
  37755. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37756. private _startDrag;
  37757. private _dragDelta;
  37758. private _moveDrag;
  37759. private _pickWithRayOnDragPlane;
  37760. private _pointA;
  37761. private _pointB;
  37762. private _pointC;
  37763. private _lineA;
  37764. private _lineB;
  37765. private _localAxis;
  37766. private _lookAt;
  37767. private _updateDragPlanePosition;
  37768. /**
  37769. * Detaches the behavior from the mesh
  37770. */
  37771. detach(): void;
  37772. }
  37773. }
  37774. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37775. import { Mesh } from "babylonjs/Meshes/mesh";
  37776. import { Behavior } from "babylonjs/Behaviors/behavior";
  37777. /**
  37778. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37779. */
  37780. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37781. private _dragBehaviorA;
  37782. private _dragBehaviorB;
  37783. private _startDistance;
  37784. private _initialScale;
  37785. private _targetScale;
  37786. private _ownerNode;
  37787. private _sceneRenderObserver;
  37788. /**
  37789. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37790. */
  37791. constructor();
  37792. /**
  37793. * The name of the behavior
  37794. */
  37795. readonly name: string;
  37796. /**
  37797. * Initializes the behavior
  37798. */
  37799. init(): void;
  37800. private _getCurrentDistance;
  37801. /**
  37802. * Attaches the scale behavior the passed in mesh
  37803. * @param ownerNode The mesh that will be scaled around once attached
  37804. */
  37805. attach(ownerNode: Mesh): void;
  37806. /**
  37807. * Detaches the behavior from the mesh
  37808. */
  37809. detach(): void;
  37810. }
  37811. }
  37812. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37813. import { Behavior } from "babylonjs/Behaviors/behavior";
  37814. import { Mesh } from "babylonjs/Meshes/mesh";
  37815. import { Observable } from "babylonjs/Misc/observable";
  37816. /**
  37817. * 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
  37818. */
  37819. export class SixDofDragBehavior implements Behavior<Mesh> {
  37820. private static _virtualScene;
  37821. private _ownerNode;
  37822. private _sceneRenderObserver;
  37823. private _scene;
  37824. private _targetPosition;
  37825. private _virtualOriginMesh;
  37826. private _virtualDragMesh;
  37827. private _pointerObserver;
  37828. private _moving;
  37829. private _startingOrientation;
  37830. /**
  37831. * 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)
  37832. */
  37833. private zDragFactor;
  37834. /**
  37835. * If the object should rotate to face the drag origin
  37836. */
  37837. rotateDraggedObject: boolean;
  37838. /**
  37839. * If the behavior is currently in a dragging state
  37840. */
  37841. dragging: boolean;
  37842. /**
  37843. * 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)
  37844. */
  37845. dragDeltaRatio: number;
  37846. /**
  37847. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37848. */
  37849. currentDraggingPointerID: number;
  37850. /**
  37851. * If camera controls should be detached during the drag
  37852. */
  37853. detachCameraControls: boolean;
  37854. /**
  37855. * Fires each time a drag starts
  37856. */
  37857. onDragStartObservable: Observable<{}>;
  37858. /**
  37859. * Fires each time a drag ends (eg. mouse release after drag)
  37860. */
  37861. onDragEndObservable: Observable<{}>;
  37862. /**
  37863. * 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
  37864. */
  37865. constructor();
  37866. /**
  37867. * The name of the behavior
  37868. */
  37869. readonly name: string;
  37870. /**
  37871. * Initializes the behavior
  37872. */
  37873. init(): void;
  37874. /**
  37875. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37876. */
  37877. private readonly _pointerCamera;
  37878. /**
  37879. * Attaches the scale behavior the passed in mesh
  37880. * @param ownerNode The mesh that will be scaled around once attached
  37881. */
  37882. attach(ownerNode: Mesh): void;
  37883. /**
  37884. * Detaches the behavior from the mesh
  37885. */
  37886. detach(): void;
  37887. }
  37888. }
  37889. declare module "babylonjs/Behaviors/Meshes/index" {
  37890. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37891. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37892. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37893. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37894. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37895. }
  37896. declare module "babylonjs/Behaviors/index" {
  37897. export * from "babylonjs/Behaviors/behavior";
  37898. export * from "babylonjs/Behaviors/Cameras/index";
  37899. export * from "babylonjs/Behaviors/Meshes/index";
  37900. }
  37901. declare module "babylonjs/Bones/boneIKController" {
  37902. import { Bone } from "babylonjs/Bones/bone";
  37903. import { Vector3 } from "babylonjs/Maths/math.vector";
  37904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37905. import { Nullable } from "babylonjs/types";
  37906. /**
  37907. * Class used to apply inverse kinematics to bones
  37908. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37909. */
  37910. export class BoneIKController {
  37911. private static _tmpVecs;
  37912. private static _tmpQuat;
  37913. private static _tmpMats;
  37914. /**
  37915. * Gets or sets the target mesh
  37916. */
  37917. targetMesh: AbstractMesh;
  37918. /** Gets or sets the mesh used as pole */
  37919. poleTargetMesh: AbstractMesh;
  37920. /**
  37921. * Gets or sets the bone used as pole
  37922. */
  37923. poleTargetBone: Nullable<Bone>;
  37924. /**
  37925. * Gets or sets the target position
  37926. */
  37927. targetPosition: Vector3;
  37928. /**
  37929. * Gets or sets the pole target position
  37930. */
  37931. poleTargetPosition: Vector3;
  37932. /**
  37933. * Gets or sets the pole target local offset
  37934. */
  37935. poleTargetLocalOffset: Vector3;
  37936. /**
  37937. * Gets or sets the pole angle
  37938. */
  37939. poleAngle: number;
  37940. /**
  37941. * Gets or sets the mesh associated with the controller
  37942. */
  37943. mesh: AbstractMesh;
  37944. /**
  37945. * 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)
  37946. */
  37947. slerpAmount: number;
  37948. private _bone1Quat;
  37949. private _bone1Mat;
  37950. private _bone2Ang;
  37951. private _bone1;
  37952. private _bone2;
  37953. private _bone1Length;
  37954. private _bone2Length;
  37955. private _maxAngle;
  37956. private _maxReach;
  37957. private _rightHandedSystem;
  37958. private _bendAxis;
  37959. private _slerping;
  37960. private _adjustRoll;
  37961. /**
  37962. * Gets or sets maximum allowed angle
  37963. */
  37964. maxAngle: number;
  37965. /**
  37966. * Creates a new BoneIKController
  37967. * @param mesh defines the mesh to control
  37968. * @param bone defines the bone to control
  37969. * @param options defines options to set up the controller
  37970. */
  37971. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37972. targetMesh?: AbstractMesh;
  37973. poleTargetMesh?: AbstractMesh;
  37974. poleTargetBone?: Bone;
  37975. poleTargetLocalOffset?: Vector3;
  37976. poleAngle?: number;
  37977. bendAxis?: Vector3;
  37978. maxAngle?: number;
  37979. slerpAmount?: number;
  37980. });
  37981. private _setMaxAngle;
  37982. /**
  37983. * Force the controller to update the bones
  37984. */
  37985. update(): void;
  37986. }
  37987. }
  37988. declare module "babylonjs/Bones/boneLookController" {
  37989. import { Vector3 } from "babylonjs/Maths/math.vector";
  37990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37991. import { Bone } from "babylonjs/Bones/bone";
  37992. import { Space } from "babylonjs/Maths/math.axis";
  37993. /**
  37994. * Class used to make a bone look toward a point in space
  37995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37996. */
  37997. export class BoneLookController {
  37998. private static _tmpVecs;
  37999. private static _tmpQuat;
  38000. private static _tmpMats;
  38001. /**
  38002. * The target Vector3 that the bone will look at
  38003. */
  38004. target: Vector3;
  38005. /**
  38006. * The mesh that the bone is attached to
  38007. */
  38008. mesh: AbstractMesh;
  38009. /**
  38010. * The bone that will be looking to the target
  38011. */
  38012. bone: Bone;
  38013. /**
  38014. * The up axis of the coordinate system that is used when the bone is rotated
  38015. */
  38016. upAxis: Vector3;
  38017. /**
  38018. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38019. */
  38020. upAxisSpace: Space;
  38021. /**
  38022. * Used to make an adjustment to the yaw of the bone
  38023. */
  38024. adjustYaw: number;
  38025. /**
  38026. * Used to make an adjustment to the pitch of the bone
  38027. */
  38028. adjustPitch: number;
  38029. /**
  38030. * Used to make an adjustment to the roll of the bone
  38031. */
  38032. adjustRoll: number;
  38033. /**
  38034. * 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)
  38035. */
  38036. slerpAmount: number;
  38037. private _minYaw;
  38038. private _maxYaw;
  38039. private _minPitch;
  38040. private _maxPitch;
  38041. private _minYawSin;
  38042. private _minYawCos;
  38043. private _maxYawSin;
  38044. private _maxYawCos;
  38045. private _midYawConstraint;
  38046. private _minPitchTan;
  38047. private _maxPitchTan;
  38048. private _boneQuat;
  38049. private _slerping;
  38050. private _transformYawPitch;
  38051. private _transformYawPitchInv;
  38052. private _firstFrameSkipped;
  38053. private _yawRange;
  38054. private _fowardAxis;
  38055. /**
  38056. * Gets or sets the minimum yaw angle that the bone can look to
  38057. */
  38058. minYaw: number;
  38059. /**
  38060. * Gets or sets the maximum yaw angle that the bone can look to
  38061. */
  38062. maxYaw: number;
  38063. /**
  38064. * Gets or sets the minimum pitch angle that the bone can look to
  38065. */
  38066. minPitch: number;
  38067. /**
  38068. * Gets or sets the maximum pitch angle that the bone can look to
  38069. */
  38070. maxPitch: number;
  38071. /**
  38072. * Create a BoneLookController
  38073. * @param mesh the mesh that the bone belongs to
  38074. * @param bone the bone that will be looking to the target
  38075. * @param target the target Vector3 to look at
  38076. * @param options optional settings:
  38077. * * maxYaw: the maximum angle the bone will yaw to
  38078. * * minYaw: the minimum angle the bone will yaw to
  38079. * * maxPitch: the maximum angle the bone will pitch to
  38080. * * minPitch: the minimum angle the bone will yaw to
  38081. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38082. * * upAxis: the up axis of the coordinate system
  38083. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38084. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38085. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38086. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38087. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38088. * * adjustRoll: used to make an adjustment to the roll of the bone
  38089. **/
  38090. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38091. maxYaw?: number;
  38092. minYaw?: number;
  38093. maxPitch?: number;
  38094. minPitch?: number;
  38095. slerpAmount?: number;
  38096. upAxis?: Vector3;
  38097. upAxisSpace?: Space;
  38098. yawAxis?: Vector3;
  38099. pitchAxis?: Vector3;
  38100. adjustYaw?: number;
  38101. adjustPitch?: number;
  38102. adjustRoll?: number;
  38103. });
  38104. /**
  38105. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38106. */
  38107. update(): void;
  38108. private _getAngleDiff;
  38109. private _getAngleBetween;
  38110. private _isAngleBetween;
  38111. }
  38112. }
  38113. declare module "babylonjs/Bones/index" {
  38114. export * from "babylonjs/Bones/bone";
  38115. export * from "babylonjs/Bones/boneIKController";
  38116. export * from "babylonjs/Bones/boneLookController";
  38117. export * from "babylonjs/Bones/skeleton";
  38118. }
  38119. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38120. import { Nullable } from "babylonjs/types";
  38121. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38123. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38124. /**
  38125. * Manage the gamepad inputs to control an arc rotate camera.
  38126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38127. */
  38128. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38129. /**
  38130. * Defines the camera the input is attached to.
  38131. */
  38132. camera: ArcRotateCamera;
  38133. /**
  38134. * Defines the gamepad the input is gathering event from.
  38135. */
  38136. gamepad: Nullable<Gamepad>;
  38137. /**
  38138. * Defines the gamepad rotation sensiblity.
  38139. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38140. */
  38141. gamepadRotationSensibility: number;
  38142. /**
  38143. * Defines the gamepad move sensiblity.
  38144. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38145. */
  38146. gamepadMoveSensibility: number;
  38147. private _onGamepadConnectedObserver;
  38148. private _onGamepadDisconnectedObserver;
  38149. /**
  38150. * Attach the input controls to a specific dom element to get the input from.
  38151. * @param element Defines the element the controls should be listened from
  38152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38153. */
  38154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38155. /**
  38156. * Detach the current controls from the specified dom element.
  38157. * @param element Defines the element to stop listening the inputs from
  38158. */
  38159. detachControl(element: Nullable<HTMLElement>): void;
  38160. /**
  38161. * Update the current camera state depending on the inputs that have been used this frame.
  38162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38163. */
  38164. checkInputs(): void;
  38165. /**
  38166. * Gets the class name of the current intput.
  38167. * @returns the class name
  38168. */
  38169. getClassName(): string;
  38170. /**
  38171. * Get the friendly name associated with the input class.
  38172. * @returns the input friendly name
  38173. */
  38174. getSimpleName(): string;
  38175. }
  38176. }
  38177. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38178. import { Nullable } from "babylonjs/types";
  38179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38181. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38182. interface ArcRotateCameraInputsManager {
  38183. /**
  38184. * Add orientation input support to the input manager.
  38185. * @returns the current input manager
  38186. */
  38187. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38188. }
  38189. }
  38190. /**
  38191. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38193. */
  38194. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38195. /**
  38196. * Defines the camera the input is attached to.
  38197. */
  38198. camera: ArcRotateCamera;
  38199. /**
  38200. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38201. */
  38202. alphaCorrection: number;
  38203. /**
  38204. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38205. */
  38206. gammaCorrection: number;
  38207. private _alpha;
  38208. private _gamma;
  38209. private _dirty;
  38210. private _deviceOrientationHandler;
  38211. /**
  38212. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38213. */
  38214. constructor();
  38215. /**
  38216. * Attach the input controls to a specific dom element to get the input from.
  38217. * @param element Defines the element the controls should be listened from
  38218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38219. */
  38220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38221. /** @hidden */
  38222. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38223. /**
  38224. * Update the current camera state depending on the inputs that have been used this frame.
  38225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38226. */
  38227. checkInputs(): void;
  38228. /**
  38229. * Detach the current controls from the specified dom element.
  38230. * @param element Defines the element to stop listening the inputs from
  38231. */
  38232. detachControl(element: Nullable<HTMLElement>): void;
  38233. /**
  38234. * Gets the class name of the current intput.
  38235. * @returns the class name
  38236. */
  38237. getClassName(): string;
  38238. /**
  38239. * Get the friendly name associated with the input class.
  38240. * @returns the input friendly name
  38241. */
  38242. getSimpleName(): string;
  38243. }
  38244. }
  38245. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38246. import { Nullable } from "babylonjs/types";
  38247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38248. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38249. /**
  38250. * Listen to mouse events to control the camera.
  38251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38252. */
  38253. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38254. /**
  38255. * Defines the camera the input is attached to.
  38256. */
  38257. camera: FlyCamera;
  38258. /**
  38259. * Defines if touch is enabled. (Default is true.)
  38260. */
  38261. touchEnabled: boolean;
  38262. /**
  38263. * Defines the buttons associated with the input to handle camera rotation.
  38264. */
  38265. buttons: number[];
  38266. /**
  38267. * Assign buttons for Yaw control.
  38268. */
  38269. buttonsYaw: number[];
  38270. /**
  38271. * Assign buttons for Pitch control.
  38272. */
  38273. buttonsPitch: number[];
  38274. /**
  38275. * Assign buttons for Roll control.
  38276. */
  38277. buttonsRoll: number[];
  38278. /**
  38279. * Detect if any button is being pressed while mouse is moved.
  38280. * -1 = Mouse locked.
  38281. * 0 = Left button.
  38282. * 1 = Middle Button.
  38283. * 2 = Right Button.
  38284. */
  38285. activeButton: number;
  38286. /**
  38287. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38288. * Higher values reduce its sensitivity.
  38289. */
  38290. angularSensibility: number;
  38291. private _mousemoveCallback;
  38292. private _observer;
  38293. private _rollObserver;
  38294. private previousPosition;
  38295. private noPreventDefault;
  38296. private element;
  38297. /**
  38298. * Listen to mouse events to control the camera.
  38299. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38301. */
  38302. constructor(touchEnabled?: boolean);
  38303. /**
  38304. * Attach the mouse control to the HTML DOM element.
  38305. * @param element Defines the element that listens to the input events.
  38306. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38307. */
  38308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38309. /**
  38310. * Detach the current controls from the specified dom element.
  38311. * @param element Defines the element to stop listening the inputs from
  38312. */
  38313. detachControl(element: Nullable<HTMLElement>): void;
  38314. /**
  38315. * Gets the class name of the current input.
  38316. * @returns the class name.
  38317. */
  38318. getClassName(): string;
  38319. /**
  38320. * Get the friendly name associated with the input class.
  38321. * @returns the input's friendly name.
  38322. */
  38323. getSimpleName(): string;
  38324. private _pointerInput;
  38325. private _onMouseMove;
  38326. /**
  38327. * Rotate camera by mouse offset.
  38328. */
  38329. private rotateCamera;
  38330. }
  38331. }
  38332. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38333. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38334. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38335. /**
  38336. * Default Inputs manager for the FlyCamera.
  38337. * It groups all the default supported inputs for ease of use.
  38338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38339. */
  38340. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38341. /**
  38342. * Instantiates a new FlyCameraInputsManager.
  38343. * @param camera Defines the camera the inputs belong to.
  38344. */
  38345. constructor(camera: FlyCamera);
  38346. /**
  38347. * Add keyboard input support to the input manager.
  38348. * @returns the new FlyCameraKeyboardMoveInput().
  38349. */
  38350. addKeyboard(): FlyCameraInputsManager;
  38351. /**
  38352. * Add mouse input support to the input manager.
  38353. * @param touchEnabled Enable touch screen support.
  38354. * @returns the new FlyCameraMouseInput().
  38355. */
  38356. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38357. }
  38358. }
  38359. declare module "babylonjs/Cameras/flyCamera" {
  38360. import { Scene } from "babylonjs/scene";
  38361. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38364. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38365. /**
  38366. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38367. * such as in a 3D Space Shooter or a Flight Simulator.
  38368. */
  38369. export class FlyCamera extends TargetCamera {
  38370. /**
  38371. * Define the collision ellipsoid of the camera.
  38372. * This is helpful for simulating a camera body, like a player's body.
  38373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38374. */
  38375. ellipsoid: Vector3;
  38376. /**
  38377. * Define an offset for the position of the ellipsoid around the camera.
  38378. * This can be helpful if the camera is attached away from the player's body center,
  38379. * such as at its head.
  38380. */
  38381. ellipsoidOffset: Vector3;
  38382. /**
  38383. * Enable or disable collisions of the camera with the rest of the scene objects.
  38384. */
  38385. checkCollisions: boolean;
  38386. /**
  38387. * Enable or disable gravity on the camera.
  38388. */
  38389. applyGravity: boolean;
  38390. /**
  38391. * Define the current direction the camera is moving to.
  38392. */
  38393. cameraDirection: Vector3;
  38394. /**
  38395. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38396. * This overrides and empties cameraRotation.
  38397. */
  38398. rotationQuaternion: Quaternion;
  38399. /**
  38400. * Track Roll to maintain the wanted Rolling when looking around.
  38401. */
  38402. _trackRoll: number;
  38403. /**
  38404. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38405. */
  38406. rollCorrect: number;
  38407. /**
  38408. * Mimic a banked turn, Rolling the camera when Yawing.
  38409. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38410. */
  38411. bankedTurn: boolean;
  38412. /**
  38413. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38414. */
  38415. bankedTurnLimit: number;
  38416. /**
  38417. * Value of 0 disables the banked Roll.
  38418. * Value of 1 is equal to the Yaw angle in radians.
  38419. */
  38420. bankedTurnMultiplier: number;
  38421. /**
  38422. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38423. */
  38424. inputs: FlyCameraInputsManager;
  38425. /**
  38426. * Gets the input sensibility for mouse input.
  38427. * Higher values reduce sensitivity.
  38428. */
  38429. /**
  38430. * Sets the input sensibility for a mouse input.
  38431. * Higher values reduce sensitivity.
  38432. */
  38433. angularSensibility: number;
  38434. /**
  38435. * Get the keys for camera movement forward.
  38436. */
  38437. /**
  38438. * Set the keys for camera movement forward.
  38439. */
  38440. keysForward: number[];
  38441. /**
  38442. * Get the keys for camera movement backward.
  38443. */
  38444. keysBackward: number[];
  38445. /**
  38446. * Get the keys for camera movement up.
  38447. */
  38448. /**
  38449. * Set the keys for camera movement up.
  38450. */
  38451. keysUp: number[];
  38452. /**
  38453. * Get the keys for camera movement down.
  38454. */
  38455. /**
  38456. * Set the keys for camera movement down.
  38457. */
  38458. keysDown: number[];
  38459. /**
  38460. * Get the keys for camera movement left.
  38461. */
  38462. /**
  38463. * Set the keys for camera movement left.
  38464. */
  38465. keysLeft: number[];
  38466. /**
  38467. * Set the keys for camera movement right.
  38468. */
  38469. /**
  38470. * Set the keys for camera movement right.
  38471. */
  38472. keysRight: number[];
  38473. /**
  38474. * Event raised when the camera collides with a mesh in the scene.
  38475. */
  38476. onCollide: (collidedMesh: AbstractMesh) => void;
  38477. private _collider;
  38478. private _needMoveForGravity;
  38479. private _oldPosition;
  38480. private _diffPosition;
  38481. private _newPosition;
  38482. /** @hidden */
  38483. _localDirection: Vector3;
  38484. /** @hidden */
  38485. _transformedDirection: Vector3;
  38486. /**
  38487. * Instantiates a FlyCamera.
  38488. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38489. * such as in a 3D Space Shooter or a Flight Simulator.
  38490. * @param name Define the name of the camera in the scene.
  38491. * @param position Define the starting position of the camera in the scene.
  38492. * @param scene Define the scene the camera belongs to.
  38493. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38494. */
  38495. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38496. /**
  38497. * Attach a control to the HTML DOM element.
  38498. * @param element Defines the element that listens to the input events.
  38499. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38500. */
  38501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38502. /**
  38503. * Detach a control from the HTML DOM element.
  38504. * The camera will stop reacting to that input.
  38505. * @param element Defines the element that listens to the input events.
  38506. */
  38507. detachControl(element: HTMLElement): void;
  38508. private _collisionMask;
  38509. /**
  38510. * Get the mask that the camera ignores in collision events.
  38511. */
  38512. /**
  38513. * Set the mask that the camera ignores in collision events.
  38514. */
  38515. collisionMask: number;
  38516. /** @hidden */
  38517. _collideWithWorld(displacement: Vector3): void;
  38518. /** @hidden */
  38519. private _onCollisionPositionChange;
  38520. /** @hidden */
  38521. _checkInputs(): void;
  38522. /** @hidden */
  38523. _decideIfNeedsToMove(): boolean;
  38524. /** @hidden */
  38525. _updatePosition(): void;
  38526. /**
  38527. * Restore the Roll to its target value at the rate specified.
  38528. * @param rate - Higher means slower restoring.
  38529. * @hidden
  38530. */
  38531. restoreRoll(rate: number): void;
  38532. /**
  38533. * Destroy the camera and release the current resources held by it.
  38534. */
  38535. dispose(): void;
  38536. /**
  38537. * Get the current object class name.
  38538. * @returns the class name.
  38539. */
  38540. getClassName(): string;
  38541. }
  38542. }
  38543. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38544. import { Nullable } from "babylonjs/types";
  38545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38546. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38547. /**
  38548. * Listen to keyboard events to control the camera.
  38549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38550. */
  38551. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38552. /**
  38553. * Defines the camera the input is attached to.
  38554. */
  38555. camera: FlyCamera;
  38556. /**
  38557. * The list of keyboard keys used to control the forward move of the camera.
  38558. */
  38559. keysForward: number[];
  38560. /**
  38561. * The list of keyboard keys used to control the backward move of the camera.
  38562. */
  38563. keysBackward: number[];
  38564. /**
  38565. * The list of keyboard keys used to control the forward move of the camera.
  38566. */
  38567. keysUp: number[];
  38568. /**
  38569. * The list of keyboard keys used to control the backward move of the camera.
  38570. */
  38571. keysDown: number[];
  38572. /**
  38573. * The list of keyboard keys used to control the right strafe move of the camera.
  38574. */
  38575. keysRight: number[];
  38576. /**
  38577. * The list of keyboard keys used to control the left strafe move of the camera.
  38578. */
  38579. keysLeft: number[];
  38580. private _keys;
  38581. private _onCanvasBlurObserver;
  38582. private _onKeyboardObserver;
  38583. private _engine;
  38584. private _scene;
  38585. /**
  38586. * Attach the input controls to a specific dom element to get the input from.
  38587. * @param element Defines the element the controls should be listened from
  38588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38589. */
  38590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38591. /**
  38592. * Detach the current controls from the specified dom element.
  38593. * @param element Defines the element to stop listening the inputs from
  38594. */
  38595. detachControl(element: Nullable<HTMLElement>): void;
  38596. /**
  38597. * Gets the class name of the current intput.
  38598. * @returns the class name
  38599. */
  38600. getClassName(): string;
  38601. /** @hidden */
  38602. _onLostFocus(e: FocusEvent): void;
  38603. /**
  38604. * Get the friendly name associated with the input class.
  38605. * @returns the input friendly name
  38606. */
  38607. getSimpleName(): string;
  38608. /**
  38609. * Update the current camera state depending on the inputs that have been used this frame.
  38610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38611. */
  38612. checkInputs(): void;
  38613. }
  38614. }
  38615. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38616. import { Nullable } from "babylonjs/types";
  38617. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38618. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38619. /**
  38620. * Manage the mouse wheel inputs to control a follow camera.
  38621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38622. */
  38623. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38624. /**
  38625. * Defines the camera the input is attached to.
  38626. */
  38627. camera: FollowCamera;
  38628. /**
  38629. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38630. */
  38631. axisControlRadius: boolean;
  38632. /**
  38633. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38634. */
  38635. axisControlHeight: boolean;
  38636. /**
  38637. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38638. */
  38639. axisControlRotation: boolean;
  38640. /**
  38641. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38642. * relation to mouseWheel events.
  38643. */
  38644. wheelPrecision: number;
  38645. /**
  38646. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38647. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38648. */
  38649. wheelDeltaPercentage: number;
  38650. private _wheel;
  38651. private _observer;
  38652. /**
  38653. * Attach the input controls to a specific dom element to get the input from.
  38654. * @param element Defines the element the controls should be listened from
  38655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38656. */
  38657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38658. /**
  38659. * Detach the current controls from the specified dom element.
  38660. * @param element Defines the element to stop listening the inputs from
  38661. */
  38662. detachControl(element: Nullable<HTMLElement>): void;
  38663. /**
  38664. * Gets the class name of the current intput.
  38665. * @returns the class name
  38666. */
  38667. getClassName(): string;
  38668. /**
  38669. * Get the friendly name associated with the input class.
  38670. * @returns the input friendly name
  38671. */
  38672. getSimpleName(): string;
  38673. }
  38674. }
  38675. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38676. import { Nullable } from "babylonjs/types";
  38677. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38678. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38679. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38680. /**
  38681. * Manage the pointers inputs to control an follow camera.
  38682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38683. */
  38684. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38685. /**
  38686. * Defines the camera the input is attached to.
  38687. */
  38688. camera: FollowCamera;
  38689. /**
  38690. * Gets the class name of the current input.
  38691. * @returns the class name
  38692. */
  38693. getClassName(): string;
  38694. /**
  38695. * Defines the pointer angular sensibility along the X axis or how fast is
  38696. * the camera rotating.
  38697. * A negative number will reverse the axis direction.
  38698. */
  38699. angularSensibilityX: number;
  38700. /**
  38701. * Defines the pointer angular sensibility along the Y axis or how fast is
  38702. * the camera rotating.
  38703. * A negative number will reverse the axis direction.
  38704. */
  38705. angularSensibilityY: number;
  38706. /**
  38707. * Defines the pointer pinch precision or how fast is the camera zooming.
  38708. * A negative number will reverse the axis direction.
  38709. */
  38710. pinchPrecision: number;
  38711. /**
  38712. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38713. * from 0.
  38714. * It defines the percentage of current camera.radius to use as delta when
  38715. * pinch zoom is used.
  38716. */
  38717. pinchDeltaPercentage: number;
  38718. /**
  38719. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38720. */
  38721. axisXControlRadius: boolean;
  38722. /**
  38723. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38724. */
  38725. axisXControlHeight: boolean;
  38726. /**
  38727. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38728. */
  38729. axisXControlRotation: boolean;
  38730. /**
  38731. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38732. */
  38733. axisYControlRadius: boolean;
  38734. /**
  38735. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38736. */
  38737. axisYControlHeight: boolean;
  38738. /**
  38739. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38740. */
  38741. axisYControlRotation: boolean;
  38742. /**
  38743. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38744. */
  38745. axisPinchControlRadius: boolean;
  38746. /**
  38747. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38748. */
  38749. axisPinchControlHeight: boolean;
  38750. /**
  38751. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38752. */
  38753. axisPinchControlRotation: boolean;
  38754. /**
  38755. * Log error messages if basic misconfiguration has occurred.
  38756. */
  38757. warningEnable: boolean;
  38758. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38760. private _warningCounter;
  38761. private _warning;
  38762. }
  38763. }
  38764. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38765. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38766. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38767. /**
  38768. * Default Inputs manager for the FollowCamera.
  38769. * It groups all the default supported inputs for ease of use.
  38770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38771. */
  38772. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38773. /**
  38774. * Instantiates a new FollowCameraInputsManager.
  38775. * @param camera Defines the camera the inputs belong to
  38776. */
  38777. constructor(camera: FollowCamera);
  38778. /**
  38779. * Add keyboard input support to the input manager.
  38780. * @returns the current input manager
  38781. */
  38782. addKeyboard(): FollowCameraInputsManager;
  38783. /**
  38784. * Add mouse wheel input support to the input manager.
  38785. * @returns the current input manager
  38786. */
  38787. addMouseWheel(): FollowCameraInputsManager;
  38788. /**
  38789. * Add pointers input support to the input manager.
  38790. * @returns the current input manager
  38791. */
  38792. addPointers(): FollowCameraInputsManager;
  38793. /**
  38794. * Add orientation input support to the input manager.
  38795. * @returns the current input manager
  38796. */
  38797. addVRDeviceOrientation(): FollowCameraInputsManager;
  38798. }
  38799. }
  38800. declare module "babylonjs/Cameras/followCamera" {
  38801. import { Nullable } from "babylonjs/types";
  38802. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38803. import { Scene } from "babylonjs/scene";
  38804. import { Vector3 } from "babylonjs/Maths/math.vector";
  38805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38806. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38807. /**
  38808. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38809. * an arc rotate version arcFollowCamera are available.
  38810. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38811. */
  38812. export class FollowCamera extends TargetCamera {
  38813. /**
  38814. * Distance the follow camera should follow an object at
  38815. */
  38816. radius: number;
  38817. /**
  38818. * Minimum allowed distance of the camera to the axis of rotation
  38819. * (The camera can not get closer).
  38820. * This can help limiting how the Camera is able to move in the scene.
  38821. */
  38822. lowerRadiusLimit: Nullable<number>;
  38823. /**
  38824. * Maximum allowed distance of the camera to the axis of rotation
  38825. * (The camera can not get further).
  38826. * This can help limiting how the Camera is able to move in the scene.
  38827. */
  38828. upperRadiusLimit: Nullable<number>;
  38829. /**
  38830. * Define a rotation offset between the camera and the object it follows
  38831. */
  38832. rotationOffset: number;
  38833. /**
  38834. * Minimum allowed angle to camera position relative to target object.
  38835. * This can help limiting how the Camera is able to move in the scene.
  38836. */
  38837. lowerRotationOffsetLimit: Nullable<number>;
  38838. /**
  38839. * Maximum allowed angle to camera position relative to target object.
  38840. * This can help limiting how the Camera is able to move in the scene.
  38841. */
  38842. upperRotationOffsetLimit: Nullable<number>;
  38843. /**
  38844. * Define a height offset between the camera and the object it follows.
  38845. * It can help following an object from the top (like a car chaing a plane)
  38846. */
  38847. heightOffset: number;
  38848. /**
  38849. * Minimum allowed height of camera position relative to target object.
  38850. * This can help limiting how the Camera is able to move in the scene.
  38851. */
  38852. lowerHeightOffsetLimit: Nullable<number>;
  38853. /**
  38854. * Maximum allowed height of camera position relative to target object.
  38855. * This can help limiting how the Camera is able to move in the scene.
  38856. */
  38857. upperHeightOffsetLimit: Nullable<number>;
  38858. /**
  38859. * Define how fast the camera can accelerate to follow it s target.
  38860. */
  38861. cameraAcceleration: number;
  38862. /**
  38863. * Define the speed limit of the camera following an object.
  38864. */
  38865. maxCameraSpeed: number;
  38866. /**
  38867. * Define the target of the camera.
  38868. */
  38869. lockedTarget: Nullable<AbstractMesh>;
  38870. /**
  38871. * Defines the input associated with the camera.
  38872. */
  38873. inputs: FollowCameraInputsManager;
  38874. /**
  38875. * Instantiates the follow camera.
  38876. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38877. * @param name Define the name of the camera in the scene
  38878. * @param position Define the position of the camera
  38879. * @param scene Define the scene the camera belong to
  38880. * @param lockedTarget Define the target of the camera
  38881. */
  38882. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38883. private _follow;
  38884. /**
  38885. * Attached controls to the current camera.
  38886. * @param element Defines the element the controls should be listened from
  38887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38888. */
  38889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38890. /**
  38891. * Detach the current controls from the camera.
  38892. * The camera will stop reacting to inputs.
  38893. * @param element Defines the element to stop listening the inputs from
  38894. */
  38895. detachControl(element: HTMLElement): void;
  38896. /** @hidden */
  38897. _checkInputs(): void;
  38898. private _checkLimits;
  38899. /**
  38900. * Gets the camera class name.
  38901. * @returns the class name
  38902. */
  38903. getClassName(): string;
  38904. }
  38905. /**
  38906. * Arc Rotate version of the follow camera.
  38907. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38908. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38909. */
  38910. export class ArcFollowCamera extends TargetCamera {
  38911. /** The longitudinal angle of the camera */
  38912. alpha: number;
  38913. /** The latitudinal angle of the camera */
  38914. beta: number;
  38915. /** The radius of the camera from its target */
  38916. radius: number;
  38917. /** Define the camera target (the messh it should follow) */
  38918. target: Nullable<AbstractMesh>;
  38919. private _cartesianCoordinates;
  38920. /**
  38921. * Instantiates a new ArcFollowCamera
  38922. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38923. * @param name Define the name of the camera
  38924. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38925. * @param beta Define the rotation angle of the camera around the elevation axis
  38926. * @param radius Define the radius of the camera from its target point
  38927. * @param target Define the target of the camera
  38928. * @param scene Define the scene the camera belongs to
  38929. */
  38930. constructor(name: string,
  38931. /** The longitudinal angle of the camera */
  38932. alpha: number,
  38933. /** The latitudinal angle of the camera */
  38934. beta: number,
  38935. /** The radius of the camera from its target */
  38936. radius: number,
  38937. /** Define the camera target (the messh it should follow) */
  38938. target: Nullable<AbstractMesh>, scene: Scene);
  38939. private _follow;
  38940. /** @hidden */
  38941. _checkInputs(): void;
  38942. /**
  38943. * Returns the class name of the object.
  38944. * It is mostly used internally for serialization purposes.
  38945. */
  38946. getClassName(): string;
  38947. }
  38948. }
  38949. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38950. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38951. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38952. import { Nullable } from "babylonjs/types";
  38953. /**
  38954. * Manage the keyboard inputs to control the movement of a follow camera.
  38955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38956. */
  38957. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38958. /**
  38959. * Defines the camera the input is attached to.
  38960. */
  38961. camera: FollowCamera;
  38962. /**
  38963. * Defines the list of key codes associated with the up action (increase heightOffset)
  38964. */
  38965. keysHeightOffsetIncr: number[];
  38966. /**
  38967. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38968. */
  38969. keysHeightOffsetDecr: number[];
  38970. /**
  38971. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38972. */
  38973. keysHeightOffsetModifierAlt: boolean;
  38974. /**
  38975. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38976. */
  38977. keysHeightOffsetModifierCtrl: boolean;
  38978. /**
  38979. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38980. */
  38981. keysHeightOffsetModifierShift: boolean;
  38982. /**
  38983. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38984. */
  38985. keysRotationOffsetIncr: number[];
  38986. /**
  38987. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38988. */
  38989. keysRotationOffsetDecr: number[];
  38990. /**
  38991. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38992. */
  38993. keysRotationOffsetModifierAlt: boolean;
  38994. /**
  38995. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38996. */
  38997. keysRotationOffsetModifierCtrl: boolean;
  38998. /**
  38999. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39000. */
  39001. keysRotationOffsetModifierShift: boolean;
  39002. /**
  39003. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39004. */
  39005. keysRadiusIncr: number[];
  39006. /**
  39007. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39008. */
  39009. keysRadiusDecr: number[];
  39010. /**
  39011. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39012. */
  39013. keysRadiusModifierAlt: boolean;
  39014. /**
  39015. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39016. */
  39017. keysRadiusModifierCtrl: boolean;
  39018. /**
  39019. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39020. */
  39021. keysRadiusModifierShift: boolean;
  39022. /**
  39023. * Defines the rate of change of heightOffset.
  39024. */
  39025. heightSensibility: number;
  39026. /**
  39027. * Defines the rate of change of rotationOffset.
  39028. */
  39029. rotationSensibility: number;
  39030. /**
  39031. * Defines the rate of change of radius.
  39032. */
  39033. radiusSensibility: number;
  39034. private _keys;
  39035. private _ctrlPressed;
  39036. private _altPressed;
  39037. private _shiftPressed;
  39038. private _onCanvasBlurObserver;
  39039. private _onKeyboardObserver;
  39040. private _engine;
  39041. private _scene;
  39042. /**
  39043. * Attach the input controls to a specific dom element to get the input from.
  39044. * @param element Defines the element the controls should be listened from
  39045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39046. */
  39047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39048. /**
  39049. * Detach the current controls from the specified dom element.
  39050. * @param element Defines the element to stop listening the inputs from
  39051. */
  39052. detachControl(element: Nullable<HTMLElement>): void;
  39053. /**
  39054. * Update the current camera state depending on the inputs that have been used this frame.
  39055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39056. */
  39057. checkInputs(): void;
  39058. /**
  39059. * Gets the class name of the current input.
  39060. * @returns the class name
  39061. */
  39062. getClassName(): string;
  39063. /**
  39064. * Get the friendly name associated with the input class.
  39065. * @returns the input friendly name
  39066. */
  39067. getSimpleName(): string;
  39068. /**
  39069. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39070. * allow modification of the heightOffset value.
  39071. */
  39072. private _modifierHeightOffset;
  39073. /**
  39074. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39075. * allow modification of the rotationOffset value.
  39076. */
  39077. private _modifierRotationOffset;
  39078. /**
  39079. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39080. * allow modification of the radius value.
  39081. */
  39082. private _modifierRadius;
  39083. }
  39084. }
  39085. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39086. import { Nullable } from "babylonjs/types";
  39087. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39088. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39089. import { Observable } from "babylonjs/Misc/observable";
  39090. module "babylonjs/Cameras/freeCameraInputsManager" {
  39091. interface FreeCameraInputsManager {
  39092. /**
  39093. * @hidden
  39094. */
  39095. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39096. /**
  39097. * Add orientation input support to the input manager.
  39098. * @returns the current input manager
  39099. */
  39100. addDeviceOrientation(): FreeCameraInputsManager;
  39101. }
  39102. }
  39103. /**
  39104. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39105. * Screen rotation is taken into account.
  39106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39107. */
  39108. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39109. private _camera;
  39110. private _screenOrientationAngle;
  39111. private _constantTranform;
  39112. private _screenQuaternion;
  39113. private _alpha;
  39114. private _beta;
  39115. private _gamma;
  39116. /**
  39117. * Can be used to detect if a device orientation sensor is availible on a device
  39118. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39119. * @returns a promise that will resolve on orientation change
  39120. */
  39121. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39122. /**
  39123. * @hidden
  39124. */
  39125. _onDeviceOrientationChangedObservable: Observable<void>;
  39126. /**
  39127. * Instantiates a new input
  39128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39129. */
  39130. constructor();
  39131. /**
  39132. * Define the camera controlled by the input.
  39133. */
  39134. camera: FreeCamera;
  39135. /**
  39136. * Attach the input controls to a specific dom element to get the input from.
  39137. * @param element Defines the element the controls should be listened from
  39138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39139. */
  39140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39141. private _orientationChanged;
  39142. private _deviceOrientation;
  39143. /**
  39144. * Detach the current controls from the specified dom element.
  39145. * @param element Defines the element to stop listening the inputs from
  39146. */
  39147. detachControl(element: Nullable<HTMLElement>): void;
  39148. /**
  39149. * Update the current camera state depending on the inputs that have been used this frame.
  39150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39151. */
  39152. checkInputs(): void;
  39153. /**
  39154. * Gets the class name of the current intput.
  39155. * @returns the class name
  39156. */
  39157. getClassName(): string;
  39158. /**
  39159. * Get the friendly name associated with the input class.
  39160. * @returns the input friendly name
  39161. */
  39162. getSimpleName(): string;
  39163. }
  39164. }
  39165. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39166. import { Nullable } from "babylonjs/types";
  39167. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39169. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39170. /**
  39171. * Manage the gamepad inputs to control a free camera.
  39172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39173. */
  39174. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39175. /**
  39176. * Define the camera the input is attached to.
  39177. */
  39178. camera: FreeCamera;
  39179. /**
  39180. * Define the Gamepad controlling the input
  39181. */
  39182. gamepad: Nullable<Gamepad>;
  39183. /**
  39184. * Defines the gamepad rotation sensiblity.
  39185. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39186. */
  39187. gamepadAngularSensibility: number;
  39188. /**
  39189. * Defines the gamepad move sensiblity.
  39190. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39191. */
  39192. gamepadMoveSensibility: number;
  39193. private _onGamepadConnectedObserver;
  39194. private _onGamepadDisconnectedObserver;
  39195. private _cameraTransform;
  39196. private _deltaTransform;
  39197. private _vector3;
  39198. private _vector2;
  39199. /**
  39200. * Attach the input controls to a specific dom element to get the input from.
  39201. * @param element Defines the element the controls should be listened from
  39202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39203. */
  39204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39205. /**
  39206. * Detach the current controls from the specified dom element.
  39207. * @param element Defines the element to stop listening the inputs from
  39208. */
  39209. detachControl(element: Nullable<HTMLElement>): void;
  39210. /**
  39211. * Update the current camera state depending on the inputs that have been used this frame.
  39212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39213. */
  39214. checkInputs(): void;
  39215. /**
  39216. * Gets the class name of the current intput.
  39217. * @returns the class name
  39218. */
  39219. getClassName(): string;
  39220. /**
  39221. * Get the friendly name associated with the input class.
  39222. * @returns the input friendly name
  39223. */
  39224. getSimpleName(): string;
  39225. }
  39226. }
  39227. declare module "babylonjs/Misc/virtualJoystick" {
  39228. import { Nullable } from "babylonjs/types";
  39229. import { Vector3 } from "babylonjs/Maths/math.vector";
  39230. /**
  39231. * Defines the potential axis of a Joystick
  39232. */
  39233. export enum JoystickAxis {
  39234. /** X axis */
  39235. X = 0,
  39236. /** Y axis */
  39237. Y = 1,
  39238. /** Z axis */
  39239. Z = 2
  39240. }
  39241. /**
  39242. * Class used to define virtual joystick (used in touch mode)
  39243. */
  39244. export class VirtualJoystick {
  39245. /**
  39246. * Gets or sets a boolean indicating that left and right values must be inverted
  39247. */
  39248. reverseLeftRight: boolean;
  39249. /**
  39250. * Gets or sets a boolean indicating that up and down values must be inverted
  39251. */
  39252. reverseUpDown: boolean;
  39253. /**
  39254. * Gets the offset value for the position (ie. the change of the position value)
  39255. */
  39256. deltaPosition: Vector3;
  39257. /**
  39258. * Gets a boolean indicating if the virtual joystick was pressed
  39259. */
  39260. pressed: boolean;
  39261. /**
  39262. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39263. */
  39264. static Canvas: Nullable<HTMLCanvasElement>;
  39265. private static _globalJoystickIndex;
  39266. private static vjCanvasContext;
  39267. private static vjCanvasWidth;
  39268. private static vjCanvasHeight;
  39269. private static halfWidth;
  39270. private _action;
  39271. private _axisTargetedByLeftAndRight;
  39272. private _axisTargetedByUpAndDown;
  39273. private _joystickSensibility;
  39274. private _inversedSensibility;
  39275. private _joystickPointerID;
  39276. private _joystickColor;
  39277. private _joystickPointerPos;
  39278. private _joystickPreviousPointerPos;
  39279. private _joystickPointerStartPos;
  39280. private _deltaJoystickVector;
  39281. private _leftJoystick;
  39282. private _touches;
  39283. private _onPointerDownHandlerRef;
  39284. private _onPointerMoveHandlerRef;
  39285. private _onPointerUpHandlerRef;
  39286. private _onResize;
  39287. /**
  39288. * Creates a new virtual joystick
  39289. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39290. */
  39291. constructor(leftJoystick?: boolean);
  39292. /**
  39293. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39294. * @param newJoystickSensibility defines the new sensibility
  39295. */
  39296. setJoystickSensibility(newJoystickSensibility: number): void;
  39297. private _onPointerDown;
  39298. private _onPointerMove;
  39299. private _onPointerUp;
  39300. /**
  39301. * Change the color of the virtual joystick
  39302. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39303. */
  39304. setJoystickColor(newColor: string): void;
  39305. /**
  39306. * Defines a callback to call when the joystick is touched
  39307. * @param action defines the callback
  39308. */
  39309. setActionOnTouch(action: () => any): void;
  39310. /**
  39311. * Defines which axis you'd like to control for left & right
  39312. * @param axis defines the axis to use
  39313. */
  39314. setAxisForLeftRight(axis: JoystickAxis): void;
  39315. /**
  39316. * Defines which axis you'd like to control for up & down
  39317. * @param axis defines the axis to use
  39318. */
  39319. setAxisForUpDown(axis: JoystickAxis): void;
  39320. private _drawVirtualJoystick;
  39321. /**
  39322. * Release internal HTML canvas
  39323. */
  39324. releaseCanvas(): void;
  39325. }
  39326. }
  39327. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39328. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39329. import { Nullable } from "babylonjs/types";
  39330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39332. module "babylonjs/Cameras/freeCameraInputsManager" {
  39333. interface FreeCameraInputsManager {
  39334. /**
  39335. * Add virtual joystick input support to the input manager.
  39336. * @returns the current input manager
  39337. */
  39338. addVirtualJoystick(): FreeCameraInputsManager;
  39339. }
  39340. }
  39341. /**
  39342. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39344. */
  39345. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39346. /**
  39347. * Defines the camera the input is attached to.
  39348. */
  39349. camera: FreeCamera;
  39350. private _leftjoystick;
  39351. private _rightjoystick;
  39352. /**
  39353. * Gets the left stick of the virtual joystick.
  39354. * @returns The virtual Joystick
  39355. */
  39356. getLeftJoystick(): VirtualJoystick;
  39357. /**
  39358. * Gets the right stick of the virtual joystick.
  39359. * @returns The virtual Joystick
  39360. */
  39361. getRightJoystick(): VirtualJoystick;
  39362. /**
  39363. * Update the current camera state depending on the inputs that have been used this frame.
  39364. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39365. */
  39366. checkInputs(): void;
  39367. /**
  39368. * Attach the input controls to a specific dom element to get the input from.
  39369. * @param element Defines the element the controls should be listened from
  39370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39371. */
  39372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39373. /**
  39374. * Detach the current controls from the specified dom element.
  39375. * @param element Defines the element to stop listening the inputs from
  39376. */
  39377. detachControl(element: Nullable<HTMLElement>): void;
  39378. /**
  39379. * Gets the class name of the current intput.
  39380. * @returns the class name
  39381. */
  39382. getClassName(): string;
  39383. /**
  39384. * Get the friendly name associated with the input class.
  39385. * @returns the input friendly name
  39386. */
  39387. getSimpleName(): string;
  39388. }
  39389. }
  39390. declare module "babylonjs/Cameras/Inputs/index" {
  39391. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39392. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39393. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39394. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39395. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39396. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39397. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39398. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39399. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39400. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39401. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39402. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39403. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39404. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39405. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39406. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39407. }
  39408. declare module "babylonjs/Cameras/touchCamera" {
  39409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39410. import { Scene } from "babylonjs/scene";
  39411. import { Vector3 } from "babylonjs/Maths/math.vector";
  39412. /**
  39413. * This represents a FPS type of camera controlled by touch.
  39414. * This is like a universal camera minus the Gamepad controls.
  39415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39416. */
  39417. export class TouchCamera extends FreeCamera {
  39418. /**
  39419. * Defines the touch sensibility for rotation.
  39420. * The higher the faster.
  39421. */
  39422. touchAngularSensibility: number;
  39423. /**
  39424. * Defines the touch sensibility for move.
  39425. * The higher the faster.
  39426. */
  39427. touchMoveSensibility: number;
  39428. /**
  39429. * Instantiates a new touch camera.
  39430. * This represents a FPS type of camera controlled by touch.
  39431. * This is like a universal camera minus the Gamepad controls.
  39432. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39433. * @param name Define the name of the camera in the scene
  39434. * @param position Define the start position of the camera in the scene
  39435. * @param scene Define the scene the camera belongs to
  39436. */
  39437. constructor(name: string, position: Vector3, scene: Scene);
  39438. /**
  39439. * Gets the current object class name.
  39440. * @return the class name
  39441. */
  39442. getClassName(): string;
  39443. /** @hidden */
  39444. _setupInputs(): void;
  39445. }
  39446. }
  39447. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39449. import { Scene } from "babylonjs/scene";
  39450. import { Vector3 } from "babylonjs/Maths/math.vector";
  39451. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39452. import { Axis } from "babylonjs/Maths/math.axis";
  39453. /**
  39454. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39455. * being tilted forward or back and left or right.
  39456. */
  39457. export class DeviceOrientationCamera extends FreeCamera {
  39458. private _initialQuaternion;
  39459. private _quaternionCache;
  39460. private _tmpDragQuaternion;
  39461. private _disablePointerInputWhenUsingDeviceOrientation;
  39462. /**
  39463. * Creates a new device orientation camera
  39464. * @param name The name of the camera
  39465. * @param position The start position camera
  39466. * @param scene The scene the camera belongs to
  39467. */
  39468. constructor(name: string, position: Vector3, scene: Scene);
  39469. /**
  39470. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39471. */
  39472. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39473. private _dragFactor;
  39474. /**
  39475. * Enabled turning on the y axis when the orientation sensor is active
  39476. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39477. */
  39478. enableHorizontalDragging(dragFactor?: number): void;
  39479. /**
  39480. * Gets the current instance class name ("DeviceOrientationCamera").
  39481. * This helps avoiding instanceof at run time.
  39482. * @returns the class name
  39483. */
  39484. getClassName(): string;
  39485. /**
  39486. * @hidden
  39487. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39488. */
  39489. _checkInputs(): void;
  39490. /**
  39491. * Reset the camera to its default orientation on the specified axis only.
  39492. * @param axis The axis to reset
  39493. */
  39494. resetToCurrentRotation(axis?: Axis): void;
  39495. }
  39496. }
  39497. declare module "babylonjs/Gamepads/xboxGamepad" {
  39498. import { Observable } from "babylonjs/Misc/observable";
  39499. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39500. /**
  39501. * Defines supported buttons for XBox360 compatible gamepads
  39502. */
  39503. export enum Xbox360Button {
  39504. /** A */
  39505. A = 0,
  39506. /** B */
  39507. B = 1,
  39508. /** X */
  39509. X = 2,
  39510. /** Y */
  39511. Y = 3,
  39512. /** Start */
  39513. Start = 4,
  39514. /** Back */
  39515. Back = 5,
  39516. /** Left button */
  39517. LB = 6,
  39518. /** Right button */
  39519. RB = 7,
  39520. /** Left stick */
  39521. LeftStick = 8,
  39522. /** Right stick */
  39523. RightStick = 9
  39524. }
  39525. /** Defines values for XBox360 DPad */
  39526. export enum Xbox360Dpad {
  39527. /** Up */
  39528. Up = 0,
  39529. /** Down */
  39530. Down = 1,
  39531. /** Left */
  39532. Left = 2,
  39533. /** Right */
  39534. Right = 3
  39535. }
  39536. /**
  39537. * Defines a XBox360 gamepad
  39538. */
  39539. export class Xbox360Pad extends Gamepad {
  39540. private _leftTrigger;
  39541. private _rightTrigger;
  39542. private _onlefttriggerchanged;
  39543. private _onrighttriggerchanged;
  39544. private _onbuttondown;
  39545. private _onbuttonup;
  39546. private _ondpaddown;
  39547. private _ondpadup;
  39548. /** Observable raised when a button is pressed */
  39549. onButtonDownObservable: Observable<Xbox360Button>;
  39550. /** Observable raised when a button is released */
  39551. onButtonUpObservable: Observable<Xbox360Button>;
  39552. /** Observable raised when a pad is pressed */
  39553. onPadDownObservable: Observable<Xbox360Dpad>;
  39554. /** Observable raised when a pad is released */
  39555. onPadUpObservable: Observable<Xbox360Dpad>;
  39556. private _buttonA;
  39557. private _buttonB;
  39558. private _buttonX;
  39559. private _buttonY;
  39560. private _buttonBack;
  39561. private _buttonStart;
  39562. private _buttonLB;
  39563. private _buttonRB;
  39564. private _buttonLeftStick;
  39565. private _buttonRightStick;
  39566. private _dPadUp;
  39567. private _dPadDown;
  39568. private _dPadLeft;
  39569. private _dPadRight;
  39570. private _isXboxOnePad;
  39571. /**
  39572. * Creates a new XBox360 gamepad object
  39573. * @param id defines the id of this gamepad
  39574. * @param index defines its index
  39575. * @param gamepad defines the internal HTML gamepad object
  39576. * @param xboxOne defines if it is a XBox One gamepad
  39577. */
  39578. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39579. /**
  39580. * Defines the callback to call when left trigger is pressed
  39581. * @param callback defines the callback to use
  39582. */
  39583. onlefttriggerchanged(callback: (value: number) => void): void;
  39584. /**
  39585. * Defines the callback to call when right trigger is pressed
  39586. * @param callback defines the callback to use
  39587. */
  39588. onrighttriggerchanged(callback: (value: number) => void): void;
  39589. /**
  39590. * Gets the left trigger value
  39591. */
  39592. /**
  39593. * Sets the left trigger value
  39594. */
  39595. leftTrigger: number;
  39596. /**
  39597. * Gets the right trigger value
  39598. */
  39599. /**
  39600. * Sets the right trigger value
  39601. */
  39602. rightTrigger: number;
  39603. /**
  39604. * Defines the callback to call when a button is pressed
  39605. * @param callback defines the callback to use
  39606. */
  39607. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39608. /**
  39609. * Defines the callback to call when a button is released
  39610. * @param callback defines the callback to use
  39611. */
  39612. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39613. /**
  39614. * Defines the callback to call when a pad is pressed
  39615. * @param callback defines the callback to use
  39616. */
  39617. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39618. /**
  39619. * Defines the callback to call when a pad is released
  39620. * @param callback defines the callback to use
  39621. */
  39622. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39623. private _setButtonValue;
  39624. private _setDPadValue;
  39625. /**
  39626. * Gets the value of the `A` button
  39627. */
  39628. /**
  39629. * Sets the value of the `A` button
  39630. */
  39631. buttonA: number;
  39632. /**
  39633. * Gets the value of the `B` button
  39634. */
  39635. /**
  39636. * Sets the value of the `B` button
  39637. */
  39638. buttonB: number;
  39639. /**
  39640. * Gets the value of the `X` button
  39641. */
  39642. /**
  39643. * Sets the value of the `X` button
  39644. */
  39645. buttonX: number;
  39646. /**
  39647. * Gets the value of the `Y` button
  39648. */
  39649. /**
  39650. * Sets the value of the `Y` button
  39651. */
  39652. buttonY: number;
  39653. /**
  39654. * Gets the value of the `Start` button
  39655. */
  39656. /**
  39657. * Sets the value of the `Start` button
  39658. */
  39659. buttonStart: number;
  39660. /**
  39661. * Gets the value of the `Back` button
  39662. */
  39663. /**
  39664. * Sets the value of the `Back` button
  39665. */
  39666. buttonBack: number;
  39667. /**
  39668. * Gets the value of the `Left` button
  39669. */
  39670. /**
  39671. * Sets the value of the `Left` button
  39672. */
  39673. buttonLB: number;
  39674. /**
  39675. * Gets the value of the `Right` button
  39676. */
  39677. /**
  39678. * Sets the value of the `Right` button
  39679. */
  39680. buttonRB: number;
  39681. /**
  39682. * Gets the value of the Left joystick
  39683. */
  39684. /**
  39685. * Sets the value of the Left joystick
  39686. */
  39687. buttonLeftStick: number;
  39688. /**
  39689. * Gets the value of the Right joystick
  39690. */
  39691. /**
  39692. * Sets the value of the Right joystick
  39693. */
  39694. buttonRightStick: number;
  39695. /**
  39696. * Gets the value of D-pad up
  39697. */
  39698. /**
  39699. * Sets the value of D-pad up
  39700. */
  39701. dPadUp: number;
  39702. /**
  39703. * Gets the value of D-pad down
  39704. */
  39705. /**
  39706. * Sets the value of D-pad down
  39707. */
  39708. dPadDown: number;
  39709. /**
  39710. * Gets the value of D-pad left
  39711. */
  39712. /**
  39713. * Sets the value of D-pad left
  39714. */
  39715. dPadLeft: number;
  39716. /**
  39717. * Gets the value of D-pad right
  39718. */
  39719. /**
  39720. * Sets the value of D-pad right
  39721. */
  39722. dPadRight: number;
  39723. /**
  39724. * Force the gamepad to synchronize with device values
  39725. */
  39726. update(): void;
  39727. /**
  39728. * Disposes the gamepad
  39729. */
  39730. dispose(): void;
  39731. }
  39732. }
  39733. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39734. import { Observable } from "babylonjs/Misc/observable";
  39735. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39736. /**
  39737. * Defines supported buttons for DualShock compatible gamepads
  39738. */
  39739. export enum DualShockButton {
  39740. /** Cross */
  39741. Cross = 0,
  39742. /** Circle */
  39743. Circle = 1,
  39744. /** Square */
  39745. Square = 2,
  39746. /** Triangle */
  39747. Triangle = 3,
  39748. /** Options */
  39749. Options = 4,
  39750. /** Share */
  39751. Share = 5,
  39752. /** L1 */
  39753. L1 = 6,
  39754. /** R1 */
  39755. R1 = 7,
  39756. /** Left stick */
  39757. LeftStick = 8,
  39758. /** Right stick */
  39759. RightStick = 9
  39760. }
  39761. /** Defines values for DualShock DPad */
  39762. export enum DualShockDpad {
  39763. /** Up */
  39764. Up = 0,
  39765. /** Down */
  39766. Down = 1,
  39767. /** Left */
  39768. Left = 2,
  39769. /** Right */
  39770. Right = 3
  39771. }
  39772. /**
  39773. * Defines a DualShock gamepad
  39774. */
  39775. export class DualShockPad extends Gamepad {
  39776. private _leftTrigger;
  39777. private _rightTrigger;
  39778. private _onlefttriggerchanged;
  39779. private _onrighttriggerchanged;
  39780. private _onbuttondown;
  39781. private _onbuttonup;
  39782. private _ondpaddown;
  39783. private _ondpadup;
  39784. /** Observable raised when a button is pressed */
  39785. onButtonDownObservable: Observable<DualShockButton>;
  39786. /** Observable raised when a button is released */
  39787. onButtonUpObservable: Observable<DualShockButton>;
  39788. /** Observable raised when a pad is pressed */
  39789. onPadDownObservable: Observable<DualShockDpad>;
  39790. /** Observable raised when a pad is released */
  39791. onPadUpObservable: Observable<DualShockDpad>;
  39792. private _buttonCross;
  39793. private _buttonCircle;
  39794. private _buttonSquare;
  39795. private _buttonTriangle;
  39796. private _buttonShare;
  39797. private _buttonOptions;
  39798. private _buttonL1;
  39799. private _buttonR1;
  39800. private _buttonLeftStick;
  39801. private _buttonRightStick;
  39802. private _dPadUp;
  39803. private _dPadDown;
  39804. private _dPadLeft;
  39805. private _dPadRight;
  39806. /**
  39807. * Creates a new DualShock gamepad object
  39808. * @param id defines the id of this gamepad
  39809. * @param index defines its index
  39810. * @param gamepad defines the internal HTML gamepad object
  39811. */
  39812. constructor(id: string, index: number, gamepad: any);
  39813. /**
  39814. * Defines the callback to call when left trigger is pressed
  39815. * @param callback defines the callback to use
  39816. */
  39817. onlefttriggerchanged(callback: (value: number) => void): void;
  39818. /**
  39819. * Defines the callback to call when right trigger is pressed
  39820. * @param callback defines the callback to use
  39821. */
  39822. onrighttriggerchanged(callback: (value: number) => void): void;
  39823. /**
  39824. * Gets the left trigger value
  39825. */
  39826. /**
  39827. * Sets the left trigger value
  39828. */
  39829. leftTrigger: number;
  39830. /**
  39831. * Gets the right trigger value
  39832. */
  39833. /**
  39834. * Sets the right trigger value
  39835. */
  39836. rightTrigger: number;
  39837. /**
  39838. * Defines the callback to call when a button is pressed
  39839. * @param callback defines the callback to use
  39840. */
  39841. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39842. /**
  39843. * Defines the callback to call when a button is released
  39844. * @param callback defines the callback to use
  39845. */
  39846. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39847. /**
  39848. * Defines the callback to call when a pad is pressed
  39849. * @param callback defines the callback to use
  39850. */
  39851. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39852. /**
  39853. * Defines the callback to call when a pad is released
  39854. * @param callback defines the callback to use
  39855. */
  39856. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39857. private _setButtonValue;
  39858. private _setDPadValue;
  39859. /**
  39860. * Gets the value of the `Cross` button
  39861. */
  39862. /**
  39863. * Sets the value of the `Cross` button
  39864. */
  39865. buttonCross: number;
  39866. /**
  39867. * Gets the value of the `Circle` button
  39868. */
  39869. /**
  39870. * Sets the value of the `Circle` button
  39871. */
  39872. buttonCircle: number;
  39873. /**
  39874. * Gets the value of the `Square` button
  39875. */
  39876. /**
  39877. * Sets the value of the `Square` button
  39878. */
  39879. buttonSquare: number;
  39880. /**
  39881. * Gets the value of the `Triangle` button
  39882. */
  39883. /**
  39884. * Sets the value of the `Triangle` button
  39885. */
  39886. buttonTriangle: number;
  39887. /**
  39888. * Gets the value of the `Options` button
  39889. */
  39890. /**
  39891. * Sets the value of the `Options` button
  39892. */
  39893. buttonOptions: number;
  39894. /**
  39895. * Gets the value of the `Share` button
  39896. */
  39897. /**
  39898. * Sets the value of the `Share` button
  39899. */
  39900. buttonShare: number;
  39901. /**
  39902. * Gets the value of the `L1` button
  39903. */
  39904. /**
  39905. * Sets the value of the `L1` button
  39906. */
  39907. buttonL1: number;
  39908. /**
  39909. * Gets the value of the `R1` button
  39910. */
  39911. /**
  39912. * Sets the value of the `R1` button
  39913. */
  39914. buttonR1: number;
  39915. /**
  39916. * Gets the value of the Left joystick
  39917. */
  39918. /**
  39919. * Sets the value of the Left joystick
  39920. */
  39921. buttonLeftStick: number;
  39922. /**
  39923. * Gets the value of the Right joystick
  39924. */
  39925. /**
  39926. * Sets the value of the Right joystick
  39927. */
  39928. buttonRightStick: number;
  39929. /**
  39930. * Gets the value of D-pad up
  39931. */
  39932. /**
  39933. * Sets the value of D-pad up
  39934. */
  39935. dPadUp: number;
  39936. /**
  39937. * Gets the value of D-pad down
  39938. */
  39939. /**
  39940. * Sets the value of D-pad down
  39941. */
  39942. dPadDown: number;
  39943. /**
  39944. * Gets the value of D-pad left
  39945. */
  39946. /**
  39947. * Sets the value of D-pad left
  39948. */
  39949. dPadLeft: number;
  39950. /**
  39951. * Gets the value of D-pad right
  39952. */
  39953. /**
  39954. * Sets the value of D-pad right
  39955. */
  39956. dPadRight: number;
  39957. /**
  39958. * Force the gamepad to synchronize with device values
  39959. */
  39960. update(): void;
  39961. /**
  39962. * Disposes the gamepad
  39963. */
  39964. dispose(): void;
  39965. }
  39966. }
  39967. declare module "babylonjs/Gamepads/gamepadManager" {
  39968. import { Observable } from "babylonjs/Misc/observable";
  39969. import { Nullable } from "babylonjs/types";
  39970. import { Scene } from "babylonjs/scene";
  39971. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39972. /**
  39973. * Manager for handling gamepads
  39974. */
  39975. export class GamepadManager {
  39976. private _scene?;
  39977. private _babylonGamepads;
  39978. private _oneGamepadConnected;
  39979. /** @hidden */
  39980. _isMonitoring: boolean;
  39981. private _gamepadEventSupported;
  39982. private _gamepadSupport;
  39983. /**
  39984. * observable to be triggered when the gamepad controller has been connected
  39985. */
  39986. onGamepadConnectedObservable: Observable<Gamepad>;
  39987. /**
  39988. * observable to be triggered when the gamepad controller has been disconnected
  39989. */
  39990. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39991. private _onGamepadConnectedEvent;
  39992. private _onGamepadDisconnectedEvent;
  39993. /**
  39994. * Initializes the gamepad manager
  39995. * @param _scene BabylonJS scene
  39996. */
  39997. constructor(_scene?: Scene | undefined);
  39998. /**
  39999. * The gamepads in the game pad manager
  40000. */
  40001. readonly gamepads: Gamepad[];
  40002. /**
  40003. * Get the gamepad controllers based on type
  40004. * @param type The type of gamepad controller
  40005. * @returns Nullable gamepad
  40006. */
  40007. getGamepadByType(type?: number): Nullable<Gamepad>;
  40008. /**
  40009. * Disposes the gamepad manager
  40010. */
  40011. dispose(): void;
  40012. private _addNewGamepad;
  40013. private _startMonitoringGamepads;
  40014. private _stopMonitoringGamepads;
  40015. /** @hidden */
  40016. _checkGamepadsStatus(): void;
  40017. private _updateGamepadObjects;
  40018. }
  40019. }
  40020. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40021. import { Nullable } from "babylonjs/types";
  40022. import { Scene } from "babylonjs/scene";
  40023. import { ISceneComponent } from "babylonjs/sceneComponent";
  40024. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40025. module "babylonjs/scene" {
  40026. interface Scene {
  40027. /** @hidden */
  40028. _gamepadManager: Nullable<GamepadManager>;
  40029. /**
  40030. * Gets the gamepad manager associated with the scene
  40031. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40032. */
  40033. gamepadManager: GamepadManager;
  40034. }
  40035. }
  40036. module "babylonjs/Cameras/freeCameraInputsManager" {
  40037. /**
  40038. * Interface representing a free camera inputs manager
  40039. */
  40040. interface FreeCameraInputsManager {
  40041. /**
  40042. * Adds gamepad input support to the FreeCameraInputsManager.
  40043. * @returns the FreeCameraInputsManager
  40044. */
  40045. addGamepad(): FreeCameraInputsManager;
  40046. }
  40047. }
  40048. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40049. /**
  40050. * Interface representing an arc rotate camera inputs manager
  40051. */
  40052. interface ArcRotateCameraInputsManager {
  40053. /**
  40054. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40055. * @returns the camera inputs manager
  40056. */
  40057. addGamepad(): ArcRotateCameraInputsManager;
  40058. }
  40059. }
  40060. /**
  40061. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40062. */
  40063. export class GamepadSystemSceneComponent implements ISceneComponent {
  40064. /**
  40065. * The component name helpfull to identify the component in the list of scene components.
  40066. */
  40067. readonly name: string;
  40068. /**
  40069. * The scene the component belongs to.
  40070. */
  40071. scene: Scene;
  40072. /**
  40073. * Creates a new instance of the component for the given scene
  40074. * @param scene Defines the scene to register the component in
  40075. */
  40076. constructor(scene: Scene);
  40077. /**
  40078. * Registers the component in a given scene
  40079. */
  40080. register(): void;
  40081. /**
  40082. * Rebuilds the elements related to this component in case of
  40083. * context lost for instance.
  40084. */
  40085. rebuild(): void;
  40086. /**
  40087. * Disposes the component and the associated ressources
  40088. */
  40089. dispose(): void;
  40090. private _beforeCameraUpdate;
  40091. }
  40092. }
  40093. declare module "babylonjs/Cameras/universalCamera" {
  40094. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40095. import { Scene } from "babylonjs/scene";
  40096. import { Vector3 } from "babylonjs/Maths/math.vector";
  40097. import "babylonjs/Gamepads/gamepadSceneComponent";
  40098. /**
  40099. * 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,
  40100. * which still works and will still be found in many Playgrounds.
  40101. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40102. */
  40103. export class UniversalCamera extends TouchCamera {
  40104. /**
  40105. * Defines the gamepad rotation sensiblity.
  40106. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40107. */
  40108. gamepadAngularSensibility: number;
  40109. /**
  40110. * Defines the gamepad move sensiblity.
  40111. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40112. */
  40113. gamepadMoveSensibility: number;
  40114. /**
  40115. * 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,
  40116. * which still works and will still be found in many Playgrounds.
  40117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40118. * @param name Define the name of the camera in the scene
  40119. * @param position Define the start position of the camera in the scene
  40120. * @param scene Define the scene the camera belongs to
  40121. */
  40122. constructor(name: string, position: Vector3, scene: Scene);
  40123. /**
  40124. * Gets the current object class name.
  40125. * @return the class name
  40126. */
  40127. getClassName(): string;
  40128. }
  40129. }
  40130. declare module "babylonjs/Cameras/gamepadCamera" {
  40131. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40132. import { Scene } from "babylonjs/scene";
  40133. import { Vector3 } from "babylonjs/Maths/math.vector";
  40134. /**
  40135. * This represents a FPS type of camera. This is only here for back compat purpose.
  40136. * Please use the UniversalCamera instead as both are identical.
  40137. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40138. */
  40139. export class GamepadCamera extends UniversalCamera {
  40140. /**
  40141. * Instantiates a new Gamepad Camera
  40142. * This represents a FPS type of camera. This is only here for back compat purpose.
  40143. * Please use the UniversalCamera instead as both are identical.
  40144. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40145. * @param name Define the name of the camera in the scene
  40146. * @param position Define the start position of the camera in the scene
  40147. * @param scene Define the scene the camera belongs to
  40148. */
  40149. constructor(name: string, position: Vector3, scene: Scene);
  40150. /**
  40151. * Gets the current object class name.
  40152. * @return the class name
  40153. */
  40154. getClassName(): string;
  40155. }
  40156. }
  40157. declare module "babylonjs/Shaders/pass.fragment" {
  40158. /** @hidden */
  40159. export var passPixelShader: {
  40160. name: string;
  40161. shader: string;
  40162. };
  40163. }
  40164. declare module "babylonjs/Shaders/passCube.fragment" {
  40165. /** @hidden */
  40166. export var passCubePixelShader: {
  40167. name: string;
  40168. shader: string;
  40169. };
  40170. }
  40171. declare module "babylonjs/PostProcesses/passPostProcess" {
  40172. import { Nullable } from "babylonjs/types";
  40173. import { Camera } from "babylonjs/Cameras/camera";
  40174. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40175. import { Engine } from "babylonjs/Engines/engine";
  40176. import "babylonjs/Shaders/pass.fragment";
  40177. import "babylonjs/Shaders/passCube.fragment";
  40178. /**
  40179. * PassPostProcess which produces an output the same as it's input
  40180. */
  40181. export class PassPostProcess extends PostProcess {
  40182. /**
  40183. * Creates the PassPostProcess
  40184. * @param name The name of the effect.
  40185. * @param options The required width/height ratio to downsize to before computing the render pass.
  40186. * @param camera The camera to apply the render pass to.
  40187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40188. * @param engine The engine which the post process will be applied. (default: current engine)
  40189. * @param reusable If the post process can be reused on the same frame. (default: false)
  40190. * @param textureType The type of texture to be used when performing the post processing.
  40191. * @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)
  40192. */
  40193. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40194. }
  40195. /**
  40196. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40197. */
  40198. export class PassCubePostProcess extends PostProcess {
  40199. private _face;
  40200. /**
  40201. * Gets or sets the cube face to display.
  40202. * * 0 is +X
  40203. * * 1 is -X
  40204. * * 2 is +Y
  40205. * * 3 is -Y
  40206. * * 4 is +Z
  40207. * * 5 is -Z
  40208. */
  40209. face: number;
  40210. /**
  40211. * Creates the PassCubePostProcess
  40212. * @param name The name of the effect.
  40213. * @param options The required width/height ratio to downsize to before computing the render pass.
  40214. * @param camera The camera to apply the render pass to.
  40215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40216. * @param engine The engine which the post process will be applied. (default: current engine)
  40217. * @param reusable If the post process can be reused on the same frame. (default: false)
  40218. * @param textureType The type of texture to be used when performing the post processing.
  40219. * @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)
  40220. */
  40221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40222. }
  40223. }
  40224. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40225. /** @hidden */
  40226. export var anaglyphPixelShader: {
  40227. name: string;
  40228. shader: string;
  40229. };
  40230. }
  40231. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40232. import { Engine } from "babylonjs/Engines/engine";
  40233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40234. import { Camera } from "babylonjs/Cameras/camera";
  40235. import "babylonjs/Shaders/anaglyph.fragment";
  40236. /**
  40237. * Postprocess used to generate anaglyphic rendering
  40238. */
  40239. export class AnaglyphPostProcess extends PostProcess {
  40240. private _passedProcess;
  40241. /**
  40242. * Creates a new AnaglyphPostProcess
  40243. * @param name defines postprocess name
  40244. * @param options defines creation options or target ratio scale
  40245. * @param rigCameras defines cameras using this postprocess
  40246. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40247. * @param engine defines hosting engine
  40248. * @param reusable defines if the postprocess will be reused multiple times per frame
  40249. */
  40250. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40251. }
  40252. }
  40253. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40254. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40256. import { Scene } from "babylonjs/scene";
  40257. import { Vector3 } from "babylonjs/Maths/math.vector";
  40258. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40259. /**
  40260. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40261. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40262. */
  40263. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40264. /**
  40265. * Creates a new AnaglyphArcRotateCamera
  40266. * @param name defines camera name
  40267. * @param alpha defines alpha angle (in radians)
  40268. * @param beta defines beta angle (in radians)
  40269. * @param radius defines radius
  40270. * @param target defines camera target
  40271. * @param interaxialDistance defines distance between each color axis
  40272. * @param scene defines the hosting scene
  40273. */
  40274. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40275. /**
  40276. * Gets camera class name
  40277. * @returns AnaglyphArcRotateCamera
  40278. */
  40279. getClassName(): string;
  40280. }
  40281. }
  40282. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40284. import { Scene } from "babylonjs/scene";
  40285. import { Vector3 } from "babylonjs/Maths/math.vector";
  40286. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40287. /**
  40288. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40289. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40290. */
  40291. export class AnaglyphFreeCamera extends FreeCamera {
  40292. /**
  40293. * Creates a new AnaglyphFreeCamera
  40294. * @param name defines camera name
  40295. * @param position defines initial position
  40296. * @param interaxialDistance defines distance between each color axis
  40297. * @param scene defines the hosting scene
  40298. */
  40299. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40300. /**
  40301. * Gets camera class name
  40302. * @returns AnaglyphFreeCamera
  40303. */
  40304. getClassName(): string;
  40305. }
  40306. }
  40307. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40308. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40309. import { Scene } from "babylonjs/scene";
  40310. import { Vector3 } from "babylonjs/Maths/math.vector";
  40311. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40312. /**
  40313. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40314. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40315. */
  40316. export class AnaglyphGamepadCamera extends GamepadCamera {
  40317. /**
  40318. * Creates a new AnaglyphGamepadCamera
  40319. * @param name defines camera name
  40320. * @param position defines initial position
  40321. * @param interaxialDistance defines distance between each color axis
  40322. * @param scene defines the hosting scene
  40323. */
  40324. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40325. /**
  40326. * Gets camera class name
  40327. * @returns AnaglyphGamepadCamera
  40328. */
  40329. getClassName(): string;
  40330. }
  40331. }
  40332. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40333. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40334. import { Scene } from "babylonjs/scene";
  40335. import { Vector3 } from "babylonjs/Maths/math.vector";
  40336. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40337. /**
  40338. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40340. */
  40341. export class AnaglyphUniversalCamera extends UniversalCamera {
  40342. /**
  40343. * Creates a new AnaglyphUniversalCamera
  40344. * @param name defines camera name
  40345. * @param position defines initial position
  40346. * @param interaxialDistance defines distance between each color axis
  40347. * @param scene defines the hosting scene
  40348. */
  40349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40350. /**
  40351. * Gets camera class name
  40352. * @returns AnaglyphUniversalCamera
  40353. */
  40354. getClassName(): string;
  40355. }
  40356. }
  40357. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40358. /** @hidden */
  40359. export var stereoscopicInterlacePixelShader: {
  40360. name: string;
  40361. shader: string;
  40362. };
  40363. }
  40364. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40365. import { Camera } from "babylonjs/Cameras/camera";
  40366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40367. import { Engine } from "babylonjs/Engines/engine";
  40368. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40369. /**
  40370. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40371. */
  40372. export class StereoscopicInterlacePostProcess extends PostProcess {
  40373. private _stepSize;
  40374. private _passedProcess;
  40375. /**
  40376. * Initializes a StereoscopicInterlacePostProcess
  40377. * @param name The name of the effect.
  40378. * @param rigCameras The rig cameras to be appled to the post process
  40379. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40381. * @param engine The engine which the post process will be applied. (default: current engine)
  40382. * @param reusable If the post process can be reused on the same frame. (default: false)
  40383. */
  40384. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40385. }
  40386. }
  40387. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40388. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40389. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40390. import { Scene } from "babylonjs/scene";
  40391. import { Vector3 } from "babylonjs/Maths/math.vector";
  40392. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40393. /**
  40394. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40395. * @see http://doc.babylonjs.com/features/cameras
  40396. */
  40397. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40398. /**
  40399. * Creates a new StereoscopicArcRotateCamera
  40400. * @param name defines camera name
  40401. * @param alpha defines alpha angle (in radians)
  40402. * @param beta defines beta angle (in radians)
  40403. * @param radius defines radius
  40404. * @param target defines camera target
  40405. * @param interaxialDistance defines distance between each color axis
  40406. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40407. * @param scene defines the hosting scene
  40408. */
  40409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40410. /**
  40411. * Gets camera class name
  40412. * @returns StereoscopicArcRotateCamera
  40413. */
  40414. getClassName(): string;
  40415. }
  40416. }
  40417. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40418. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40419. import { Scene } from "babylonjs/scene";
  40420. import { Vector3 } from "babylonjs/Maths/math.vector";
  40421. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40422. /**
  40423. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40424. * @see http://doc.babylonjs.com/features/cameras
  40425. */
  40426. export class StereoscopicFreeCamera extends FreeCamera {
  40427. /**
  40428. * Creates a new StereoscopicFreeCamera
  40429. * @param name defines camera name
  40430. * @param position defines initial position
  40431. * @param interaxialDistance defines distance between each color axis
  40432. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40433. * @param scene defines the hosting scene
  40434. */
  40435. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40436. /**
  40437. * Gets camera class name
  40438. * @returns StereoscopicFreeCamera
  40439. */
  40440. getClassName(): string;
  40441. }
  40442. }
  40443. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40444. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40445. import { Scene } from "babylonjs/scene";
  40446. import { Vector3 } from "babylonjs/Maths/math.vector";
  40447. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40448. /**
  40449. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40450. * @see http://doc.babylonjs.com/features/cameras
  40451. */
  40452. export class StereoscopicGamepadCamera extends GamepadCamera {
  40453. /**
  40454. * Creates a new StereoscopicGamepadCamera
  40455. * @param name defines camera name
  40456. * @param position defines initial position
  40457. * @param interaxialDistance defines distance between each color axis
  40458. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40459. * @param scene defines the hosting scene
  40460. */
  40461. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40462. /**
  40463. * Gets camera class name
  40464. * @returns StereoscopicGamepadCamera
  40465. */
  40466. getClassName(): string;
  40467. }
  40468. }
  40469. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40470. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40471. import { Scene } from "babylonjs/scene";
  40472. import { Vector3 } from "babylonjs/Maths/math.vector";
  40473. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40474. /**
  40475. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40476. * @see http://doc.babylonjs.com/features/cameras
  40477. */
  40478. export class StereoscopicUniversalCamera extends UniversalCamera {
  40479. /**
  40480. * Creates a new StereoscopicUniversalCamera
  40481. * @param name defines camera name
  40482. * @param position defines initial position
  40483. * @param interaxialDistance defines distance between each color axis
  40484. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40485. * @param scene defines the hosting scene
  40486. */
  40487. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40488. /**
  40489. * Gets camera class name
  40490. * @returns StereoscopicUniversalCamera
  40491. */
  40492. getClassName(): string;
  40493. }
  40494. }
  40495. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40496. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40497. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40498. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40499. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40500. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40501. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40502. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40503. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40504. }
  40505. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40506. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40507. import { Scene } from "babylonjs/scene";
  40508. import { Vector3 } from "babylonjs/Maths/math.vector";
  40509. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40510. /**
  40511. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40512. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40513. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40514. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40515. */
  40516. export class VirtualJoysticksCamera extends FreeCamera {
  40517. /**
  40518. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40519. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40520. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40521. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40522. * @param name Define the name of the camera in the scene
  40523. * @param position Define the start position of the camera in the scene
  40524. * @param scene Define the scene the camera belongs to
  40525. */
  40526. constructor(name: string, position: Vector3, scene: Scene);
  40527. /**
  40528. * Gets the current object class name.
  40529. * @return the class name
  40530. */
  40531. getClassName(): string;
  40532. }
  40533. }
  40534. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40535. import { Matrix } from "babylonjs/Maths/math.vector";
  40536. /**
  40537. * This represents all the required metrics to create a VR camera.
  40538. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40539. */
  40540. export class VRCameraMetrics {
  40541. /**
  40542. * Define the horizontal resolution off the screen.
  40543. */
  40544. hResolution: number;
  40545. /**
  40546. * Define the vertical resolution off the screen.
  40547. */
  40548. vResolution: number;
  40549. /**
  40550. * Define the horizontal screen size.
  40551. */
  40552. hScreenSize: number;
  40553. /**
  40554. * Define the vertical screen size.
  40555. */
  40556. vScreenSize: number;
  40557. /**
  40558. * Define the vertical screen center position.
  40559. */
  40560. vScreenCenter: number;
  40561. /**
  40562. * Define the distance of the eyes to the screen.
  40563. */
  40564. eyeToScreenDistance: number;
  40565. /**
  40566. * Define the distance between both lenses
  40567. */
  40568. lensSeparationDistance: number;
  40569. /**
  40570. * Define the distance between both viewer's eyes.
  40571. */
  40572. interpupillaryDistance: number;
  40573. /**
  40574. * Define the distortion factor of the VR postprocess.
  40575. * Please, touch with care.
  40576. */
  40577. distortionK: number[];
  40578. /**
  40579. * Define the chromatic aberration correction factors for the VR post process.
  40580. */
  40581. chromaAbCorrection: number[];
  40582. /**
  40583. * Define the scale factor of the post process.
  40584. * The smaller the better but the slower.
  40585. */
  40586. postProcessScaleFactor: number;
  40587. /**
  40588. * Define an offset for the lens center.
  40589. */
  40590. lensCenterOffset: number;
  40591. /**
  40592. * Define if the current vr camera should compensate the distortion of the lense or not.
  40593. */
  40594. compensateDistortion: boolean;
  40595. /**
  40596. * Defines if multiview should be enabled when rendering (Default: false)
  40597. */
  40598. multiviewEnabled: boolean;
  40599. /**
  40600. * Gets the rendering aspect ratio based on the provided resolutions.
  40601. */
  40602. readonly aspectRatio: number;
  40603. /**
  40604. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40605. */
  40606. readonly aspectRatioFov: number;
  40607. /**
  40608. * @hidden
  40609. */
  40610. readonly leftHMatrix: Matrix;
  40611. /**
  40612. * @hidden
  40613. */
  40614. readonly rightHMatrix: Matrix;
  40615. /**
  40616. * @hidden
  40617. */
  40618. readonly leftPreViewMatrix: Matrix;
  40619. /**
  40620. * @hidden
  40621. */
  40622. readonly rightPreViewMatrix: Matrix;
  40623. /**
  40624. * Get the default VRMetrics based on the most generic setup.
  40625. * @returns the default vr metrics
  40626. */
  40627. static GetDefault(): VRCameraMetrics;
  40628. }
  40629. }
  40630. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40631. /** @hidden */
  40632. export var vrDistortionCorrectionPixelShader: {
  40633. name: string;
  40634. shader: string;
  40635. };
  40636. }
  40637. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40638. import { Camera } from "babylonjs/Cameras/camera";
  40639. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40640. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40641. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40642. /**
  40643. * VRDistortionCorrectionPostProcess used for mobile VR
  40644. */
  40645. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40646. private _isRightEye;
  40647. private _distortionFactors;
  40648. private _postProcessScaleFactor;
  40649. private _lensCenterOffset;
  40650. private _scaleIn;
  40651. private _scaleFactor;
  40652. private _lensCenter;
  40653. /**
  40654. * Initializes the VRDistortionCorrectionPostProcess
  40655. * @param name The name of the effect.
  40656. * @param camera The camera to apply the render pass to.
  40657. * @param isRightEye If this is for the right eye distortion
  40658. * @param vrMetrics All the required metrics for the VR camera
  40659. */
  40660. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40664. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40665. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40666. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40667. import { Scene } from "babylonjs/scene";
  40668. import { Vector3 } from "babylonjs/Maths/math.vector";
  40669. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40670. import "babylonjs/Cameras/RigModes/vrRigMode";
  40671. /**
  40672. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40673. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40674. */
  40675. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40676. /**
  40677. * Creates a new VRDeviceOrientationArcRotateCamera
  40678. * @param name defines camera name
  40679. * @param alpha defines the camera rotation along the logitudinal axis
  40680. * @param beta defines the camera rotation along the latitudinal axis
  40681. * @param radius defines the camera distance from its target
  40682. * @param target defines the camera target
  40683. * @param scene defines the scene the camera belongs to
  40684. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40685. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40686. */
  40687. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40688. /**
  40689. * Gets camera class name
  40690. * @returns VRDeviceOrientationArcRotateCamera
  40691. */
  40692. getClassName(): string;
  40693. }
  40694. }
  40695. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40696. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40697. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40698. import { Scene } from "babylonjs/scene";
  40699. import { Vector3 } from "babylonjs/Maths/math.vector";
  40700. import "babylonjs/Cameras/RigModes/vrRigMode";
  40701. /**
  40702. * Camera used to simulate VR rendering (based on FreeCamera)
  40703. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40704. */
  40705. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40706. /**
  40707. * Creates a new VRDeviceOrientationFreeCamera
  40708. * @param name defines camera name
  40709. * @param position defines the start position of the camera
  40710. * @param scene defines the scene the camera belongs to
  40711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40713. */
  40714. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40715. /**
  40716. * Gets camera class name
  40717. * @returns VRDeviceOrientationFreeCamera
  40718. */
  40719. getClassName(): string;
  40720. }
  40721. }
  40722. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40723. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40724. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40725. import { Scene } from "babylonjs/scene";
  40726. import { Vector3 } from "babylonjs/Maths/math.vector";
  40727. import "babylonjs/Gamepads/gamepadSceneComponent";
  40728. /**
  40729. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40731. */
  40732. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40733. /**
  40734. * Creates a new VRDeviceOrientationGamepadCamera
  40735. * @param name defines camera name
  40736. * @param position defines the start position of the camera
  40737. * @param scene defines the scene the camera belongs to
  40738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40740. */
  40741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40742. /**
  40743. * Gets camera class name
  40744. * @returns VRDeviceOrientationGamepadCamera
  40745. */
  40746. getClassName(): string;
  40747. }
  40748. }
  40749. declare module "babylonjs/Materials/pushMaterial" {
  40750. import { Nullable } from "babylonjs/types";
  40751. import { Scene } from "babylonjs/scene";
  40752. import { Matrix } from "babylonjs/Maths/math.vector";
  40753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40754. import { Mesh } from "babylonjs/Meshes/mesh";
  40755. import { Material } from "babylonjs/Materials/material";
  40756. import { Effect } from "babylonjs/Materials/effect";
  40757. /**
  40758. * Base class of materials working in push mode in babylon JS
  40759. * @hidden
  40760. */
  40761. export class PushMaterial extends Material {
  40762. protected _activeEffect: Effect;
  40763. protected _normalMatrix: Matrix;
  40764. /**
  40765. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40766. * This means that the material can keep using a previous shader while a new one is being compiled.
  40767. * This is mostly used when shader parallel compilation is supported (true by default)
  40768. */
  40769. allowShaderHotSwapping: boolean;
  40770. constructor(name: string, scene: Scene);
  40771. getEffect(): Effect;
  40772. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40773. /**
  40774. * Binds the given world matrix to the active effect
  40775. *
  40776. * @param world the matrix to bind
  40777. */
  40778. bindOnlyWorldMatrix(world: Matrix): void;
  40779. /**
  40780. * Binds the given normal matrix to the active effect
  40781. *
  40782. * @param normalMatrix the matrix to bind
  40783. */
  40784. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40785. bind(world: Matrix, mesh?: Mesh): void;
  40786. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40787. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40788. }
  40789. }
  40790. declare module "babylonjs/Materials/materialFlags" {
  40791. /**
  40792. * This groups all the flags used to control the materials channel.
  40793. */
  40794. export class MaterialFlags {
  40795. private static _DiffuseTextureEnabled;
  40796. /**
  40797. * Are diffuse textures enabled in the application.
  40798. */
  40799. static DiffuseTextureEnabled: boolean;
  40800. private static _AmbientTextureEnabled;
  40801. /**
  40802. * Are ambient textures enabled in the application.
  40803. */
  40804. static AmbientTextureEnabled: boolean;
  40805. private static _OpacityTextureEnabled;
  40806. /**
  40807. * Are opacity textures enabled in the application.
  40808. */
  40809. static OpacityTextureEnabled: boolean;
  40810. private static _ReflectionTextureEnabled;
  40811. /**
  40812. * Are reflection textures enabled in the application.
  40813. */
  40814. static ReflectionTextureEnabled: boolean;
  40815. private static _EmissiveTextureEnabled;
  40816. /**
  40817. * Are emissive textures enabled in the application.
  40818. */
  40819. static EmissiveTextureEnabled: boolean;
  40820. private static _SpecularTextureEnabled;
  40821. /**
  40822. * Are specular textures enabled in the application.
  40823. */
  40824. static SpecularTextureEnabled: boolean;
  40825. private static _BumpTextureEnabled;
  40826. /**
  40827. * Are bump textures enabled in the application.
  40828. */
  40829. static BumpTextureEnabled: boolean;
  40830. private static _LightmapTextureEnabled;
  40831. /**
  40832. * Are lightmap textures enabled in the application.
  40833. */
  40834. static LightmapTextureEnabled: boolean;
  40835. private static _RefractionTextureEnabled;
  40836. /**
  40837. * Are refraction textures enabled in the application.
  40838. */
  40839. static RefractionTextureEnabled: boolean;
  40840. private static _ColorGradingTextureEnabled;
  40841. /**
  40842. * Are color grading textures enabled in the application.
  40843. */
  40844. static ColorGradingTextureEnabled: boolean;
  40845. private static _FresnelEnabled;
  40846. /**
  40847. * Are fresnels enabled in the application.
  40848. */
  40849. static FresnelEnabled: boolean;
  40850. private static _ClearCoatTextureEnabled;
  40851. /**
  40852. * Are clear coat textures enabled in the application.
  40853. */
  40854. static ClearCoatTextureEnabled: boolean;
  40855. private static _ClearCoatBumpTextureEnabled;
  40856. /**
  40857. * Are clear coat bump textures enabled in the application.
  40858. */
  40859. static ClearCoatBumpTextureEnabled: boolean;
  40860. private static _ClearCoatTintTextureEnabled;
  40861. /**
  40862. * Are clear coat tint textures enabled in the application.
  40863. */
  40864. static ClearCoatTintTextureEnabled: boolean;
  40865. private static _SheenTextureEnabled;
  40866. /**
  40867. * Are sheen textures enabled in the application.
  40868. */
  40869. static SheenTextureEnabled: boolean;
  40870. private static _AnisotropicTextureEnabled;
  40871. /**
  40872. * Are anisotropic textures enabled in the application.
  40873. */
  40874. static AnisotropicTextureEnabled: boolean;
  40875. private static _ThicknessTextureEnabled;
  40876. /**
  40877. * Are thickness textures enabled in the application.
  40878. */
  40879. static ThicknessTextureEnabled: boolean;
  40880. }
  40881. }
  40882. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40883. /** @hidden */
  40884. export var defaultFragmentDeclaration: {
  40885. name: string;
  40886. shader: string;
  40887. };
  40888. }
  40889. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40890. /** @hidden */
  40891. export var defaultUboDeclaration: {
  40892. name: string;
  40893. shader: string;
  40894. };
  40895. }
  40896. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40897. /** @hidden */
  40898. export var lightFragmentDeclaration: {
  40899. name: string;
  40900. shader: string;
  40901. };
  40902. }
  40903. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40904. /** @hidden */
  40905. export var lightUboDeclaration: {
  40906. name: string;
  40907. shader: string;
  40908. };
  40909. }
  40910. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40911. /** @hidden */
  40912. export var lightsFragmentFunctions: {
  40913. name: string;
  40914. shader: string;
  40915. };
  40916. }
  40917. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40918. /** @hidden */
  40919. export var shadowsFragmentFunctions: {
  40920. name: string;
  40921. shader: string;
  40922. };
  40923. }
  40924. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40925. /** @hidden */
  40926. export var fresnelFunction: {
  40927. name: string;
  40928. shader: string;
  40929. };
  40930. }
  40931. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40932. /** @hidden */
  40933. export var reflectionFunction: {
  40934. name: string;
  40935. shader: string;
  40936. };
  40937. }
  40938. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40939. /** @hidden */
  40940. export var bumpFragmentFunctions: {
  40941. name: string;
  40942. shader: string;
  40943. };
  40944. }
  40945. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40946. /** @hidden */
  40947. export var logDepthDeclaration: {
  40948. name: string;
  40949. shader: string;
  40950. };
  40951. }
  40952. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40953. /** @hidden */
  40954. export var bumpFragment: {
  40955. name: string;
  40956. shader: string;
  40957. };
  40958. }
  40959. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40960. /** @hidden */
  40961. export var depthPrePass: {
  40962. name: string;
  40963. shader: string;
  40964. };
  40965. }
  40966. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40967. /** @hidden */
  40968. export var lightFragment: {
  40969. name: string;
  40970. shader: string;
  40971. };
  40972. }
  40973. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40974. /** @hidden */
  40975. export var logDepthFragment: {
  40976. name: string;
  40977. shader: string;
  40978. };
  40979. }
  40980. declare module "babylonjs/Shaders/default.fragment" {
  40981. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40982. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40984. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40985. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40986. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40987. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40988. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40992. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40994. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40995. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40997. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40998. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40999. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41000. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41002. /** @hidden */
  41003. export var defaultPixelShader: {
  41004. name: string;
  41005. shader: string;
  41006. };
  41007. }
  41008. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41009. /** @hidden */
  41010. export var defaultVertexDeclaration: {
  41011. name: string;
  41012. shader: string;
  41013. };
  41014. }
  41015. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41016. /** @hidden */
  41017. export var bumpVertexDeclaration: {
  41018. name: string;
  41019. shader: string;
  41020. };
  41021. }
  41022. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41023. /** @hidden */
  41024. export var bumpVertex: {
  41025. name: string;
  41026. shader: string;
  41027. };
  41028. }
  41029. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41030. /** @hidden */
  41031. export var fogVertex: {
  41032. name: string;
  41033. shader: string;
  41034. };
  41035. }
  41036. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41037. /** @hidden */
  41038. export var shadowsVertex: {
  41039. name: string;
  41040. shader: string;
  41041. };
  41042. }
  41043. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41044. /** @hidden */
  41045. export var pointCloudVertex: {
  41046. name: string;
  41047. shader: string;
  41048. };
  41049. }
  41050. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41051. /** @hidden */
  41052. export var logDepthVertex: {
  41053. name: string;
  41054. shader: string;
  41055. };
  41056. }
  41057. declare module "babylonjs/Shaders/default.vertex" {
  41058. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41059. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41061. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41062. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41063. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41065. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41068. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41070. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41072. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41073. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41074. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41075. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41076. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41077. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41078. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41079. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41080. /** @hidden */
  41081. export var defaultVertexShader: {
  41082. name: string;
  41083. shader: string;
  41084. };
  41085. }
  41086. declare module "babylonjs/Materials/standardMaterial" {
  41087. import { SmartArray } from "babylonjs/Misc/smartArray";
  41088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41089. import { Nullable } from "babylonjs/types";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Matrix } from "babylonjs/Maths/math.vector";
  41092. import { Color3 } from "babylonjs/Maths/math.color";
  41093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41095. import { Mesh } from "babylonjs/Meshes/mesh";
  41096. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41097. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41098. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41103. import "babylonjs/Shaders/default.fragment";
  41104. import "babylonjs/Shaders/default.vertex";
  41105. /** @hidden */
  41106. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41107. MAINUV1: boolean;
  41108. MAINUV2: boolean;
  41109. DIFFUSE: boolean;
  41110. DIFFUSEDIRECTUV: number;
  41111. AMBIENT: boolean;
  41112. AMBIENTDIRECTUV: number;
  41113. OPACITY: boolean;
  41114. OPACITYDIRECTUV: number;
  41115. OPACITYRGB: boolean;
  41116. REFLECTION: boolean;
  41117. EMISSIVE: boolean;
  41118. EMISSIVEDIRECTUV: number;
  41119. SPECULAR: boolean;
  41120. SPECULARDIRECTUV: number;
  41121. BUMP: boolean;
  41122. BUMPDIRECTUV: number;
  41123. PARALLAX: boolean;
  41124. PARALLAXOCCLUSION: boolean;
  41125. SPECULAROVERALPHA: boolean;
  41126. CLIPPLANE: boolean;
  41127. CLIPPLANE2: boolean;
  41128. CLIPPLANE3: boolean;
  41129. CLIPPLANE4: boolean;
  41130. ALPHATEST: boolean;
  41131. DEPTHPREPASS: boolean;
  41132. ALPHAFROMDIFFUSE: boolean;
  41133. POINTSIZE: boolean;
  41134. FOG: boolean;
  41135. SPECULARTERM: boolean;
  41136. DIFFUSEFRESNEL: boolean;
  41137. OPACITYFRESNEL: boolean;
  41138. REFLECTIONFRESNEL: boolean;
  41139. REFRACTIONFRESNEL: boolean;
  41140. EMISSIVEFRESNEL: boolean;
  41141. FRESNEL: boolean;
  41142. NORMAL: boolean;
  41143. UV1: boolean;
  41144. UV2: boolean;
  41145. VERTEXCOLOR: boolean;
  41146. VERTEXALPHA: boolean;
  41147. NUM_BONE_INFLUENCERS: number;
  41148. BonesPerMesh: number;
  41149. BONETEXTURE: boolean;
  41150. INSTANCES: boolean;
  41151. GLOSSINESS: boolean;
  41152. ROUGHNESS: boolean;
  41153. EMISSIVEASILLUMINATION: boolean;
  41154. LINKEMISSIVEWITHDIFFUSE: boolean;
  41155. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41156. LIGHTMAP: boolean;
  41157. LIGHTMAPDIRECTUV: number;
  41158. OBJECTSPACE_NORMALMAP: boolean;
  41159. USELIGHTMAPASSHADOWMAP: boolean;
  41160. REFLECTIONMAP_3D: boolean;
  41161. REFLECTIONMAP_SPHERICAL: boolean;
  41162. REFLECTIONMAP_PLANAR: boolean;
  41163. REFLECTIONMAP_CUBIC: boolean;
  41164. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41165. REFLECTIONMAP_PROJECTION: boolean;
  41166. REFLECTIONMAP_SKYBOX: boolean;
  41167. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41168. REFLECTIONMAP_EXPLICIT: boolean;
  41169. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41170. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41171. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41172. INVERTCUBICMAP: boolean;
  41173. LOGARITHMICDEPTH: boolean;
  41174. REFRACTION: boolean;
  41175. REFRACTIONMAP_3D: boolean;
  41176. REFLECTIONOVERALPHA: boolean;
  41177. TWOSIDEDLIGHTING: boolean;
  41178. SHADOWFLOAT: boolean;
  41179. MORPHTARGETS: boolean;
  41180. MORPHTARGETS_NORMAL: boolean;
  41181. MORPHTARGETS_TANGENT: boolean;
  41182. MORPHTARGETS_UV: boolean;
  41183. NUM_MORPH_INFLUENCERS: number;
  41184. NONUNIFORMSCALING: boolean;
  41185. PREMULTIPLYALPHA: boolean;
  41186. IMAGEPROCESSING: boolean;
  41187. VIGNETTE: boolean;
  41188. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41189. VIGNETTEBLENDMODEOPAQUE: boolean;
  41190. TONEMAPPING: boolean;
  41191. TONEMAPPING_ACES: boolean;
  41192. CONTRAST: boolean;
  41193. COLORCURVES: boolean;
  41194. COLORGRADING: boolean;
  41195. COLORGRADING3D: boolean;
  41196. SAMPLER3DGREENDEPTH: boolean;
  41197. SAMPLER3DBGRMAP: boolean;
  41198. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41199. MULTIVIEW: boolean;
  41200. /**
  41201. * If the reflection texture on this material is in linear color space
  41202. * @hidden
  41203. */
  41204. IS_REFLECTION_LINEAR: boolean;
  41205. /**
  41206. * If the refraction texture on this material is in linear color space
  41207. * @hidden
  41208. */
  41209. IS_REFRACTION_LINEAR: boolean;
  41210. EXPOSURE: boolean;
  41211. constructor();
  41212. setReflectionMode(modeToEnable: string): void;
  41213. }
  41214. /**
  41215. * This is the default material used in Babylon. It is the best trade off between quality
  41216. * and performances.
  41217. * @see http://doc.babylonjs.com/babylon101/materials
  41218. */
  41219. export class StandardMaterial extends PushMaterial {
  41220. private _diffuseTexture;
  41221. /**
  41222. * The basic texture of the material as viewed under a light.
  41223. */
  41224. diffuseTexture: Nullable<BaseTexture>;
  41225. private _ambientTexture;
  41226. /**
  41227. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41228. */
  41229. ambientTexture: Nullable<BaseTexture>;
  41230. private _opacityTexture;
  41231. /**
  41232. * Define the transparency of the material from a texture.
  41233. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41234. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41235. */
  41236. opacityTexture: Nullable<BaseTexture>;
  41237. private _reflectionTexture;
  41238. /**
  41239. * Define the texture used to display the reflection.
  41240. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41241. */
  41242. reflectionTexture: Nullable<BaseTexture>;
  41243. private _emissiveTexture;
  41244. /**
  41245. * Define texture of the material as if self lit.
  41246. * This will be mixed in the final result even in the absence of light.
  41247. */
  41248. emissiveTexture: Nullable<BaseTexture>;
  41249. private _specularTexture;
  41250. /**
  41251. * Define how the color and intensity of the highlight given by the light in the material.
  41252. */
  41253. specularTexture: Nullable<BaseTexture>;
  41254. private _bumpTexture;
  41255. /**
  41256. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41257. * 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.
  41258. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41259. */
  41260. bumpTexture: Nullable<BaseTexture>;
  41261. private _lightmapTexture;
  41262. /**
  41263. * Complex lighting can be computationally expensive to compute at runtime.
  41264. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41265. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41266. */
  41267. lightmapTexture: Nullable<BaseTexture>;
  41268. private _refractionTexture;
  41269. /**
  41270. * Define the texture used to display the refraction.
  41271. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41272. */
  41273. refractionTexture: Nullable<BaseTexture>;
  41274. /**
  41275. * The color of the material lit by the environmental background lighting.
  41276. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41277. */
  41278. ambientColor: Color3;
  41279. /**
  41280. * The basic color of the material as viewed under a light.
  41281. */
  41282. diffuseColor: Color3;
  41283. /**
  41284. * Define how the color and intensity of the highlight given by the light in the material.
  41285. */
  41286. specularColor: Color3;
  41287. /**
  41288. * Define the color of the material as if self lit.
  41289. * This will be mixed in the final result even in the absence of light.
  41290. */
  41291. emissiveColor: Color3;
  41292. /**
  41293. * Defines how sharp are the highlights in the material.
  41294. * The bigger the value the sharper giving a more glossy feeling to the result.
  41295. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41296. */
  41297. specularPower: number;
  41298. private _useAlphaFromDiffuseTexture;
  41299. /**
  41300. * Does the transparency come from the diffuse texture alpha channel.
  41301. */
  41302. useAlphaFromDiffuseTexture: boolean;
  41303. private _useEmissiveAsIllumination;
  41304. /**
  41305. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41306. */
  41307. useEmissiveAsIllumination: boolean;
  41308. private _linkEmissiveWithDiffuse;
  41309. /**
  41310. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41311. * the emissive level when the final color is close to one.
  41312. */
  41313. linkEmissiveWithDiffuse: boolean;
  41314. private _useSpecularOverAlpha;
  41315. /**
  41316. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41317. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41318. */
  41319. useSpecularOverAlpha: boolean;
  41320. private _useReflectionOverAlpha;
  41321. /**
  41322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41324. */
  41325. useReflectionOverAlpha: boolean;
  41326. private _disableLighting;
  41327. /**
  41328. * Does lights from the scene impacts this material.
  41329. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41330. */
  41331. disableLighting: boolean;
  41332. private _useObjectSpaceNormalMap;
  41333. /**
  41334. * Allows using an object space normal map (instead of tangent space).
  41335. */
  41336. useObjectSpaceNormalMap: boolean;
  41337. private _useParallax;
  41338. /**
  41339. * Is parallax enabled or not.
  41340. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41341. */
  41342. useParallax: boolean;
  41343. private _useParallaxOcclusion;
  41344. /**
  41345. * Is parallax occlusion enabled or not.
  41346. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41347. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41348. */
  41349. useParallaxOcclusion: boolean;
  41350. /**
  41351. * 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.
  41352. */
  41353. parallaxScaleBias: number;
  41354. private _roughness;
  41355. /**
  41356. * Helps to define how blurry the reflections should appears in the material.
  41357. */
  41358. roughness: number;
  41359. /**
  41360. * In case of refraction, define the value of the index of refraction.
  41361. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41362. */
  41363. indexOfRefraction: number;
  41364. /**
  41365. * Invert the refraction texture alongside the y axis.
  41366. * It can be useful with procedural textures or probe for instance.
  41367. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41368. */
  41369. invertRefractionY: boolean;
  41370. /**
  41371. * Defines the alpha limits in alpha test mode.
  41372. */
  41373. alphaCutOff: number;
  41374. private _useLightmapAsShadowmap;
  41375. /**
  41376. * In case of light mapping, define whether the map contains light or shadow informations.
  41377. */
  41378. useLightmapAsShadowmap: boolean;
  41379. private _diffuseFresnelParameters;
  41380. /**
  41381. * Define the diffuse fresnel parameters of the material.
  41382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41383. */
  41384. diffuseFresnelParameters: FresnelParameters;
  41385. private _opacityFresnelParameters;
  41386. /**
  41387. * Define the opacity fresnel parameters of the material.
  41388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41389. */
  41390. opacityFresnelParameters: FresnelParameters;
  41391. private _reflectionFresnelParameters;
  41392. /**
  41393. * Define the reflection fresnel parameters of the material.
  41394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41395. */
  41396. reflectionFresnelParameters: FresnelParameters;
  41397. private _refractionFresnelParameters;
  41398. /**
  41399. * Define the refraction fresnel parameters of the material.
  41400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41401. */
  41402. refractionFresnelParameters: FresnelParameters;
  41403. private _emissiveFresnelParameters;
  41404. /**
  41405. * Define the emissive fresnel parameters of the material.
  41406. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41407. */
  41408. emissiveFresnelParameters: FresnelParameters;
  41409. private _useReflectionFresnelFromSpecular;
  41410. /**
  41411. * If true automatically deducts the fresnels values from the material specularity.
  41412. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41413. */
  41414. useReflectionFresnelFromSpecular: boolean;
  41415. private _useGlossinessFromSpecularMapAlpha;
  41416. /**
  41417. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41418. */
  41419. useGlossinessFromSpecularMapAlpha: boolean;
  41420. private _maxSimultaneousLights;
  41421. /**
  41422. * Defines the maximum number of lights that can be used in the material
  41423. */
  41424. maxSimultaneousLights: number;
  41425. private _invertNormalMapX;
  41426. /**
  41427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41428. */
  41429. invertNormalMapX: boolean;
  41430. private _invertNormalMapY;
  41431. /**
  41432. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41433. */
  41434. invertNormalMapY: boolean;
  41435. private _twoSidedLighting;
  41436. /**
  41437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41438. */
  41439. twoSidedLighting: boolean;
  41440. /**
  41441. * Default configuration related to image processing available in the standard Material.
  41442. */
  41443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41444. /**
  41445. * Gets the image processing configuration used either in this material.
  41446. */
  41447. /**
  41448. * Sets the Default image processing configuration used either in the this material.
  41449. *
  41450. * If sets to null, the scene one is in use.
  41451. */
  41452. imageProcessingConfiguration: ImageProcessingConfiguration;
  41453. /**
  41454. * Keep track of the image processing observer to allow dispose and replace.
  41455. */
  41456. private _imageProcessingObserver;
  41457. /**
  41458. * Attaches a new image processing configuration to the Standard Material.
  41459. * @param configuration
  41460. */
  41461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41462. /**
  41463. * Gets wether the color curves effect is enabled.
  41464. */
  41465. /**
  41466. * Sets wether the color curves effect is enabled.
  41467. */
  41468. cameraColorCurvesEnabled: boolean;
  41469. /**
  41470. * Gets wether the color grading effect is enabled.
  41471. */
  41472. /**
  41473. * Gets wether the color grading effect is enabled.
  41474. */
  41475. cameraColorGradingEnabled: boolean;
  41476. /**
  41477. * Gets wether tonemapping is enabled or not.
  41478. */
  41479. /**
  41480. * Sets wether tonemapping is enabled or not
  41481. */
  41482. cameraToneMappingEnabled: boolean;
  41483. /**
  41484. * The camera exposure used on this material.
  41485. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41486. * This corresponds to a photographic exposure.
  41487. */
  41488. /**
  41489. * The camera exposure used on this material.
  41490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41491. * This corresponds to a photographic exposure.
  41492. */
  41493. cameraExposure: number;
  41494. /**
  41495. * Gets The camera contrast used on this material.
  41496. */
  41497. /**
  41498. * Sets The camera contrast used on this material.
  41499. */
  41500. cameraContrast: number;
  41501. /**
  41502. * Gets the Color Grading 2D Lookup Texture.
  41503. */
  41504. /**
  41505. * Sets the Color Grading 2D Lookup Texture.
  41506. */
  41507. cameraColorGradingTexture: Nullable<BaseTexture>;
  41508. /**
  41509. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41510. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41511. * 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;
  41512. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41513. */
  41514. /**
  41515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41517. * 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;
  41518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41519. */
  41520. cameraColorCurves: Nullable<ColorCurves>;
  41521. /**
  41522. * Custom callback helping to override the default shader used in the material.
  41523. */
  41524. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41525. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41526. protected _worldViewProjectionMatrix: Matrix;
  41527. protected _globalAmbientColor: Color3;
  41528. protected _useLogarithmicDepth: boolean;
  41529. /**
  41530. * Instantiates a new standard material.
  41531. * This is the default material used in Babylon. It is the best trade off between quality
  41532. * and performances.
  41533. * @see http://doc.babylonjs.com/babylon101/materials
  41534. * @param name Define the name of the material in the scene
  41535. * @param scene Define the scene the material belong to
  41536. */
  41537. constructor(name: string, scene: Scene);
  41538. /**
  41539. * Gets a boolean indicating that current material needs to register RTT
  41540. */
  41541. readonly hasRenderTargetTextures: boolean;
  41542. /**
  41543. * Gets the current class name of the material e.g. "StandardMaterial"
  41544. * Mainly use in serialization.
  41545. * @returns the class name
  41546. */
  41547. getClassName(): string;
  41548. /**
  41549. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41550. * You can try switching to logarithmic depth.
  41551. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41552. */
  41553. useLogarithmicDepth: boolean;
  41554. /**
  41555. * Specifies if the material will require alpha blending
  41556. * @returns a boolean specifying if alpha blending is needed
  41557. */
  41558. needAlphaBlending(): boolean;
  41559. /**
  41560. * Specifies if this material should be rendered in alpha test mode
  41561. * @returns a boolean specifying if an alpha test is needed.
  41562. */
  41563. needAlphaTesting(): boolean;
  41564. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41565. /**
  41566. * Get the texture used for alpha test purpose.
  41567. * @returns the diffuse texture in case of the standard material.
  41568. */
  41569. getAlphaTestTexture(): Nullable<BaseTexture>;
  41570. /**
  41571. * Get if the submesh is ready to be used and all its information available.
  41572. * Child classes can use it to update shaders
  41573. * @param mesh defines the mesh to check
  41574. * @param subMesh defines which submesh to check
  41575. * @param useInstances specifies that instances should be used
  41576. * @returns a boolean indicating that the submesh is ready or not
  41577. */
  41578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41579. /**
  41580. * Builds the material UBO layouts.
  41581. * Used internally during the effect preparation.
  41582. */
  41583. buildUniformLayout(): void;
  41584. /**
  41585. * Unbinds the material from the mesh
  41586. */
  41587. unbind(): void;
  41588. /**
  41589. * Binds the submesh to this material by preparing the effect and shader to draw
  41590. * @param world defines the world transformation matrix
  41591. * @param mesh defines the mesh containing the submesh
  41592. * @param subMesh defines the submesh to bind the material to
  41593. */
  41594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41595. /**
  41596. * Get the list of animatables in the material.
  41597. * @returns the list of animatables object used in the material
  41598. */
  41599. getAnimatables(): IAnimatable[];
  41600. /**
  41601. * Gets the active textures from the material
  41602. * @returns an array of textures
  41603. */
  41604. getActiveTextures(): BaseTexture[];
  41605. /**
  41606. * Specifies if the material uses a texture
  41607. * @param texture defines the texture to check against the material
  41608. * @returns a boolean specifying if the material uses the texture
  41609. */
  41610. hasTexture(texture: BaseTexture): boolean;
  41611. /**
  41612. * Disposes the material
  41613. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41614. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41615. */
  41616. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41617. /**
  41618. * Makes a duplicate of the material, and gives it a new name
  41619. * @param name defines the new name for the duplicated material
  41620. * @returns the cloned material
  41621. */
  41622. clone(name: string): StandardMaterial;
  41623. /**
  41624. * Serializes this material in a JSON representation
  41625. * @returns the serialized material object
  41626. */
  41627. serialize(): any;
  41628. /**
  41629. * Creates a standard material from parsed material data
  41630. * @param source defines the JSON representation of the material
  41631. * @param scene defines the hosting scene
  41632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41633. * @returns a new standard material
  41634. */
  41635. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41636. /**
  41637. * Are diffuse textures enabled in the application.
  41638. */
  41639. static DiffuseTextureEnabled: boolean;
  41640. /**
  41641. * Are ambient textures enabled in the application.
  41642. */
  41643. static AmbientTextureEnabled: boolean;
  41644. /**
  41645. * Are opacity textures enabled in the application.
  41646. */
  41647. static OpacityTextureEnabled: boolean;
  41648. /**
  41649. * Are reflection textures enabled in the application.
  41650. */
  41651. static ReflectionTextureEnabled: boolean;
  41652. /**
  41653. * Are emissive textures enabled in the application.
  41654. */
  41655. static EmissiveTextureEnabled: boolean;
  41656. /**
  41657. * Are specular textures enabled in the application.
  41658. */
  41659. static SpecularTextureEnabled: boolean;
  41660. /**
  41661. * Are bump textures enabled in the application.
  41662. */
  41663. static BumpTextureEnabled: boolean;
  41664. /**
  41665. * Are lightmap textures enabled in the application.
  41666. */
  41667. static LightmapTextureEnabled: boolean;
  41668. /**
  41669. * Are refraction textures enabled in the application.
  41670. */
  41671. static RefractionTextureEnabled: boolean;
  41672. /**
  41673. * Are color grading textures enabled in the application.
  41674. */
  41675. static ColorGradingTextureEnabled: boolean;
  41676. /**
  41677. * Are fresnels enabled in the application.
  41678. */
  41679. static FresnelEnabled: boolean;
  41680. }
  41681. }
  41682. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41683. import { Scene } from "babylonjs/scene";
  41684. import { Texture } from "babylonjs/Materials/Textures/texture";
  41685. /**
  41686. * A class extending Texture allowing drawing on a texture
  41687. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41688. */
  41689. export class DynamicTexture extends Texture {
  41690. private _generateMipMaps;
  41691. private _canvas;
  41692. private _context;
  41693. private _engine;
  41694. /**
  41695. * Creates a DynamicTexture
  41696. * @param name defines the name of the texture
  41697. * @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
  41698. * @param scene defines the scene where you want the texture
  41699. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41700. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41701. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41702. */
  41703. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41704. /**
  41705. * Get the current class name of the texture useful for serialization or dynamic coding.
  41706. * @returns "DynamicTexture"
  41707. */
  41708. getClassName(): string;
  41709. /**
  41710. * Gets the current state of canRescale
  41711. */
  41712. readonly canRescale: boolean;
  41713. private _recreate;
  41714. /**
  41715. * Scales the texture
  41716. * @param ratio the scale factor to apply to both width and height
  41717. */
  41718. scale(ratio: number): void;
  41719. /**
  41720. * Resizes the texture
  41721. * @param width the new width
  41722. * @param height the new height
  41723. */
  41724. scaleTo(width: number, height: number): void;
  41725. /**
  41726. * Gets the context of the canvas used by the texture
  41727. * @returns the canvas context of the dynamic texture
  41728. */
  41729. getContext(): CanvasRenderingContext2D;
  41730. /**
  41731. * Clears the texture
  41732. */
  41733. clear(): void;
  41734. /**
  41735. * Updates the texture
  41736. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41737. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41738. */
  41739. update(invertY?: boolean, premulAlpha?: boolean): void;
  41740. /**
  41741. * Draws text onto the texture
  41742. * @param text defines the text to be drawn
  41743. * @param x defines the placement of the text from the left
  41744. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41745. * @param font defines the font to be used with font-style, font-size, font-name
  41746. * @param color defines the color used for the text
  41747. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41748. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41749. * @param update defines whether texture is immediately update (default is true)
  41750. */
  41751. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41752. /**
  41753. * Clones the texture
  41754. * @returns the clone of the texture.
  41755. */
  41756. clone(): DynamicTexture;
  41757. /**
  41758. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41759. * @returns a serialized dynamic texture object
  41760. */
  41761. serialize(): any;
  41762. /** @hidden */
  41763. _rebuild(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41767. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41769. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41770. /** @hidden */
  41771. export var imageProcessingPixelShader: {
  41772. name: string;
  41773. shader: string;
  41774. };
  41775. }
  41776. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41777. import { Nullable } from "babylonjs/types";
  41778. import { Color4 } from "babylonjs/Maths/math.color";
  41779. import { Camera } from "babylonjs/Cameras/camera";
  41780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41781. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41782. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41784. import { Engine } from "babylonjs/Engines/engine";
  41785. import "babylonjs/Shaders/imageProcessing.fragment";
  41786. import "babylonjs/Shaders/postprocess.vertex";
  41787. /**
  41788. * ImageProcessingPostProcess
  41789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41790. */
  41791. export class ImageProcessingPostProcess extends PostProcess {
  41792. /**
  41793. * Default configuration related to image processing available in the PBR Material.
  41794. */
  41795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41796. /**
  41797. * Gets the image processing configuration used either in this material.
  41798. */
  41799. /**
  41800. * Sets the Default image processing configuration used either in the this material.
  41801. *
  41802. * If sets to null, the scene one is in use.
  41803. */
  41804. imageProcessingConfiguration: ImageProcessingConfiguration;
  41805. /**
  41806. * Keep track of the image processing observer to allow dispose and replace.
  41807. */
  41808. private _imageProcessingObserver;
  41809. /**
  41810. * Attaches a new image processing configuration to the PBR Material.
  41811. * @param configuration
  41812. */
  41813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41814. /**
  41815. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41816. */
  41817. /**
  41818. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41819. */
  41820. colorCurves: Nullable<ColorCurves>;
  41821. /**
  41822. * Gets wether the color curves effect is enabled.
  41823. */
  41824. /**
  41825. * Sets wether the color curves effect is enabled.
  41826. */
  41827. colorCurvesEnabled: boolean;
  41828. /**
  41829. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41830. */
  41831. /**
  41832. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41833. */
  41834. colorGradingTexture: Nullable<BaseTexture>;
  41835. /**
  41836. * Gets wether the color grading effect is enabled.
  41837. */
  41838. /**
  41839. * Gets wether the color grading effect is enabled.
  41840. */
  41841. colorGradingEnabled: boolean;
  41842. /**
  41843. * Gets exposure used in the effect.
  41844. */
  41845. /**
  41846. * Sets exposure used in the effect.
  41847. */
  41848. exposure: number;
  41849. /**
  41850. * Gets wether tonemapping is enabled or not.
  41851. */
  41852. /**
  41853. * Sets wether tonemapping is enabled or not
  41854. */
  41855. toneMappingEnabled: boolean;
  41856. /**
  41857. * Gets the type of tone mapping effect.
  41858. */
  41859. /**
  41860. * Sets the type of tone mapping effect.
  41861. */
  41862. toneMappingType: number;
  41863. /**
  41864. * Gets contrast used in the effect.
  41865. */
  41866. /**
  41867. * Sets contrast used in the effect.
  41868. */
  41869. contrast: number;
  41870. /**
  41871. * Gets Vignette stretch size.
  41872. */
  41873. /**
  41874. * Sets Vignette stretch size.
  41875. */
  41876. vignetteStretch: number;
  41877. /**
  41878. * Gets Vignette centre X Offset.
  41879. */
  41880. /**
  41881. * Sets Vignette centre X Offset.
  41882. */
  41883. vignetteCentreX: number;
  41884. /**
  41885. * Gets Vignette centre Y Offset.
  41886. */
  41887. /**
  41888. * Sets Vignette centre Y Offset.
  41889. */
  41890. vignetteCentreY: number;
  41891. /**
  41892. * Gets Vignette weight or intensity of the vignette effect.
  41893. */
  41894. /**
  41895. * Sets Vignette weight or intensity of the vignette effect.
  41896. */
  41897. vignetteWeight: number;
  41898. /**
  41899. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41900. * if vignetteEnabled is set to true.
  41901. */
  41902. /**
  41903. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41904. * if vignetteEnabled is set to true.
  41905. */
  41906. vignetteColor: Color4;
  41907. /**
  41908. * Gets Camera field of view used by the Vignette effect.
  41909. */
  41910. /**
  41911. * Sets Camera field of view used by the Vignette effect.
  41912. */
  41913. vignetteCameraFov: number;
  41914. /**
  41915. * Gets the vignette blend mode allowing different kind of effect.
  41916. */
  41917. /**
  41918. * Sets the vignette blend mode allowing different kind of effect.
  41919. */
  41920. vignetteBlendMode: number;
  41921. /**
  41922. * Gets wether the vignette effect is enabled.
  41923. */
  41924. /**
  41925. * Sets wether the vignette effect is enabled.
  41926. */
  41927. vignetteEnabled: boolean;
  41928. private _fromLinearSpace;
  41929. /**
  41930. * Gets wether the input of the processing is in Gamma or Linear Space.
  41931. */
  41932. /**
  41933. * Sets wether the input of the processing is in Gamma or Linear Space.
  41934. */
  41935. fromLinearSpace: boolean;
  41936. /**
  41937. * Defines cache preventing GC.
  41938. */
  41939. private _defines;
  41940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41941. /**
  41942. * "ImageProcessingPostProcess"
  41943. * @returns "ImageProcessingPostProcess"
  41944. */
  41945. getClassName(): string;
  41946. protected _updateParameters(): void;
  41947. dispose(camera?: Camera): void;
  41948. }
  41949. }
  41950. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41951. import { Scene } from "babylonjs/scene";
  41952. import { Color3 } from "babylonjs/Maths/math.color";
  41953. import { Mesh } from "babylonjs/Meshes/mesh";
  41954. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41955. import { Nullable } from "babylonjs/types";
  41956. /**
  41957. * Class containing static functions to help procedurally build meshes
  41958. */
  41959. export class GroundBuilder {
  41960. /**
  41961. * Creates a ground mesh
  41962. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41963. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41965. * @param name defines the name of the mesh
  41966. * @param options defines the options used to create the mesh
  41967. * @param scene defines the hosting scene
  41968. * @returns the ground mesh
  41969. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41970. */
  41971. static CreateGround(name: string, options: {
  41972. width?: number;
  41973. height?: number;
  41974. subdivisions?: number;
  41975. subdivisionsX?: number;
  41976. subdivisionsY?: number;
  41977. updatable?: boolean;
  41978. }, scene: any): Mesh;
  41979. /**
  41980. * Creates a tiled ground mesh
  41981. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41982. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41983. * * 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
  41984. * * 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
  41985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41986. * @param name defines the name of the mesh
  41987. * @param options defines the options used to create the mesh
  41988. * @param scene defines the hosting scene
  41989. * @returns the tiled ground mesh
  41990. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41991. */
  41992. static CreateTiledGround(name: string, options: {
  41993. xmin: number;
  41994. zmin: number;
  41995. xmax: number;
  41996. zmax: number;
  41997. subdivisions?: {
  41998. w: number;
  41999. h: number;
  42000. };
  42001. precision?: {
  42002. w: number;
  42003. h: number;
  42004. };
  42005. updatable?: boolean;
  42006. }, scene?: Nullable<Scene>): Mesh;
  42007. /**
  42008. * Creates a ground mesh from a height map
  42009. * * The parameter `url` sets the URL of the height map image resource.
  42010. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42011. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42012. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42013. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42014. * * 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.
  42015. * * 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).
  42016. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42018. * @param name defines the name of the mesh
  42019. * @param url defines the url to the height map
  42020. * @param options defines the options used to create the mesh
  42021. * @param scene defines the hosting scene
  42022. * @returns the ground mesh
  42023. * @see https://doc.babylonjs.com/babylon101/height_map
  42024. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42025. */
  42026. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42027. width?: number;
  42028. height?: number;
  42029. subdivisions?: number;
  42030. minHeight?: number;
  42031. maxHeight?: number;
  42032. colorFilter?: Color3;
  42033. alphaFilter?: number;
  42034. updatable?: boolean;
  42035. onReady?: (mesh: GroundMesh) => void;
  42036. }, scene?: Nullable<Scene>): GroundMesh;
  42037. }
  42038. }
  42039. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42040. import { Vector4 } from "babylonjs/Maths/math.vector";
  42041. import { Mesh } from "babylonjs/Meshes/mesh";
  42042. /**
  42043. * Class containing static functions to help procedurally build meshes
  42044. */
  42045. export class TorusBuilder {
  42046. /**
  42047. * Creates a torus mesh
  42048. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42049. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42050. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42054. * @param name defines the name of the mesh
  42055. * @param options defines the options used to create the mesh
  42056. * @param scene defines the hosting scene
  42057. * @returns the torus mesh
  42058. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42059. */
  42060. static CreateTorus(name: string, options: {
  42061. diameter?: number;
  42062. thickness?: number;
  42063. tessellation?: number;
  42064. updatable?: boolean;
  42065. sideOrientation?: number;
  42066. frontUVs?: Vector4;
  42067. backUVs?: Vector4;
  42068. }, scene: any): Mesh;
  42069. }
  42070. }
  42071. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42072. import { Vector4 } from "babylonjs/Maths/math.vector";
  42073. import { Color4 } from "babylonjs/Maths/math.color";
  42074. import { Mesh } from "babylonjs/Meshes/mesh";
  42075. /**
  42076. * Class containing static functions to help procedurally build meshes
  42077. */
  42078. export class CylinderBuilder {
  42079. /**
  42080. * Creates a cylinder or a cone mesh
  42081. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42082. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42083. * * 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.
  42084. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42085. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42086. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42087. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42088. * * 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).
  42089. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42090. * * 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).
  42091. * * 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
  42092. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42093. * * 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
  42094. * * 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.
  42095. * * If `enclose` is false, a ring surface is one element.
  42096. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42097. * * 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
  42098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42101. * @param name defines the name of the mesh
  42102. * @param options defines the options used to create the mesh
  42103. * @param scene defines the hosting scene
  42104. * @returns the cylinder mesh
  42105. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42106. */
  42107. static CreateCylinder(name: string, options: {
  42108. height?: number;
  42109. diameterTop?: number;
  42110. diameterBottom?: number;
  42111. diameter?: number;
  42112. tessellation?: number;
  42113. subdivisions?: number;
  42114. arc?: number;
  42115. faceColors?: Color4[];
  42116. faceUV?: Vector4[];
  42117. updatable?: boolean;
  42118. hasRings?: boolean;
  42119. enclose?: boolean;
  42120. cap?: number;
  42121. sideOrientation?: number;
  42122. frontUVs?: Vector4;
  42123. backUVs?: Vector4;
  42124. }, scene: any): Mesh;
  42125. }
  42126. }
  42127. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42128. import { Observable } from "babylonjs/Misc/observable";
  42129. import { Nullable } from "babylonjs/types";
  42130. import { Camera } from "babylonjs/Cameras/camera";
  42131. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42132. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42133. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42134. import { Scene } from "babylonjs/scene";
  42135. import { Vector3 } from "babylonjs/Maths/math.vector";
  42136. import { Color3 } from "babylonjs/Maths/math.color";
  42137. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42139. import { Mesh } from "babylonjs/Meshes/mesh";
  42140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42141. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42142. import "babylonjs/Meshes/Builders/groundBuilder";
  42143. import "babylonjs/Meshes/Builders/torusBuilder";
  42144. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42145. import "babylonjs/Gamepads/gamepadSceneComponent";
  42146. import "babylonjs/Animations/animatable";
  42147. /**
  42148. * Options to modify the vr teleportation behavior.
  42149. */
  42150. export interface VRTeleportationOptions {
  42151. /**
  42152. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42153. */
  42154. floorMeshName?: string;
  42155. /**
  42156. * A list of meshes to be used as the teleportation floor. (default: empty)
  42157. */
  42158. floorMeshes?: Mesh[];
  42159. }
  42160. /**
  42161. * Options to modify the vr experience helper's behavior.
  42162. */
  42163. export interface VRExperienceHelperOptions extends WebVROptions {
  42164. /**
  42165. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42166. */
  42167. createDeviceOrientationCamera?: boolean;
  42168. /**
  42169. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42170. */
  42171. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42172. /**
  42173. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42174. */
  42175. laserToggle?: boolean;
  42176. /**
  42177. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42178. */
  42179. floorMeshes?: Mesh[];
  42180. /**
  42181. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42182. */
  42183. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42184. }
  42185. /**
  42186. * Event containing information after VR has been entered
  42187. */
  42188. export class OnAfterEnteringVRObservableEvent {
  42189. /**
  42190. * If entering vr was successful
  42191. */
  42192. success: boolean;
  42193. }
  42194. /**
  42195. * Helps to quickly add VR support to an existing scene.
  42196. * See http://doc.babylonjs.com/how_to/webvr_helper
  42197. */
  42198. export class VRExperienceHelper {
  42199. /** Options to modify the vr experience helper's behavior. */
  42200. webVROptions: VRExperienceHelperOptions;
  42201. private _scene;
  42202. private _position;
  42203. private _btnVR;
  42204. private _btnVRDisplayed;
  42205. private _webVRsupported;
  42206. private _webVRready;
  42207. private _webVRrequesting;
  42208. private _webVRpresenting;
  42209. private _hasEnteredVR;
  42210. private _fullscreenVRpresenting;
  42211. private _canvas;
  42212. private _webVRCamera;
  42213. private _vrDeviceOrientationCamera;
  42214. private _deviceOrientationCamera;
  42215. private _existingCamera;
  42216. private _onKeyDown;
  42217. private _onVrDisplayPresentChange;
  42218. private _onVRDisplayChanged;
  42219. private _onVRRequestPresentStart;
  42220. private _onVRRequestPresentComplete;
  42221. /**
  42222. * 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)
  42223. */
  42224. enableGazeEvenWhenNoPointerLock: boolean;
  42225. /**
  42226. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42227. */
  42228. exitVROnDoubleTap: boolean;
  42229. /**
  42230. * Observable raised right before entering VR.
  42231. */
  42232. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42233. /**
  42234. * Observable raised when entering VR has completed.
  42235. */
  42236. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42237. /**
  42238. * Observable raised when exiting VR.
  42239. */
  42240. onExitingVRObservable: Observable<VRExperienceHelper>;
  42241. /**
  42242. * Observable raised when controller mesh is loaded.
  42243. */
  42244. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42245. /** Return this.onEnteringVRObservable
  42246. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42247. */
  42248. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42249. /** Return this.onExitingVRObservable
  42250. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42251. */
  42252. readonly onExitingVR: Observable<VRExperienceHelper>;
  42253. /** Return this.onControllerMeshLoadedObservable
  42254. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42255. */
  42256. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42257. private _rayLength;
  42258. private _useCustomVRButton;
  42259. private _teleportationRequested;
  42260. private _teleportActive;
  42261. private _floorMeshName;
  42262. private _floorMeshesCollection;
  42263. private _rotationAllowed;
  42264. private _teleportBackwardsVector;
  42265. private _teleportationTarget;
  42266. private _isDefaultTeleportationTarget;
  42267. private _postProcessMove;
  42268. private _teleportationFillColor;
  42269. private _teleportationBorderColor;
  42270. private _rotationAngle;
  42271. private _haloCenter;
  42272. private _cameraGazer;
  42273. private _padSensibilityUp;
  42274. private _padSensibilityDown;
  42275. private _leftController;
  42276. private _rightController;
  42277. /**
  42278. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42279. */
  42280. onNewMeshSelected: Observable<AbstractMesh>;
  42281. /**
  42282. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42283. */
  42284. onNewMeshPicked: Observable<PickingInfo>;
  42285. private _circleEase;
  42286. /**
  42287. * Observable raised before camera teleportation
  42288. */
  42289. onBeforeCameraTeleport: Observable<Vector3>;
  42290. /**
  42291. * Observable raised after camera teleportation
  42292. */
  42293. onAfterCameraTeleport: Observable<Vector3>;
  42294. /**
  42295. * Observable raised when current selected mesh gets unselected
  42296. */
  42297. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42298. private _raySelectionPredicate;
  42299. /**
  42300. * To be optionaly changed by user to define custom ray selection
  42301. */
  42302. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42303. /**
  42304. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42305. */
  42306. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42307. /**
  42308. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42309. */
  42310. teleportationEnabled: boolean;
  42311. private _defaultHeight;
  42312. private _teleportationInitialized;
  42313. private _interactionsEnabled;
  42314. private _interactionsRequested;
  42315. private _displayGaze;
  42316. private _displayLaserPointer;
  42317. /**
  42318. * The mesh used to display where the user is going to teleport.
  42319. */
  42320. /**
  42321. * Sets the mesh to be used to display where the user is going to teleport.
  42322. */
  42323. teleportationTarget: Mesh;
  42324. /**
  42325. * 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
  42326. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42327. * See http://doc.babylonjs.com/resources/baking_transformations
  42328. */
  42329. gazeTrackerMesh: Mesh;
  42330. /**
  42331. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42332. */
  42333. updateGazeTrackerScale: boolean;
  42334. /**
  42335. * If the gaze trackers color should be updated when selecting meshes
  42336. */
  42337. updateGazeTrackerColor: boolean;
  42338. /**
  42339. * The gaze tracking mesh corresponding to the left controller
  42340. */
  42341. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42342. /**
  42343. * The gaze tracking mesh corresponding to the right controller
  42344. */
  42345. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42346. /**
  42347. * If the ray of the gaze should be displayed.
  42348. */
  42349. /**
  42350. * Sets if the ray of the gaze should be displayed.
  42351. */
  42352. displayGaze: boolean;
  42353. /**
  42354. * If the ray of the LaserPointer should be displayed.
  42355. */
  42356. /**
  42357. * Sets if the ray of the LaserPointer should be displayed.
  42358. */
  42359. displayLaserPointer: boolean;
  42360. /**
  42361. * The deviceOrientationCamera used as the camera when not in VR.
  42362. */
  42363. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42364. /**
  42365. * Based on the current WebVR support, returns the current VR camera used.
  42366. */
  42367. readonly currentVRCamera: Nullable<Camera>;
  42368. /**
  42369. * The webVRCamera which is used when in VR.
  42370. */
  42371. readonly webVRCamera: WebVRFreeCamera;
  42372. /**
  42373. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42374. */
  42375. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42376. /**
  42377. * The html button that is used to trigger entering into VR.
  42378. */
  42379. readonly vrButton: Nullable<HTMLButtonElement>;
  42380. private readonly _teleportationRequestInitiated;
  42381. /**
  42382. * Defines wether or not Pointer lock should be requested when switching to
  42383. * full screen.
  42384. */
  42385. requestPointerLockOnFullScreen: boolean;
  42386. /**
  42387. * Instantiates a VRExperienceHelper.
  42388. * Helps to quickly add VR support to an existing scene.
  42389. * @param scene The scene the VRExperienceHelper belongs to.
  42390. * @param webVROptions Options to modify the vr experience helper's behavior.
  42391. */
  42392. constructor(scene: Scene,
  42393. /** Options to modify the vr experience helper's behavior. */
  42394. webVROptions?: VRExperienceHelperOptions);
  42395. private _onDefaultMeshLoaded;
  42396. private _onResize;
  42397. private _onFullscreenChange;
  42398. /**
  42399. * Gets a value indicating if we are currently in VR mode.
  42400. */
  42401. readonly isInVRMode: boolean;
  42402. private onVrDisplayPresentChange;
  42403. private onVRDisplayChanged;
  42404. private moveButtonToBottomRight;
  42405. private displayVRButton;
  42406. private updateButtonVisibility;
  42407. private _cachedAngularSensibility;
  42408. /**
  42409. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42410. * Otherwise, will use the fullscreen API.
  42411. */
  42412. enterVR(): void;
  42413. /**
  42414. * Attempt to exit VR, or fullscreen.
  42415. */
  42416. exitVR(): void;
  42417. /**
  42418. * The position of the vr experience helper.
  42419. */
  42420. /**
  42421. * Sets the position of the vr experience helper.
  42422. */
  42423. position: Vector3;
  42424. /**
  42425. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42426. */
  42427. enableInteractions(): void;
  42428. private readonly _noControllerIsActive;
  42429. private beforeRender;
  42430. private _isTeleportationFloor;
  42431. /**
  42432. * Adds a floor mesh to be used for teleportation.
  42433. * @param floorMesh the mesh to be used for teleportation.
  42434. */
  42435. addFloorMesh(floorMesh: Mesh): void;
  42436. /**
  42437. * Removes a floor mesh from being used for teleportation.
  42438. * @param floorMesh the mesh to be removed.
  42439. */
  42440. removeFloorMesh(floorMesh: Mesh): void;
  42441. /**
  42442. * Enables interactions and teleportation using the VR controllers and gaze.
  42443. * @param vrTeleportationOptions options to modify teleportation behavior.
  42444. */
  42445. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42446. private _onNewGamepadConnected;
  42447. private _tryEnableInteractionOnController;
  42448. private _onNewGamepadDisconnected;
  42449. private _enableInteractionOnController;
  42450. private _checkTeleportWithRay;
  42451. private _checkRotate;
  42452. private _checkTeleportBackwards;
  42453. private _enableTeleportationOnController;
  42454. private _createTeleportationCircles;
  42455. private _displayTeleportationTarget;
  42456. private _hideTeleportationTarget;
  42457. private _rotateCamera;
  42458. private _moveTeleportationSelectorTo;
  42459. private _workingVector;
  42460. private _workingQuaternion;
  42461. private _workingMatrix;
  42462. /**
  42463. * Teleports the users feet to the desired location
  42464. * @param location The location where the user's feet should be placed
  42465. */
  42466. teleportCamera(location: Vector3): void;
  42467. private _convertNormalToDirectionOfRay;
  42468. private _castRayAndSelectObject;
  42469. private _notifySelectedMeshUnselected;
  42470. /**
  42471. * Sets the color of the laser ray from the vr controllers.
  42472. * @param color new color for the ray.
  42473. */
  42474. changeLaserColor(color: Color3): void;
  42475. /**
  42476. * Sets the color of the ray from the vr headsets gaze.
  42477. * @param color new color for the ray.
  42478. */
  42479. changeGazeColor(color: Color3): void;
  42480. /**
  42481. * Exits VR and disposes of the vr experience helper
  42482. */
  42483. dispose(): void;
  42484. /**
  42485. * Gets the name of the VRExperienceHelper class
  42486. * @returns "VRExperienceHelper"
  42487. */
  42488. getClassName(): string;
  42489. }
  42490. }
  42491. declare module "babylonjs/Cameras/VR/index" {
  42492. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42493. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42494. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42495. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42496. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42497. export * from "babylonjs/Cameras/VR/webVRCamera";
  42498. }
  42499. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42500. import { Observable } from "babylonjs/Misc/observable";
  42501. import { Nullable } from "babylonjs/types";
  42502. import { IDisposable, Scene } from "babylonjs/scene";
  42503. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42504. /**
  42505. * Manages an XRSession to work with Babylon's engine
  42506. * @see https://doc.babylonjs.com/how_to/webxr
  42507. */
  42508. export class WebXRSessionManager implements IDisposable {
  42509. private scene;
  42510. /**
  42511. * Fires every time a new xrFrame arrives which can be used to update the camera
  42512. */
  42513. onXRFrameObservable: Observable<any>;
  42514. /**
  42515. * Fires when the xr session is ended either by the device or manually done
  42516. */
  42517. onXRSessionEnded: Observable<any>;
  42518. /**
  42519. * Underlying xr session
  42520. */
  42521. session: XRSession;
  42522. /**
  42523. * Type of reference space used when creating the session
  42524. */
  42525. referenceSpace: XRReferenceSpace;
  42526. /** @hidden */
  42527. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42528. /**
  42529. * Current XR frame
  42530. */
  42531. currentFrame: Nullable<XRFrame>;
  42532. private _xrNavigator;
  42533. private baseLayer;
  42534. /**
  42535. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42536. * @param scene The scene which the session should be created for
  42537. */
  42538. constructor(scene: Scene);
  42539. /**
  42540. * Initializes the manager
  42541. * After initialization enterXR can be called to start an XR session
  42542. * @returns Promise which resolves after it is initialized
  42543. */
  42544. initializeAsync(): Promise<void>;
  42545. /**
  42546. * Initializes an xr session
  42547. * @param xrSessionMode mode to initialize
  42548. * @returns a promise which will resolve once the session has been initialized
  42549. */
  42550. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42551. /**
  42552. * Sets the reference space on the xr session
  42553. * @param referenceSpace space to set
  42554. * @returns a promise that will resolve once the reference space has been set
  42555. */
  42556. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42557. /**
  42558. * Updates the render state of the session
  42559. * @param state state to set
  42560. * @returns a promise that resolves once the render state has been updated
  42561. */
  42562. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42563. /**
  42564. * Starts rendering to the xr layer
  42565. * @returns a promise that will resolve once rendering has started
  42566. */
  42567. startRenderingToXRAsync(): Promise<void>;
  42568. /**
  42569. * Stops the xrSession and restores the renderloop
  42570. * @returns Promise which resolves after it exits XR
  42571. */
  42572. exitXRAsync(): Promise<unknown>;
  42573. /**
  42574. * Checks if a session would be supported for the creation options specified
  42575. * @param sessionMode session mode to check if supported eg. immersive-vr
  42576. * @returns true if supported
  42577. */
  42578. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42579. /**
  42580. * @hidden
  42581. * Converts the render layer of xrSession to a render target
  42582. * @param session session to create render target for
  42583. * @param scene scene the new render target should be created for
  42584. */
  42585. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42586. /**
  42587. * Disposes of the session manager
  42588. */
  42589. dispose(): void;
  42590. }
  42591. }
  42592. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42593. import { Scene } from "babylonjs/scene";
  42594. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42595. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42596. /**
  42597. * WebXR Camera which holds the views for the xrSession
  42598. * @see https://doc.babylonjs.com/how_to/webxr
  42599. */
  42600. export class WebXRCamera extends FreeCamera {
  42601. private static _TmpMatrix;
  42602. /**
  42603. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42604. * @param name the name of the camera
  42605. * @param scene the scene to add the camera to
  42606. */
  42607. constructor(name: string, scene: Scene);
  42608. private _updateNumberOfRigCameras;
  42609. /** @hidden */
  42610. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42611. /**
  42612. * Updates the cameras position from the current pose information of the XR session
  42613. * @param xrSessionManager the session containing pose information
  42614. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42615. */
  42616. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42617. }
  42618. }
  42619. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42620. import { Nullable } from "babylonjs/types";
  42621. import { IDisposable } from "babylonjs/scene";
  42622. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42623. /**
  42624. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42625. */
  42626. export class WebXRManagedOutputCanvas implements IDisposable {
  42627. private helper;
  42628. private _canvas;
  42629. /**
  42630. * xrpresent context of the canvas which can be used to display/mirror xr content
  42631. */
  42632. canvasContext: WebGLRenderingContext;
  42633. /**
  42634. * xr layer for the canvas
  42635. */
  42636. xrLayer: Nullable<XRWebGLLayer>;
  42637. /**
  42638. * Initializes the xr layer for the session
  42639. * @param xrSession xr session
  42640. * @returns a promise that will resolve once the XR Layer has been created
  42641. */
  42642. initializeXRLayerAsync(xrSession: any): any;
  42643. /**
  42644. * Initializes the canvas to be added/removed upon entering/exiting xr
  42645. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42646. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42647. */
  42648. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42649. /**
  42650. * Disposes of the object
  42651. */
  42652. dispose(): void;
  42653. private _setManagedOutputCanvas;
  42654. private _addCanvas;
  42655. private _removeCanvas;
  42656. }
  42657. }
  42658. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42659. import { Observable } from "babylonjs/Misc/observable";
  42660. import { IDisposable, Scene } from "babylonjs/scene";
  42661. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42663. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42664. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42665. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42666. /**
  42667. * States of the webXR experience
  42668. */
  42669. export enum WebXRState {
  42670. /**
  42671. * Transitioning to being in XR mode
  42672. */
  42673. ENTERING_XR = 0,
  42674. /**
  42675. * Transitioning to non XR mode
  42676. */
  42677. EXITING_XR = 1,
  42678. /**
  42679. * In XR mode and presenting
  42680. */
  42681. IN_XR = 2,
  42682. /**
  42683. * Not entered XR mode
  42684. */
  42685. NOT_IN_XR = 3
  42686. }
  42687. /**
  42688. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42689. * @see https://doc.babylonjs.com/how_to/webxr
  42690. */
  42691. export class WebXRExperienceHelper implements IDisposable {
  42692. private scene;
  42693. /**
  42694. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42695. */
  42696. container: AbstractMesh;
  42697. /**
  42698. * Camera used to render xr content
  42699. */
  42700. camera: WebXRCamera;
  42701. /**
  42702. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42703. */
  42704. state: WebXRState;
  42705. private _setState;
  42706. private static _TmpVector;
  42707. /**
  42708. * Fires when the state of the experience helper has changed
  42709. */
  42710. onStateChangedObservable: Observable<WebXRState>;
  42711. /** Session manager used to keep track of xr session */
  42712. sessionManager: WebXRSessionManager;
  42713. private _nonVRCamera;
  42714. private _originalSceneAutoClear;
  42715. private _supported;
  42716. /**
  42717. * Creates the experience helper
  42718. * @param scene the scene to attach the experience helper to
  42719. * @returns a promise for the experience helper
  42720. */
  42721. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42722. /**
  42723. * Creates a WebXRExperienceHelper
  42724. * @param scene The scene the helper should be created in
  42725. */
  42726. private constructor();
  42727. /**
  42728. * Exits XR mode and returns the scene to its original state
  42729. * @returns promise that resolves after xr mode has exited
  42730. */
  42731. exitXRAsync(): Promise<unknown>;
  42732. /**
  42733. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42734. * @param sessionCreationOptions options for the XR session
  42735. * @param referenceSpaceType frame of reference of the XR session
  42736. * @param outputCanvas the output canvas that will be used to enter XR mode
  42737. * @returns promise that resolves after xr mode has entered
  42738. */
  42739. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42740. /**
  42741. * Updates the global position of the camera by moving the camera's container
  42742. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42743. * @param position The desired global position of the camera
  42744. */
  42745. setPositionOfCameraUsingContainer(position: Vector3): void;
  42746. /**
  42747. * Rotates the xr camera by rotating the camera's container around the camera's position
  42748. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42749. * @param rotation the desired quaternion rotation to apply to the camera
  42750. */
  42751. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42752. /**
  42753. * Disposes of the experience helper
  42754. */
  42755. dispose(): void;
  42756. }
  42757. }
  42758. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42759. import { Nullable } from "babylonjs/types";
  42760. import { Observable } from "babylonjs/Misc/observable";
  42761. import { IDisposable, Scene } from "babylonjs/scene";
  42762. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42763. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42764. /**
  42765. * Button which can be used to enter a different mode of XR
  42766. */
  42767. export class WebXREnterExitUIButton {
  42768. /** button element */
  42769. element: HTMLElement;
  42770. /** XR initialization options for the button */
  42771. sessionMode: XRSessionMode;
  42772. /** Reference space type */
  42773. referenceSpaceType: XRReferenceSpaceType;
  42774. /**
  42775. * Creates a WebXREnterExitUIButton
  42776. * @param element button element
  42777. * @param sessionMode XR initialization session mode
  42778. * @param referenceSpaceType the type of reference space to be used
  42779. */
  42780. constructor(
  42781. /** button element */
  42782. element: HTMLElement,
  42783. /** XR initialization options for the button */
  42784. sessionMode: XRSessionMode,
  42785. /** Reference space type */
  42786. referenceSpaceType: XRReferenceSpaceType);
  42787. /**
  42788. * Overwritable function which can be used to update the button's visuals when the state changes
  42789. * @param activeButton the current active button in the UI
  42790. */
  42791. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42792. }
  42793. /**
  42794. * Options to create the webXR UI
  42795. */
  42796. export class WebXREnterExitUIOptions {
  42797. /**
  42798. * Context to enter xr with
  42799. */
  42800. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42801. /**
  42802. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42803. */
  42804. customButtons?: Array<WebXREnterExitUIButton>;
  42805. }
  42806. /**
  42807. * UI to allow the user to enter/exit XR mode
  42808. */
  42809. export class WebXREnterExitUI implements IDisposable {
  42810. private scene;
  42811. private _overlay;
  42812. private _buttons;
  42813. private _activeButton;
  42814. /**
  42815. * Fired every time the active button is changed.
  42816. *
  42817. * When xr is entered via a button that launches xr that button will be the callback parameter
  42818. *
  42819. * When exiting xr the callback parameter will be null)
  42820. */
  42821. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42822. /**
  42823. * Creates UI to allow the user to enter/exit XR mode
  42824. * @param scene the scene to add the ui to
  42825. * @param helper the xr experience helper to enter/exit xr with
  42826. * @param options options to configure the UI
  42827. * @returns the created ui
  42828. */
  42829. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42830. private constructor();
  42831. private _updateButtons;
  42832. /**
  42833. * Disposes of the object
  42834. */
  42835. dispose(): void;
  42836. }
  42837. }
  42838. declare module "babylonjs/Cameras/XR/webXRController" {
  42839. import { Nullable } from "babylonjs/types";
  42840. import { Observable } from "babylonjs/Misc/observable";
  42841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42842. import { Ray } from "babylonjs/Culling/ray";
  42843. import { Scene } from "babylonjs/scene";
  42844. /**
  42845. * Represents an XR input
  42846. */
  42847. export class WebXRController {
  42848. private scene;
  42849. /** The underlying input source for the controller */
  42850. inputSource: XRInputSource;
  42851. private parentContainer;
  42852. /**
  42853. * 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
  42854. */
  42855. grip?: AbstractMesh;
  42856. /**
  42857. * Pointer which can be used to select objects or attach a visible laser to
  42858. */
  42859. pointer: AbstractMesh;
  42860. /**
  42861. * Event that fires when the controller is removed/disposed
  42862. */
  42863. onDisposeObservable: Observable<{}>;
  42864. private _tmpMatrix;
  42865. private _tmpQuaternion;
  42866. private _tmpVector;
  42867. /**
  42868. * Creates the controller
  42869. * @see https://doc.babylonjs.com/how_to/webxr
  42870. * @param scene the scene which the controller should be associated to
  42871. * @param inputSource the underlying input source for the controller
  42872. * @param parentContainer parent that the controller meshes should be children of
  42873. */
  42874. constructor(scene: Scene,
  42875. /** The underlying input source for the controller */
  42876. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42877. /**
  42878. * Updates the controller pose based on the given XRFrame
  42879. * @param xrFrame xr frame to update the pose with
  42880. * @param referenceSpace reference space to use
  42881. */
  42882. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42883. /**
  42884. * Gets a world space ray coming from the controller
  42885. * @param result the resulting ray
  42886. */
  42887. getWorldPointerRayToRef(result: Ray): void;
  42888. /**
  42889. * Disposes of the object
  42890. */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module "babylonjs/Cameras/XR/webXRInput" {
  42895. import { Observable } from "babylonjs/Misc/observable";
  42896. import { IDisposable } from "babylonjs/scene";
  42897. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42898. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42899. /**
  42900. * XR input used to track XR inputs such as controllers/rays
  42901. */
  42902. export class WebXRInput implements IDisposable {
  42903. /**
  42904. * Base experience the input listens to
  42905. */
  42906. baseExperience: WebXRExperienceHelper;
  42907. /**
  42908. * XR controllers being tracked
  42909. */
  42910. controllers: Array<WebXRController>;
  42911. private _frameObserver;
  42912. private _stateObserver;
  42913. /**
  42914. * Event when a controller has been connected/added
  42915. */
  42916. onControllerAddedObservable: Observable<WebXRController>;
  42917. /**
  42918. * Event when a controller has been removed/disconnected
  42919. */
  42920. onControllerRemovedObservable: Observable<WebXRController>;
  42921. /**
  42922. * Initializes the WebXRInput
  42923. * @param baseExperience experience helper which the input should be created for
  42924. */
  42925. constructor(
  42926. /**
  42927. * Base experience the input listens to
  42928. */
  42929. baseExperience: WebXRExperienceHelper);
  42930. private _onInputSourcesChange;
  42931. private _addAndRemoveControllers;
  42932. /**
  42933. * Disposes of the object
  42934. */
  42935. dispose(): void;
  42936. }
  42937. }
  42938. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42940. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42941. /**
  42942. * Enables teleportation
  42943. */
  42944. export class WebXRControllerTeleportation {
  42945. private _teleportationFillColor;
  42946. private _teleportationBorderColor;
  42947. private _tmpRay;
  42948. private _tmpVector;
  42949. /**
  42950. * Creates a WebXRControllerTeleportation
  42951. * @param input input manager to add teleportation to
  42952. * @param floorMeshes floormeshes which can be teleported to
  42953. */
  42954. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42955. }
  42956. }
  42957. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42958. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42959. /**
  42960. * Handles pointer input automatically for the pointer of XR controllers
  42961. */
  42962. export class WebXRControllerPointerSelection {
  42963. private static _idCounter;
  42964. private _tmpRay;
  42965. /**
  42966. * Creates a WebXRControllerPointerSelection
  42967. * @param input input manager to setup pointer selection
  42968. */
  42969. constructor(input: WebXRInput);
  42970. private _convertNormalToDirectionOfRay;
  42971. private _updatePointerDistance;
  42972. }
  42973. }
  42974. declare module "babylonjs/Loading/sceneLoader" {
  42975. import { Observable } from "babylonjs/Misc/observable";
  42976. import { Nullable } from "babylonjs/types";
  42977. import { Scene } from "babylonjs/scene";
  42978. import { Engine } from "babylonjs/Engines/engine";
  42979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42980. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42981. import { AssetContainer } from "babylonjs/assetContainer";
  42982. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42983. import { Skeleton } from "babylonjs/Bones/skeleton";
  42984. /**
  42985. * Class used to represent data loading progression
  42986. */
  42987. export class SceneLoaderProgressEvent {
  42988. /** defines if data length to load can be evaluated */
  42989. readonly lengthComputable: boolean;
  42990. /** defines the loaded data length */
  42991. readonly loaded: number;
  42992. /** defines the data length to load */
  42993. readonly total: number;
  42994. /**
  42995. * Create a new progress event
  42996. * @param lengthComputable defines if data length to load can be evaluated
  42997. * @param loaded defines the loaded data length
  42998. * @param total defines the data length to load
  42999. */
  43000. constructor(
  43001. /** defines if data length to load can be evaluated */
  43002. lengthComputable: boolean,
  43003. /** defines the loaded data length */
  43004. loaded: number,
  43005. /** defines the data length to load */
  43006. total: number);
  43007. /**
  43008. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43009. * @param event defines the source event
  43010. * @returns a new SceneLoaderProgressEvent
  43011. */
  43012. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43013. }
  43014. /**
  43015. * Interface used by SceneLoader plugins to define supported file extensions
  43016. */
  43017. export interface ISceneLoaderPluginExtensions {
  43018. /**
  43019. * Defines the list of supported extensions
  43020. */
  43021. [extension: string]: {
  43022. isBinary: boolean;
  43023. };
  43024. }
  43025. /**
  43026. * Interface used by SceneLoader plugin factory
  43027. */
  43028. export interface ISceneLoaderPluginFactory {
  43029. /**
  43030. * Defines the name of the factory
  43031. */
  43032. name: string;
  43033. /**
  43034. * Function called to create a new plugin
  43035. * @return the new plugin
  43036. */
  43037. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43038. /**
  43039. * Boolean indicating if the plugin can direct load specific data
  43040. */
  43041. canDirectLoad?: (data: string) => boolean;
  43042. }
  43043. /**
  43044. * Interface used to define a SceneLoader plugin
  43045. */
  43046. export interface ISceneLoaderPlugin {
  43047. /**
  43048. * The friendly name of this plugin.
  43049. */
  43050. name: string;
  43051. /**
  43052. * The file extensions supported by this plugin.
  43053. */
  43054. extensions: string | ISceneLoaderPluginExtensions;
  43055. /**
  43056. * Import meshes into a scene.
  43057. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43058. * @param scene The scene to import into
  43059. * @param data The data to import
  43060. * @param rootUrl The root url for scene and resources
  43061. * @param meshes The meshes array to import into
  43062. * @param particleSystems The particle systems array to import into
  43063. * @param skeletons The skeletons array to import into
  43064. * @param onError The callback when import fails
  43065. * @returns True if successful or false otherwise
  43066. */
  43067. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43068. /**
  43069. * Load into a scene.
  43070. * @param scene The scene to load into
  43071. * @param data The data to import
  43072. * @param rootUrl The root url for scene and resources
  43073. * @param onError The callback when import fails
  43074. * @returns true if successful or false otherwise
  43075. */
  43076. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43077. /**
  43078. * The callback that returns true if the data can be directly loaded.
  43079. */
  43080. canDirectLoad?: (data: string) => boolean;
  43081. /**
  43082. * The callback that allows custom handling of the root url based on the response url.
  43083. */
  43084. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43085. /**
  43086. * Load into an asset container.
  43087. * @param scene The scene to load into
  43088. * @param data The data to import
  43089. * @param rootUrl The root url for scene and resources
  43090. * @param onError The callback when import fails
  43091. * @returns The loaded asset container
  43092. */
  43093. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43094. }
  43095. /**
  43096. * Interface used to define an async SceneLoader plugin
  43097. */
  43098. export interface ISceneLoaderPluginAsync {
  43099. /**
  43100. * The friendly name of this plugin.
  43101. */
  43102. name: string;
  43103. /**
  43104. * The file extensions supported by this plugin.
  43105. */
  43106. extensions: string | ISceneLoaderPluginExtensions;
  43107. /**
  43108. * Import meshes into a scene.
  43109. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43110. * @param scene The scene to import into
  43111. * @param data The data to import
  43112. * @param rootUrl The root url for scene and resources
  43113. * @param onProgress The callback when the load progresses
  43114. * @param fileName Defines the name of the file to load
  43115. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43116. */
  43117. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43118. meshes: AbstractMesh[];
  43119. particleSystems: IParticleSystem[];
  43120. skeletons: Skeleton[];
  43121. animationGroups: AnimationGroup[];
  43122. }>;
  43123. /**
  43124. * Load into a scene.
  43125. * @param scene The scene to load into
  43126. * @param data The data to import
  43127. * @param rootUrl The root url for scene and resources
  43128. * @param onProgress The callback when the load progresses
  43129. * @param fileName Defines the name of the file to load
  43130. * @returns Nothing
  43131. */
  43132. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43133. /**
  43134. * The callback that returns true if the data can be directly loaded.
  43135. */
  43136. canDirectLoad?: (data: string) => boolean;
  43137. /**
  43138. * The callback that allows custom handling of the root url based on the response url.
  43139. */
  43140. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43141. /**
  43142. * Load into an asset container.
  43143. * @param scene The scene to load into
  43144. * @param data The data to import
  43145. * @param rootUrl The root url for scene and resources
  43146. * @param onProgress The callback when the load progresses
  43147. * @param fileName Defines the name of the file to load
  43148. * @returns The loaded asset container
  43149. */
  43150. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43151. }
  43152. /**
  43153. * Class used to load scene from various file formats using registered plugins
  43154. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43155. */
  43156. export class SceneLoader {
  43157. /**
  43158. * No logging while loading
  43159. */
  43160. static readonly NO_LOGGING: number;
  43161. /**
  43162. * Minimal logging while loading
  43163. */
  43164. static readonly MINIMAL_LOGGING: number;
  43165. /**
  43166. * Summary logging while loading
  43167. */
  43168. static readonly SUMMARY_LOGGING: number;
  43169. /**
  43170. * Detailled logging while loading
  43171. */
  43172. static readonly DETAILED_LOGGING: number;
  43173. /**
  43174. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43175. */
  43176. static ForceFullSceneLoadingForIncremental: boolean;
  43177. /**
  43178. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43179. */
  43180. static ShowLoadingScreen: boolean;
  43181. /**
  43182. * Defines the current logging level (while loading the scene)
  43183. * @ignorenaming
  43184. */
  43185. static loggingLevel: number;
  43186. /**
  43187. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43188. */
  43189. static CleanBoneMatrixWeights: boolean;
  43190. /**
  43191. * Event raised when a plugin is used to load a scene
  43192. */
  43193. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43194. private static _registeredPlugins;
  43195. private static _getDefaultPlugin;
  43196. private static _getPluginForExtension;
  43197. private static _getPluginForDirectLoad;
  43198. private static _getPluginForFilename;
  43199. private static _getDirectLoad;
  43200. private static _loadData;
  43201. private static _getFileInfo;
  43202. /**
  43203. * Gets a plugin that can load the given extension
  43204. * @param extension defines the extension to load
  43205. * @returns a plugin or null if none works
  43206. */
  43207. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43208. /**
  43209. * Gets a boolean indicating that the given extension can be loaded
  43210. * @param extension defines the extension to load
  43211. * @returns true if the extension is supported
  43212. */
  43213. static IsPluginForExtensionAvailable(extension: string): boolean;
  43214. /**
  43215. * Adds a new plugin to the list of registered plugins
  43216. * @param plugin defines the plugin to add
  43217. */
  43218. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43219. /**
  43220. * Import meshes into a scene
  43221. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43222. * @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)
  43223. * @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)
  43224. * @param scene the instance of BABYLON.Scene to append to
  43225. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43226. * @param onProgress a callback with a progress event for each file being loaded
  43227. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43228. * @param pluginExtension the extension used to determine the plugin
  43229. * @returns The loaded plugin
  43230. */
  43231. 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>;
  43232. /**
  43233. * Import meshes into a scene
  43234. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43235. * @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)
  43236. * @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)
  43237. * @param scene the instance of BABYLON.Scene to append to
  43238. * @param onProgress a callback with a progress event for each file being loaded
  43239. * @param pluginExtension the extension used to determine the plugin
  43240. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43241. */
  43242. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43243. meshes: AbstractMesh[];
  43244. particleSystems: IParticleSystem[];
  43245. skeletons: Skeleton[];
  43246. animationGroups: AnimationGroup[];
  43247. }>;
  43248. /**
  43249. * Load a scene
  43250. * @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)
  43251. * @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)
  43252. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43253. * @param onSuccess a callback with the scene when import succeeds
  43254. * @param onProgress a callback with a progress event for each file being loaded
  43255. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43256. * @param pluginExtension the extension used to determine the plugin
  43257. * @returns The loaded plugin
  43258. */
  43259. 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>;
  43260. /**
  43261. * Load a scene
  43262. * @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)
  43263. * @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)
  43264. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43265. * @param onProgress a callback with a progress event for each file being loaded
  43266. * @param pluginExtension the extension used to determine the plugin
  43267. * @returns The loaded scene
  43268. */
  43269. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43270. /**
  43271. * Append a scene
  43272. * @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)
  43273. * @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)
  43274. * @param scene is the instance of BABYLON.Scene to append to
  43275. * @param onSuccess a callback with the scene when import succeeds
  43276. * @param onProgress a callback with a progress event for each file being loaded
  43277. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43278. * @param pluginExtension the extension used to determine the plugin
  43279. * @returns The loaded plugin
  43280. */
  43281. 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>;
  43282. /**
  43283. * Append a scene
  43284. * @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)
  43285. * @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)
  43286. * @param scene is the instance of BABYLON.Scene to append to
  43287. * @param onProgress a callback with a progress event for each file being loaded
  43288. * @param pluginExtension the extension used to determine the plugin
  43289. * @returns The given scene
  43290. */
  43291. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43292. /**
  43293. * Load a scene into an asset container
  43294. * @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)
  43295. * @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)
  43296. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43297. * @param onSuccess a callback with the scene when import succeeds
  43298. * @param onProgress a callback with a progress event for each file being loaded
  43299. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43300. * @param pluginExtension the extension used to determine the plugin
  43301. * @returns The loaded plugin
  43302. */
  43303. 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>;
  43304. /**
  43305. * Load a scene into an asset container
  43306. * @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)
  43307. * @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)
  43308. * @param scene is the instance of Scene to append to
  43309. * @param onProgress a callback with a progress event for each file being loaded
  43310. * @param pluginExtension the extension used to determine the plugin
  43311. * @returns The loaded asset container
  43312. */
  43313. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43314. }
  43315. }
  43316. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43317. import { Scene } from "babylonjs/scene";
  43318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43319. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43320. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43321. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43322. /**
  43323. * Generic Controller
  43324. */
  43325. export class GenericController extends WebVRController {
  43326. /**
  43327. * Base Url for the controller model.
  43328. */
  43329. static readonly MODEL_BASE_URL: string;
  43330. /**
  43331. * File name for the controller model.
  43332. */
  43333. static readonly MODEL_FILENAME: string;
  43334. /**
  43335. * Creates a new GenericController from a gamepad
  43336. * @param vrGamepad the gamepad that the controller should be created from
  43337. */
  43338. constructor(vrGamepad: any);
  43339. /**
  43340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43341. * @param scene scene in which to add meshes
  43342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43343. */
  43344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43345. /**
  43346. * Called once for each button that changed state since the last frame
  43347. * @param buttonIdx Which button index changed
  43348. * @param state New state of the button
  43349. * @param changes Which properties on the state changed since last frame
  43350. */
  43351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43355. import { Observable } from "babylonjs/Misc/observable";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import { Ray } from "babylonjs/Culling/ray";
  43359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43361. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43362. /**
  43363. * Defines the WindowsMotionController object that the state of the windows motion controller
  43364. */
  43365. export class WindowsMotionController extends WebVRController {
  43366. /**
  43367. * The base url used to load the left and right controller models
  43368. */
  43369. static MODEL_BASE_URL: string;
  43370. /**
  43371. * The name of the left controller model file
  43372. */
  43373. static MODEL_LEFT_FILENAME: string;
  43374. /**
  43375. * The name of the right controller model file
  43376. */
  43377. static MODEL_RIGHT_FILENAME: string;
  43378. /**
  43379. * The controller name prefix for this controller type
  43380. */
  43381. static readonly GAMEPAD_ID_PREFIX: string;
  43382. /**
  43383. * The controller id pattern for this controller type
  43384. */
  43385. private static readonly GAMEPAD_ID_PATTERN;
  43386. private _loadedMeshInfo;
  43387. private readonly _mapping;
  43388. /**
  43389. * Fired when the trackpad on this controller is clicked
  43390. */
  43391. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43392. /**
  43393. * Fired when the trackpad on this controller is modified
  43394. */
  43395. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43396. /**
  43397. * The current x and y values of this controller's trackpad
  43398. */
  43399. trackpad: StickValues;
  43400. /**
  43401. * Creates a new WindowsMotionController from a gamepad
  43402. * @param vrGamepad the gamepad that the controller should be created from
  43403. */
  43404. constructor(vrGamepad: any);
  43405. /**
  43406. * Fired when the trigger on this controller is modified
  43407. */
  43408. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Fired when the menu button on this controller is modified
  43411. */
  43412. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43413. /**
  43414. * Fired when the grip button on this controller is modified
  43415. */
  43416. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43417. /**
  43418. * Fired when the thumbstick button on this controller is modified
  43419. */
  43420. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43421. /**
  43422. * Fired when the touchpad button on this controller is modified
  43423. */
  43424. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43425. /**
  43426. * Fired when the touchpad values on this controller are modified
  43427. */
  43428. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43429. private _updateTrackpad;
  43430. /**
  43431. * Called once per frame by the engine.
  43432. */
  43433. update(): void;
  43434. /**
  43435. * Called once for each button that changed state since the last frame
  43436. * @param buttonIdx Which button index changed
  43437. * @param state New state of the button
  43438. * @param changes Which properties on the state changed since last frame
  43439. */
  43440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43441. /**
  43442. * Moves the buttons on the controller mesh based on their current state
  43443. * @param buttonName the name of the button to move
  43444. * @param buttonValue the value of the button which determines the buttons new position
  43445. */
  43446. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43447. /**
  43448. * Moves the axis on the controller mesh based on its current state
  43449. * @param axis the index of the axis
  43450. * @param axisValue the value of the axis which determines the meshes new position
  43451. * @hidden
  43452. */
  43453. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43454. /**
  43455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43456. * @param scene scene in which to add meshes
  43457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43458. */
  43459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43460. /**
  43461. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43462. * can be transformed by button presses and axes values, based on this._mapping.
  43463. *
  43464. * @param scene scene in which the meshes exist
  43465. * @param meshes list of meshes that make up the controller model to process
  43466. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43467. */
  43468. private processModel;
  43469. private createMeshInfo;
  43470. /**
  43471. * Gets the ray of the controller in the direction the controller is pointing
  43472. * @param length the length the resulting ray should be
  43473. * @returns a ray in the direction the controller is pointing
  43474. */
  43475. getForwardRay(length?: number): Ray;
  43476. /**
  43477. * Disposes of the controller
  43478. */
  43479. dispose(): void;
  43480. }
  43481. }
  43482. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43483. import { Observable } from "babylonjs/Misc/observable";
  43484. import { Scene } from "babylonjs/scene";
  43485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43486. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43487. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43488. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43489. /**
  43490. * Oculus Touch Controller
  43491. */
  43492. export class OculusTouchController extends WebVRController {
  43493. /**
  43494. * Base Url for the controller model.
  43495. */
  43496. static MODEL_BASE_URL: string;
  43497. /**
  43498. * File name for the left controller model.
  43499. */
  43500. static MODEL_LEFT_FILENAME: string;
  43501. /**
  43502. * File name for the right controller model.
  43503. */
  43504. static MODEL_RIGHT_FILENAME: string;
  43505. /**
  43506. * Base Url for the Quest controller model.
  43507. */
  43508. static QUEST_MODEL_BASE_URL: string;
  43509. /**
  43510. * @hidden
  43511. * If the controllers are running on a device that needs the updated Quest controller models
  43512. */
  43513. static _IsQuest: boolean;
  43514. /**
  43515. * Fired when the secondary trigger on this controller is modified
  43516. */
  43517. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43518. /**
  43519. * Fired when the thumb rest on this controller is modified
  43520. */
  43521. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43522. /**
  43523. * Creates a new OculusTouchController from a gamepad
  43524. * @param vrGamepad the gamepad that the controller should be created from
  43525. */
  43526. constructor(vrGamepad: any);
  43527. /**
  43528. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43529. * @param scene scene in which to add meshes
  43530. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43531. */
  43532. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43533. /**
  43534. * Fired when the A button on this controller is modified
  43535. */
  43536. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43537. /**
  43538. * Fired when the B button on this controller is modified
  43539. */
  43540. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43541. /**
  43542. * Fired when the X button on this controller is modified
  43543. */
  43544. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43545. /**
  43546. * Fired when the Y button on this controller is modified
  43547. */
  43548. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43549. /**
  43550. * Called once for each button that changed state since the last frame
  43551. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43552. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43553. * 2) secondary trigger (same)
  43554. * 3) A (right) X (left), touch, pressed = value
  43555. * 4) B / Y
  43556. * 5) thumb rest
  43557. * @param buttonIdx Which button index changed
  43558. * @param state New state of the button
  43559. * @param changes Which properties on the state changed since last frame
  43560. */
  43561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43562. }
  43563. }
  43564. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43565. import { Scene } from "babylonjs/scene";
  43566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43567. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43568. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43569. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43570. import { Observable } from "babylonjs/Misc/observable";
  43571. /**
  43572. * Vive Controller
  43573. */
  43574. export class ViveController extends WebVRController {
  43575. /**
  43576. * Base Url for the controller model.
  43577. */
  43578. static MODEL_BASE_URL: string;
  43579. /**
  43580. * File name for the controller model.
  43581. */
  43582. static MODEL_FILENAME: string;
  43583. /**
  43584. * Creates a new ViveController from a gamepad
  43585. * @param vrGamepad the gamepad that the controller should be created from
  43586. */
  43587. constructor(vrGamepad: any);
  43588. /**
  43589. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43590. * @param scene scene in which to add meshes
  43591. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43592. */
  43593. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43594. /**
  43595. * Fired when the left button on this controller is modified
  43596. */
  43597. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43598. /**
  43599. * Fired when the right button on this controller is modified
  43600. */
  43601. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43602. /**
  43603. * Fired when the menu button on this controller is modified
  43604. */
  43605. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43606. /**
  43607. * Called once for each button that changed state since the last frame
  43608. * Vive mapping:
  43609. * 0: touchpad
  43610. * 1: trigger
  43611. * 2: left AND right buttons
  43612. * 3: menu button
  43613. * @param buttonIdx Which button index changed
  43614. * @param state New state of the button
  43615. * @param changes Which properties on the state changed since last frame
  43616. */
  43617. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43618. }
  43619. }
  43620. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43621. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43622. /**
  43623. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43624. */
  43625. export class WebXRControllerModelLoader {
  43626. /**
  43627. * Creates the WebXRControllerModelLoader
  43628. * @param input xr input that creates the controllers
  43629. */
  43630. constructor(input: WebXRInput);
  43631. }
  43632. }
  43633. declare module "babylonjs/Cameras/XR/index" {
  43634. export * from "babylonjs/Cameras/XR/webXRCamera";
  43635. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43636. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43637. export * from "babylonjs/Cameras/XR/webXRInput";
  43638. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43639. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43640. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43641. export * from "babylonjs/Cameras/XR/webXRController";
  43642. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43643. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43644. }
  43645. declare module "babylonjs/Cameras/RigModes/index" {
  43646. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43647. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43648. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43649. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43650. }
  43651. declare module "babylonjs/Cameras/index" {
  43652. export * from "babylonjs/Cameras/Inputs/index";
  43653. export * from "babylonjs/Cameras/cameraInputsManager";
  43654. export * from "babylonjs/Cameras/camera";
  43655. export * from "babylonjs/Cameras/targetCamera";
  43656. export * from "babylonjs/Cameras/freeCamera";
  43657. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43658. export * from "babylonjs/Cameras/touchCamera";
  43659. export * from "babylonjs/Cameras/arcRotateCamera";
  43660. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43661. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43662. export * from "babylonjs/Cameras/flyCamera";
  43663. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43664. export * from "babylonjs/Cameras/followCamera";
  43665. export * from "babylonjs/Cameras/gamepadCamera";
  43666. export * from "babylonjs/Cameras/Stereoscopic/index";
  43667. export * from "babylonjs/Cameras/universalCamera";
  43668. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43669. export * from "babylonjs/Cameras/VR/index";
  43670. export * from "babylonjs/Cameras/XR/index";
  43671. export * from "babylonjs/Cameras/RigModes/index";
  43672. }
  43673. declare module "babylonjs/Collisions/index" {
  43674. export * from "babylonjs/Collisions/collider";
  43675. export * from "babylonjs/Collisions/collisionCoordinator";
  43676. export * from "babylonjs/Collisions/pickingInfo";
  43677. export * from "babylonjs/Collisions/intersectionInfo";
  43678. export * from "babylonjs/Collisions/meshCollisionData";
  43679. }
  43680. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43681. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43682. import { Vector3 } from "babylonjs/Maths/math.vector";
  43683. import { Ray } from "babylonjs/Culling/ray";
  43684. import { Plane } from "babylonjs/Maths/math.plane";
  43685. /**
  43686. * Contains an array of blocks representing the octree
  43687. */
  43688. export interface IOctreeContainer<T> {
  43689. /**
  43690. * Blocks within the octree
  43691. */
  43692. blocks: Array<OctreeBlock<T>>;
  43693. }
  43694. /**
  43695. * Class used to store a cell in an octree
  43696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43697. */
  43698. export class OctreeBlock<T> {
  43699. /**
  43700. * Gets the content of the current block
  43701. */
  43702. entries: T[];
  43703. /**
  43704. * Gets the list of block children
  43705. */
  43706. blocks: Array<OctreeBlock<T>>;
  43707. private _depth;
  43708. private _maxDepth;
  43709. private _capacity;
  43710. private _minPoint;
  43711. private _maxPoint;
  43712. private _boundingVectors;
  43713. private _creationFunc;
  43714. /**
  43715. * Creates a new block
  43716. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43717. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43718. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43719. * @param depth defines the current depth of this block in the octree
  43720. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43721. * @param creationFunc defines a callback to call when an element is added to the block
  43722. */
  43723. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43724. /**
  43725. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43726. */
  43727. readonly capacity: number;
  43728. /**
  43729. * Gets the minimum vector (in world space) of the block's bounding box
  43730. */
  43731. readonly minPoint: Vector3;
  43732. /**
  43733. * Gets the maximum vector (in world space) of the block's bounding box
  43734. */
  43735. readonly maxPoint: Vector3;
  43736. /**
  43737. * Add a new element to this block
  43738. * @param entry defines the element to add
  43739. */
  43740. addEntry(entry: T): void;
  43741. /**
  43742. * Remove an element from this block
  43743. * @param entry defines the element to remove
  43744. */
  43745. removeEntry(entry: T): void;
  43746. /**
  43747. * Add an array of elements to this block
  43748. * @param entries defines the array of elements to add
  43749. */
  43750. addEntries(entries: T[]): void;
  43751. /**
  43752. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43753. * @param frustumPlanes defines the frustum planes to test
  43754. * @param selection defines the array to store current content if selection is positive
  43755. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43756. */
  43757. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43758. /**
  43759. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43760. * @param sphereCenter defines the bounding sphere center
  43761. * @param sphereRadius defines the bounding sphere radius
  43762. * @param selection defines the array to store current content if selection is positive
  43763. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43764. */
  43765. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43766. /**
  43767. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43768. * @param ray defines the ray to test with
  43769. * @param selection defines the array to store current content if selection is positive
  43770. */
  43771. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43772. /**
  43773. * Subdivide the content into child blocks (this block will then be empty)
  43774. */
  43775. createInnerBlocks(): void;
  43776. /**
  43777. * @hidden
  43778. */
  43779. 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;
  43780. }
  43781. }
  43782. declare module "babylonjs/Culling/Octrees/octree" {
  43783. import { SmartArray } from "babylonjs/Misc/smartArray";
  43784. import { Vector3 } from "babylonjs/Maths/math.vector";
  43785. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43787. import { Ray } from "babylonjs/Culling/ray";
  43788. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43789. import { Plane } from "babylonjs/Maths/math.plane";
  43790. /**
  43791. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43793. */
  43794. export class Octree<T> {
  43795. /** 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.) */
  43796. maxDepth: number;
  43797. /**
  43798. * Blocks within the octree containing objects
  43799. */
  43800. blocks: Array<OctreeBlock<T>>;
  43801. /**
  43802. * Content stored in the octree
  43803. */
  43804. dynamicContent: T[];
  43805. private _maxBlockCapacity;
  43806. private _selectionContent;
  43807. private _creationFunc;
  43808. /**
  43809. * Creates a octree
  43810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43811. * @param creationFunc function to be used to instatiate the octree
  43812. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43813. * @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.)
  43814. */
  43815. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43816. /** 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.) */
  43817. maxDepth?: number);
  43818. /**
  43819. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43820. * @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);
  43821. * @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);
  43822. * @param entries meshes to be added to the octree blocks
  43823. */
  43824. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43825. /**
  43826. * Adds a mesh to the octree
  43827. * @param entry Mesh to add to the octree
  43828. */
  43829. addMesh(entry: T): void;
  43830. /**
  43831. * Remove an element from the octree
  43832. * @param entry defines the element to remove
  43833. */
  43834. removeMesh(entry: T): void;
  43835. /**
  43836. * Selects an array of meshes within the frustum
  43837. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43838. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43839. * @returns array of meshes within the frustum
  43840. */
  43841. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43842. /**
  43843. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43844. * @param sphereCenter defines the bounding sphere center
  43845. * @param sphereRadius defines the bounding sphere radius
  43846. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43847. * @returns an array of objects that intersect the sphere
  43848. */
  43849. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43850. /**
  43851. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43852. * @param ray defines the ray to test with
  43853. * @returns array of intersected objects
  43854. */
  43855. intersectsRay(ray: Ray): SmartArray<T>;
  43856. /**
  43857. * Adds a mesh into the octree block if it intersects the block
  43858. */
  43859. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43860. /**
  43861. * Adds a submesh into the octree block if it intersects the block
  43862. */
  43863. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43864. }
  43865. }
  43866. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43867. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43868. import { Scene } from "babylonjs/scene";
  43869. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43871. import { Ray } from "babylonjs/Culling/ray";
  43872. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43873. import { Collider } from "babylonjs/Collisions/collider";
  43874. module "babylonjs/scene" {
  43875. interface Scene {
  43876. /**
  43877. * @hidden
  43878. * Backing Filed
  43879. */
  43880. _selectionOctree: Octree<AbstractMesh>;
  43881. /**
  43882. * Gets the octree used to boost mesh selection (picking)
  43883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43884. */
  43885. selectionOctree: Octree<AbstractMesh>;
  43886. /**
  43887. * Creates or updates the octree used to boost selection (picking)
  43888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43889. * @param maxCapacity defines the maximum capacity per leaf
  43890. * @param maxDepth defines the maximum depth of the octree
  43891. * @returns an octree of AbstractMesh
  43892. */
  43893. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43894. }
  43895. }
  43896. module "babylonjs/Meshes/abstractMesh" {
  43897. interface AbstractMesh {
  43898. /**
  43899. * @hidden
  43900. * Backing Field
  43901. */
  43902. _submeshesOctree: Octree<SubMesh>;
  43903. /**
  43904. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43905. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43906. * @param maxCapacity defines the maximum size of each block (64 by default)
  43907. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43908. * @returns the new octree
  43909. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43911. */
  43912. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43913. }
  43914. }
  43915. /**
  43916. * Defines the octree scene component responsible to manage any octrees
  43917. * in a given scene.
  43918. */
  43919. export class OctreeSceneComponent {
  43920. /**
  43921. * The component name help to identify the component in the list of scene components.
  43922. */
  43923. readonly name: string;
  43924. /**
  43925. * The scene the component belongs to.
  43926. */
  43927. scene: Scene;
  43928. /**
  43929. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43930. */
  43931. readonly checksIsEnabled: boolean;
  43932. /**
  43933. * Creates a new instance of the component for the given scene
  43934. * @param scene Defines the scene to register the component in
  43935. */
  43936. constructor(scene: Scene);
  43937. /**
  43938. * Registers the component in a given scene
  43939. */
  43940. register(): void;
  43941. /**
  43942. * Return the list of active meshes
  43943. * @returns the list of active meshes
  43944. */
  43945. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43946. /**
  43947. * Return the list of active sub meshes
  43948. * @param mesh The mesh to get the candidates sub meshes from
  43949. * @returns the list of active sub meshes
  43950. */
  43951. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43952. private _tempRay;
  43953. /**
  43954. * Return the list of sub meshes intersecting with a given local ray
  43955. * @param mesh defines the mesh to find the submesh for
  43956. * @param localRay defines the ray in local space
  43957. * @returns the list of intersecting sub meshes
  43958. */
  43959. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43960. /**
  43961. * Return the list of sub meshes colliding with a collider
  43962. * @param mesh defines the mesh to find the submesh for
  43963. * @param collider defines the collider to evaluate the collision against
  43964. * @returns the list of colliding sub meshes
  43965. */
  43966. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43967. /**
  43968. * Rebuilds the elements related to this component in case of
  43969. * context lost for instance.
  43970. */
  43971. rebuild(): void;
  43972. /**
  43973. * Disposes the component and the associated ressources.
  43974. */
  43975. dispose(): void;
  43976. }
  43977. }
  43978. declare module "babylonjs/Culling/Octrees/index" {
  43979. export * from "babylonjs/Culling/Octrees/octree";
  43980. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43981. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43982. }
  43983. declare module "babylonjs/Culling/index" {
  43984. export * from "babylonjs/Culling/boundingBox";
  43985. export * from "babylonjs/Culling/boundingInfo";
  43986. export * from "babylonjs/Culling/boundingSphere";
  43987. export * from "babylonjs/Culling/Octrees/index";
  43988. export * from "babylonjs/Culling/ray";
  43989. }
  43990. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43991. import { IDisposable, Scene } from "babylonjs/scene";
  43992. import { Nullable } from "babylonjs/types";
  43993. import { Observable } from "babylonjs/Misc/observable";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43996. import { Camera } from "babylonjs/Cameras/camera";
  43997. /**
  43998. * Renders a layer on top of an existing scene
  43999. */
  44000. export class UtilityLayerRenderer implements IDisposable {
  44001. /** the original scene that will be rendered on top of */
  44002. originalScene: Scene;
  44003. private _pointerCaptures;
  44004. private _lastPointerEvents;
  44005. private static _DefaultUtilityLayer;
  44006. private static _DefaultKeepDepthUtilityLayer;
  44007. private _sharedGizmoLight;
  44008. private _renderCamera;
  44009. /**
  44010. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44011. * @returns the camera that is used when rendering the utility layer
  44012. */
  44013. getRenderCamera(): Nullable<Camera>;
  44014. /**
  44015. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44016. * @param cam the camera that should be used when rendering the utility layer
  44017. */
  44018. setRenderCamera(cam: Nullable<Camera>): void;
  44019. /**
  44020. * @hidden
  44021. * Light which used by gizmos to get light shading
  44022. */
  44023. _getSharedGizmoLight(): HemisphericLight;
  44024. /**
  44025. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44026. */
  44027. pickUtilitySceneFirst: boolean;
  44028. /**
  44029. * 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)
  44030. */
  44031. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44032. /**
  44033. * 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)
  44034. */
  44035. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44036. /**
  44037. * The scene that is rendered on top of the original scene
  44038. */
  44039. utilityLayerScene: Scene;
  44040. /**
  44041. * If the utility layer should automatically be rendered on top of existing scene
  44042. */
  44043. shouldRender: boolean;
  44044. /**
  44045. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44046. */
  44047. onlyCheckPointerDownEvents: boolean;
  44048. /**
  44049. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44050. */
  44051. processAllEvents: boolean;
  44052. /**
  44053. * Observable raised when the pointer move from the utility layer scene to the main scene
  44054. */
  44055. onPointerOutObservable: Observable<number>;
  44056. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44057. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44058. private _afterRenderObserver;
  44059. private _sceneDisposeObserver;
  44060. private _originalPointerObserver;
  44061. /**
  44062. * Instantiates a UtilityLayerRenderer
  44063. * @param originalScene the original scene that will be rendered on top of
  44064. * @param handleEvents boolean indicating if the utility layer should handle events
  44065. */
  44066. constructor(
  44067. /** the original scene that will be rendered on top of */
  44068. originalScene: Scene, handleEvents?: boolean);
  44069. private _notifyObservers;
  44070. /**
  44071. * Renders the utility layers scene on top of the original scene
  44072. */
  44073. render(): void;
  44074. /**
  44075. * Disposes of the renderer
  44076. */
  44077. dispose(): void;
  44078. private _updateCamera;
  44079. }
  44080. }
  44081. declare module "babylonjs/Gizmos/gizmo" {
  44082. import { Nullable } from "babylonjs/types";
  44083. import { IDisposable } from "babylonjs/scene";
  44084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44085. import { Mesh } from "babylonjs/Meshes/mesh";
  44086. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44087. /**
  44088. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44089. */
  44090. export class Gizmo implements IDisposable {
  44091. /** The utility layer the gizmo will be added to */
  44092. gizmoLayer: UtilityLayerRenderer;
  44093. /**
  44094. * The root mesh of the gizmo
  44095. */
  44096. _rootMesh: Mesh;
  44097. private _attachedMesh;
  44098. /**
  44099. * Ratio for the scale of the gizmo (Default: 1)
  44100. */
  44101. scaleRatio: number;
  44102. /**
  44103. * If a custom mesh has been set (Default: false)
  44104. */
  44105. protected _customMeshSet: boolean;
  44106. /**
  44107. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44108. * * When set, interactions will be enabled
  44109. */
  44110. attachedMesh: Nullable<AbstractMesh>;
  44111. /**
  44112. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44113. * @param mesh The mesh to replace the default mesh of the gizmo
  44114. */
  44115. setCustomMesh(mesh: Mesh): void;
  44116. /**
  44117. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44118. */
  44119. updateGizmoRotationToMatchAttachedMesh: boolean;
  44120. /**
  44121. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44122. */
  44123. updateGizmoPositionToMatchAttachedMesh: boolean;
  44124. /**
  44125. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44126. */
  44127. updateScale: boolean;
  44128. protected _interactionsEnabled: boolean;
  44129. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44130. private _beforeRenderObserver;
  44131. private _tempVector;
  44132. /**
  44133. * Creates a gizmo
  44134. * @param gizmoLayer The utility layer the gizmo will be added to
  44135. */
  44136. constructor(
  44137. /** The utility layer the gizmo will be added to */
  44138. gizmoLayer?: UtilityLayerRenderer);
  44139. /**
  44140. * Updates the gizmo to match the attached mesh's position/rotation
  44141. */
  44142. protected _update(): void;
  44143. /**
  44144. * Disposes of the gizmo
  44145. */
  44146. dispose(): void;
  44147. }
  44148. }
  44149. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44150. import { Observable } from "babylonjs/Misc/observable";
  44151. import { Nullable } from "babylonjs/types";
  44152. import { Vector3 } from "babylonjs/Maths/math.vector";
  44153. import { Color3 } from "babylonjs/Maths/math.color";
  44154. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44156. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44157. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44158. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44159. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44160. import { Scene } from "babylonjs/scene";
  44161. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44162. /**
  44163. * Single plane drag gizmo
  44164. */
  44165. export class PlaneDragGizmo extends Gizmo {
  44166. /**
  44167. * Drag behavior responsible for the gizmos dragging interactions
  44168. */
  44169. dragBehavior: PointerDragBehavior;
  44170. private _pointerObserver;
  44171. /**
  44172. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44173. */
  44174. snapDistance: number;
  44175. /**
  44176. * Event that fires each time the gizmo snaps to a new location.
  44177. * * snapDistance is the the change in distance
  44178. */
  44179. onSnapObservable: Observable<{
  44180. snapDistance: number;
  44181. }>;
  44182. private _plane;
  44183. private _coloredMaterial;
  44184. private _hoverMaterial;
  44185. private _isEnabled;
  44186. private _parent;
  44187. /** @hidden */
  44188. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44189. /** @hidden */
  44190. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44191. /**
  44192. * Creates a PlaneDragGizmo
  44193. * @param gizmoLayer The utility layer the gizmo will be added to
  44194. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44195. * @param color The color of the gizmo
  44196. */
  44197. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44198. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44199. /**
  44200. * If the gizmo is enabled
  44201. */
  44202. isEnabled: boolean;
  44203. /**
  44204. * Disposes of the gizmo
  44205. */
  44206. dispose(): void;
  44207. }
  44208. }
  44209. declare module "babylonjs/Gizmos/positionGizmo" {
  44210. import { Observable } from "babylonjs/Misc/observable";
  44211. import { Nullable } from "babylonjs/types";
  44212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44213. import { Mesh } from "babylonjs/Meshes/mesh";
  44214. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44215. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44216. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44217. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44218. /**
  44219. * Gizmo that enables dragging a mesh along 3 axis
  44220. */
  44221. export class PositionGizmo extends Gizmo {
  44222. /**
  44223. * Internal gizmo used for interactions on the x axis
  44224. */
  44225. xGizmo: AxisDragGizmo;
  44226. /**
  44227. * Internal gizmo used for interactions on the y axis
  44228. */
  44229. yGizmo: AxisDragGizmo;
  44230. /**
  44231. * Internal gizmo used for interactions on the z axis
  44232. */
  44233. zGizmo: AxisDragGizmo;
  44234. /**
  44235. * Internal gizmo used for interactions on the yz plane
  44236. */
  44237. xPlaneGizmo: PlaneDragGizmo;
  44238. /**
  44239. * Internal gizmo used for interactions on the xz plane
  44240. */
  44241. yPlaneGizmo: PlaneDragGizmo;
  44242. /**
  44243. * Internal gizmo used for interactions on the xy plane
  44244. */
  44245. zPlaneGizmo: PlaneDragGizmo;
  44246. /**
  44247. * private variables
  44248. */
  44249. private _meshAttached;
  44250. private _updateGizmoRotationToMatchAttachedMesh;
  44251. private _snapDistance;
  44252. private _scaleRatio;
  44253. /** Fires an event when any of it's sub gizmos are dragged */
  44254. onDragStartObservable: Observable<unknown>;
  44255. /** Fires an event when any of it's sub gizmos are released from dragging */
  44256. onDragEndObservable: Observable<unknown>;
  44257. /**
  44258. * If set to true, planar drag is enabled
  44259. */
  44260. private _planarGizmoEnabled;
  44261. attachedMesh: Nullable<AbstractMesh>;
  44262. /**
  44263. * Creates a PositionGizmo
  44264. * @param gizmoLayer The utility layer the gizmo will be added to
  44265. */
  44266. constructor(gizmoLayer?: UtilityLayerRenderer);
  44267. /**
  44268. * If the planar drag gizmo is enabled
  44269. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44270. */
  44271. planarGizmoEnabled: boolean;
  44272. updateGizmoRotationToMatchAttachedMesh: boolean;
  44273. /**
  44274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44275. */
  44276. snapDistance: number;
  44277. /**
  44278. * Ratio for the scale of the gizmo (Default: 1)
  44279. */
  44280. scaleRatio: number;
  44281. /**
  44282. * Disposes of the gizmo
  44283. */
  44284. dispose(): void;
  44285. /**
  44286. * CustomMeshes are not supported by this gizmo
  44287. * @param mesh The mesh to replace the default mesh of the gizmo
  44288. */
  44289. setCustomMesh(mesh: Mesh): void;
  44290. }
  44291. }
  44292. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44293. import { Observable } from "babylonjs/Misc/observable";
  44294. import { Nullable } from "babylonjs/types";
  44295. import { Vector3 } from "babylonjs/Maths/math.vector";
  44296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44301. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44302. import { Scene } from "babylonjs/scene";
  44303. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44304. import { Color3 } from "babylonjs/Maths/math.color";
  44305. /**
  44306. * Single axis drag gizmo
  44307. */
  44308. export class AxisDragGizmo extends Gizmo {
  44309. /**
  44310. * Drag behavior responsible for the gizmos dragging interactions
  44311. */
  44312. dragBehavior: PointerDragBehavior;
  44313. private _pointerObserver;
  44314. /**
  44315. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44316. */
  44317. snapDistance: number;
  44318. /**
  44319. * Event that fires each time the gizmo snaps to a new location.
  44320. * * snapDistance is the the change in distance
  44321. */
  44322. onSnapObservable: Observable<{
  44323. snapDistance: number;
  44324. }>;
  44325. private _isEnabled;
  44326. private _parent;
  44327. private _arrow;
  44328. private _coloredMaterial;
  44329. private _hoverMaterial;
  44330. /** @hidden */
  44331. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44332. /** @hidden */
  44333. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44334. /**
  44335. * Creates an AxisDragGizmo
  44336. * @param gizmoLayer The utility layer the gizmo will be added to
  44337. * @param dragAxis The axis which the gizmo will be able to drag on
  44338. * @param color The color of the gizmo
  44339. */
  44340. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44341. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44342. /**
  44343. * If the gizmo is enabled
  44344. */
  44345. isEnabled: boolean;
  44346. /**
  44347. * Disposes of the gizmo
  44348. */
  44349. dispose(): void;
  44350. }
  44351. }
  44352. declare module "babylonjs/Debug/axesViewer" {
  44353. import { Vector3 } from "babylonjs/Maths/math.vector";
  44354. import { Nullable } from "babylonjs/types";
  44355. import { Scene } from "babylonjs/scene";
  44356. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44357. /**
  44358. * The Axes viewer will show 3 axes in a specific point in space
  44359. */
  44360. export class AxesViewer {
  44361. private _xAxis;
  44362. private _yAxis;
  44363. private _zAxis;
  44364. private _scaleLinesFactor;
  44365. private _instanced;
  44366. /**
  44367. * Gets the hosting scene
  44368. */
  44369. scene: Scene;
  44370. /**
  44371. * Gets or sets a number used to scale line length
  44372. */
  44373. scaleLines: number;
  44374. /** Gets the node hierarchy used to render x-axis */
  44375. readonly xAxis: TransformNode;
  44376. /** Gets the node hierarchy used to render y-axis */
  44377. readonly yAxis: TransformNode;
  44378. /** Gets the node hierarchy used to render z-axis */
  44379. readonly zAxis: TransformNode;
  44380. /**
  44381. * Creates a new AxesViewer
  44382. * @param scene defines the hosting scene
  44383. * @param scaleLines defines a number used to scale line length (1 by default)
  44384. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44385. * @param xAxis defines the node hierarchy used to render the x-axis
  44386. * @param yAxis defines the node hierarchy used to render the y-axis
  44387. * @param zAxis defines the node hierarchy used to render the z-axis
  44388. */
  44389. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44390. /**
  44391. * Force the viewer to update
  44392. * @param position defines the position of the viewer
  44393. * @param xaxis defines the x axis of the viewer
  44394. * @param yaxis defines the y axis of the viewer
  44395. * @param zaxis defines the z axis of the viewer
  44396. */
  44397. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44398. /**
  44399. * Creates an instance of this axes viewer.
  44400. * @returns a new axes viewer with instanced meshes
  44401. */
  44402. createInstance(): AxesViewer;
  44403. /** Releases resources */
  44404. dispose(): void;
  44405. private static _SetRenderingGroupId;
  44406. }
  44407. }
  44408. declare module "babylonjs/Debug/boneAxesViewer" {
  44409. import { Nullable } from "babylonjs/types";
  44410. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44411. import { Vector3 } from "babylonjs/Maths/math.vector";
  44412. import { Mesh } from "babylonjs/Meshes/mesh";
  44413. import { Bone } from "babylonjs/Bones/bone";
  44414. import { Scene } from "babylonjs/scene";
  44415. /**
  44416. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44417. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44418. */
  44419. export class BoneAxesViewer extends AxesViewer {
  44420. /**
  44421. * Gets or sets the target mesh where to display the axes viewer
  44422. */
  44423. mesh: Nullable<Mesh>;
  44424. /**
  44425. * Gets or sets the target bone where to display the axes viewer
  44426. */
  44427. bone: Nullable<Bone>;
  44428. /** Gets current position */
  44429. pos: Vector3;
  44430. /** Gets direction of X axis */
  44431. xaxis: Vector3;
  44432. /** Gets direction of Y axis */
  44433. yaxis: Vector3;
  44434. /** Gets direction of Z axis */
  44435. zaxis: Vector3;
  44436. /**
  44437. * Creates a new BoneAxesViewer
  44438. * @param scene defines the hosting scene
  44439. * @param bone defines the target bone
  44440. * @param mesh defines the target mesh
  44441. * @param scaleLines defines a scaling factor for line length (1 by default)
  44442. */
  44443. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44444. /**
  44445. * Force the viewer to update
  44446. */
  44447. update(): void;
  44448. /** Releases resources */
  44449. dispose(): void;
  44450. }
  44451. }
  44452. declare module "babylonjs/Debug/debugLayer" {
  44453. import { Scene } from "babylonjs/scene";
  44454. /**
  44455. * Interface used to define scene explorer extensibility option
  44456. */
  44457. export interface IExplorerExtensibilityOption {
  44458. /**
  44459. * Define the option label
  44460. */
  44461. label: string;
  44462. /**
  44463. * Defines the action to execute on click
  44464. */
  44465. action: (entity: any) => void;
  44466. }
  44467. /**
  44468. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44469. */
  44470. export interface IExplorerExtensibilityGroup {
  44471. /**
  44472. * Defines a predicate to test if a given type mut be extended
  44473. */
  44474. predicate: (entity: any) => boolean;
  44475. /**
  44476. * Gets the list of options added to a type
  44477. */
  44478. entries: IExplorerExtensibilityOption[];
  44479. }
  44480. /**
  44481. * Interface used to define the options to use to create the Inspector
  44482. */
  44483. export interface IInspectorOptions {
  44484. /**
  44485. * Display in overlay mode (default: false)
  44486. */
  44487. overlay?: boolean;
  44488. /**
  44489. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44490. */
  44491. globalRoot?: HTMLElement;
  44492. /**
  44493. * Display the Scene explorer
  44494. */
  44495. showExplorer?: boolean;
  44496. /**
  44497. * Display the property inspector
  44498. */
  44499. showInspector?: boolean;
  44500. /**
  44501. * Display in embed mode (both panes on the right)
  44502. */
  44503. embedMode?: boolean;
  44504. /**
  44505. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44506. */
  44507. handleResize?: boolean;
  44508. /**
  44509. * Allow the panes to popup (default: true)
  44510. */
  44511. enablePopup?: boolean;
  44512. /**
  44513. * Allow the panes to be closed by users (default: true)
  44514. */
  44515. enableClose?: boolean;
  44516. /**
  44517. * Optional list of extensibility entries
  44518. */
  44519. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44520. /**
  44521. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44522. */
  44523. inspectorURL?: string;
  44524. }
  44525. module "babylonjs/scene" {
  44526. interface Scene {
  44527. /**
  44528. * @hidden
  44529. * Backing field
  44530. */
  44531. _debugLayer: DebugLayer;
  44532. /**
  44533. * Gets the debug layer (aka Inspector) associated with the scene
  44534. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44535. */
  44536. debugLayer: DebugLayer;
  44537. }
  44538. }
  44539. /**
  44540. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44541. * what is happening in your scene
  44542. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44543. */
  44544. export class DebugLayer {
  44545. /**
  44546. * Define the url to get the inspector script from.
  44547. * By default it uses the babylonjs CDN.
  44548. * @ignoreNaming
  44549. */
  44550. static InspectorURL: string;
  44551. private _scene;
  44552. private BJSINSPECTOR;
  44553. private _onPropertyChangedObservable?;
  44554. /**
  44555. * Observable triggered when a property is changed through the inspector.
  44556. */
  44557. readonly onPropertyChangedObservable: any;
  44558. /**
  44559. * Instantiates a new debug layer.
  44560. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44561. * what is happening in your scene
  44562. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44563. * @param scene Defines the scene to inspect
  44564. */
  44565. constructor(scene: Scene);
  44566. /** Creates the inspector window. */
  44567. private _createInspector;
  44568. /**
  44569. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44570. * @param entity defines the entity to select
  44571. * @param lineContainerTitle defines the specific block to highlight
  44572. */
  44573. select(entity: any, lineContainerTitle?: string): void;
  44574. /** Get the inspector from bundle or global */
  44575. private _getGlobalInspector;
  44576. /**
  44577. * Get if the inspector is visible or not.
  44578. * @returns true if visible otherwise, false
  44579. */
  44580. isVisible(): boolean;
  44581. /**
  44582. * Hide the inspector and close its window.
  44583. */
  44584. hide(): void;
  44585. /**
  44586. * Launch the debugLayer.
  44587. * @param config Define the configuration of the inspector
  44588. * @return a promise fulfilled when the debug layer is visible
  44589. */
  44590. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44591. }
  44592. }
  44593. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44594. import { Nullable } from "babylonjs/types";
  44595. import { Scene } from "babylonjs/scene";
  44596. import { Vector4 } from "babylonjs/Maths/math.vector";
  44597. import { Color4 } from "babylonjs/Maths/math.color";
  44598. import { Mesh } from "babylonjs/Meshes/mesh";
  44599. /**
  44600. * Class containing static functions to help procedurally build meshes
  44601. */
  44602. export class BoxBuilder {
  44603. /**
  44604. * Creates a box mesh
  44605. * * The parameter `size` sets the size (float) of each box side (default 1)
  44606. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44607. * * 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)
  44608. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44612. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44613. * @param name defines the name of the mesh
  44614. * @param options defines the options used to create the mesh
  44615. * @param scene defines the hosting scene
  44616. * @returns the box mesh
  44617. */
  44618. static CreateBox(name: string, options: {
  44619. size?: number;
  44620. width?: number;
  44621. height?: number;
  44622. depth?: number;
  44623. faceUV?: Vector4[];
  44624. faceColors?: Color4[];
  44625. sideOrientation?: number;
  44626. frontUVs?: Vector4;
  44627. backUVs?: Vector4;
  44628. wrap?: boolean;
  44629. topBaseAt?: number;
  44630. bottomBaseAt?: number;
  44631. updatable?: boolean;
  44632. }, scene?: Nullable<Scene>): Mesh;
  44633. }
  44634. }
  44635. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44636. import { Vector4 } from "babylonjs/Maths/math.vector";
  44637. import { Mesh } from "babylonjs/Meshes/mesh";
  44638. /**
  44639. * Class containing static functions to help procedurally build meshes
  44640. */
  44641. export class SphereBuilder {
  44642. /**
  44643. * Creates a sphere mesh
  44644. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44645. * * 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`)
  44646. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44647. * * 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
  44648. * * 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)
  44649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44652. * @param name defines the name of the mesh
  44653. * @param options defines the options used to create the mesh
  44654. * @param scene defines the hosting scene
  44655. * @returns the sphere mesh
  44656. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44657. */
  44658. static CreateSphere(name: string, options: {
  44659. segments?: number;
  44660. diameter?: number;
  44661. diameterX?: number;
  44662. diameterY?: number;
  44663. diameterZ?: number;
  44664. arc?: number;
  44665. slice?: number;
  44666. sideOrientation?: number;
  44667. frontUVs?: Vector4;
  44668. backUVs?: Vector4;
  44669. updatable?: boolean;
  44670. }, scene: any): Mesh;
  44671. }
  44672. }
  44673. declare module "babylonjs/Debug/physicsViewer" {
  44674. import { Nullable } from "babylonjs/types";
  44675. import { Scene } from "babylonjs/scene";
  44676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44677. import { Mesh } from "babylonjs/Meshes/mesh";
  44678. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44679. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44680. /**
  44681. * Used to show the physics impostor around the specific mesh
  44682. */
  44683. export class PhysicsViewer {
  44684. /** @hidden */
  44685. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44686. /** @hidden */
  44687. protected _meshes: Array<Nullable<AbstractMesh>>;
  44688. /** @hidden */
  44689. protected _scene: Nullable<Scene>;
  44690. /** @hidden */
  44691. protected _numMeshes: number;
  44692. /** @hidden */
  44693. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44694. private _renderFunction;
  44695. private _utilityLayer;
  44696. private _debugBoxMesh;
  44697. private _debugSphereMesh;
  44698. private _debugCylinderMesh;
  44699. private _debugMaterial;
  44700. private _debugMeshMeshes;
  44701. /**
  44702. * Creates a new PhysicsViewer
  44703. * @param scene defines the hosting scene
  44704. */
  44705. constructor(scene: Scene);
  44706. /** @hidden */
  44707. protected _updateDebugMeshes(): void;
  44708. /**
  44709. * Renders a specified physic impostor
  44710. * @param impostor defines the impostor to render
  44711. * @param targetMesh defines the mesh represented by the impostor
  44712. * @returns the new debug mesh used to render the impostor
  44713. */
  44714. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44715. /**
  44716. * Hides a specified physic impostor
  44717. * @param impostor defines the impostor to hide
  44718. */
  44719. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44720. private _getDebugMaterial;
  44721. private _getDebugBoxMesh;
  44722. private _getDebugSphereMesh;
  44723. private _getDebugCylinderMesh;
  44724. private _getDebugMeshMesh;
  44725. private _getDebugMesh;
  44726. /** Releases all resources */
  44727. dispose(): void;
  44728. }
  44729. }
  44730. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44731. import { Vector3 } from "babylonjs/Maths/math.vector";
  44732. import { Color4 } from "babylonjs/Maths/math.color";
  44733. import { Nullable } from "babylonjs/types";
  44734. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44735. import { Scene } from "babylonjs/scene";
  44736. /**
  44737. * Class containing static functions to help procedurally build meshes
  44738. */
  44739. export class LinesBuilder {
  44740. /**
  44741. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44742. * * 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
  44743. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44744. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44745. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44746. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44747. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44748. * * 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
  44749. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44752. * @param name defines the name of the new line system
  44753. * @param options defines the options used to create the line system
  44754. * @param scene defines the hosting scene
  44755. * @returns a new line system mesh
  44756. */
  44757. static CreateLineSystem(name: string, options: {
  44758. lines: Vector3[][];
  44759. updatable?: boolean;
  44760. instance?: Nullable<LinesMesh>;
  44761. colors?: Nullable<Color4[][]>;
  44762. useVertexAlpha?: boolean;
  44763. }, scene: Nullable<Scene>): LinesMesh;
  44764. /**
  44765. * Creates a line mesh
  44766. * 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
  44767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44768. * * The parameter `points` is an array successive Vector3
  44769. * * 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
  44770. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44772. * * When updating an instance, remember that only point positions can change, not the number of points
  44773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44775. * @param name defines the name of the new line system
  44776. * @param options defines the options used to create the line system
  44777. * @param scene defines the hosting scene
  44778. * @returns a new line mesh
  44779. */
  44780. static CreateLines(name: string, options: {
  44781. points: Vector3[];
  44782. updatable?: boolean;
  44783. instance?: Nullable<LinesMesh>;
  44784. colors?: Color4[];
  44785. useVertexAlpha?: boolean;
  44786. }, scene?: Nullable<Scene>): LinesMesh;
  44787. /**
  44788. * Creates a dashed line mesh
  44789. * * 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
  44790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44791. * * The parameter `points` is an array successive Vector3
  44792. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44793. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44794. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44795. * * 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
  44796. * * When updating an instance, remember that only point positions can change, not the number of points
  44797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44798. * @param name defines the name of the mesh
  44799. * @param options defines the options used to create the mesh
  44800. * @param scene defines the hosting scene
  44801. * @returns the dashed line mesh
  44802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44803. */
  44804. static CreateDashedLines(name: string, options: {
  44805. points: Vector3[];
  44806. dashSize?: number;
  44807. gapSize?: number;
  44808. dashNb?: number;
  44809. updatable?: boolean;
  44810. instance?: LinesMesh;
  44811. }, scene?: Nullable<Scene>): LinesMesh;
  44812. }
  44813. }
  44814. declare module "babylonjs/Debug/rayHelper" {
  44815. import { Nullable } from "babylonjs/types";
  44816. import { Ray } from "babylonjs/Culling/ray";
  44817. import { Vector3 } from "babylonjs/Maths/math.vector";
  44818. import { Color3 } from "babylonjs/Maths/math.color";
  44819. import { Scene } from "babylonjs/scene";
  44820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44821. import "babylonjs/Meshes/Builders/linesBuilder";
  44822. /**
  44823. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44824. * in order to better appreciate the issue one might have.
  44825. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44826. */
  44827. export class RayHelper {
  44828. /**
  44829. * Defines the ray we are currently tryin to visualize.
  44830. */
  44831. ray: Nullable<Ray>;
  44832. private _renderPoints;
  44833. private _renderLine;
  44834. private _renderFunction;
  44835. private _scene;
  44836. private _updateToMeshFunction;
  44837. private _attachedToMesh;
  44838. private _meshSpaceDirection;
  44839. private _meshSpaceOrigin;
  44840. /**
  44841. * Helper function to create a colored helper in a scene in one line.
  44842. * @param ray Defines the ray we are currently tryin to visualize
  44843. * @param scene Defines the scene the ray is used in
  44844. * @param color Defines the color we want to see the ray in
  44845. * @returns The newly created ray helper.
  44846. */
  44847. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44848. /**
  44849. * Instantiate a new ray helper.
  44850. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44851. * in order to better appreciate the issue one might have.
  44852. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44853. * @param ray Defines the ray we are currently tryin to visualize
  44854. */
  44855. constructor(ray: Ray);
  44856. /**
  44857. * Shows the ray we are willing to debug.
  44858. * @param scene Defines the scene the ray needs to be rendered in
  44859. * @param color Defines the color the ray needs to be rendered in
  44860. */
  44861. show(scene: Scene, color?: Color3): void;
  44862. /**
  44863. * Hides the ray we are debugging.
  44864. */
  44865. hide(): void;
  44866. private _render;
  44867. /**
  44868. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44869. * @param mesh Defines the mesh we want the helper attached to
  44870. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44871. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44872. * @param length Defines the length of the ray
  44873. */
  44874. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44875. /**
  44876. * Detach the ray helper from the mesh it has previously been attached to.
  44877. */
  44878. detachFromMesh(): void;
  44879. private _updateToMesh;
  44880. /**
  44881. * Dispose the helper and release its associated resources.
  44882. */
  44883. dispose(): void;
  44884. }
  44885. }
  44886. declare module "babylonjs/Debug/skeletonViewer" {
  44887. import { Color3 } from "babylonjs/Maths/math.color";
  44888. import { Scene } from "babylonjs/scene";
  44889. import { Nullable } from "babylonjs/types";
  44890. import { Skeleton } from "babylonjs/Bones/skeleton";
  44891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44892. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44893. /**
  44894. * Class used to render a debug view of a given skeleton
  44895. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44896. */
  44897. export class SkeletonViewer {
  44898. /** defines the skeleton to render */
  44899. skeleton: Skeleton;
  44900. /** defines the mesh attached to the skeleton */
  44901. mesh: AbstractMesh;
  44902. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44903. autoUpdateBonesMatrices: boolean;
  44904. /** defines the rendering group id to use with the viewer */
  44905. renderingGroupId: number;
  44906. /** Gets or sets the color used to render the skeleton */
  44907. color: Color3;
  44908. private _scene;
  44909. private _debugLines;
  44910. private _debugMesh;
  44911. private _isEnabled;
  44912. private _renderFunction;
  44913. private _utilityLayer;
  44914. /**
  44915. * Returns the mesh used to render the bones
  44916. */
  44917. readonly debugMesh: Nullable<LinesMesh>;
  44918. /**
  44919. * Creates a new SkeletonViewer
  44920. * @param skeleton defines the skeleton to render
  44921. * @param mesh defines the mesh attached to the skeleton
  44922. * @param scene defines the hosting scene
  44923. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44924. * @param renderingGroupId defines the rendering group id to use with the viewer
  44925. */
  44926. constructor(
  44927. /** defines the skeleton to render */
  44928. skeleton: Skeleton,
  44929. /** defines the mesh attached to the skeleton */
  44930. mesh: AbstractMesh, scene: Scene,
  44931. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44932. autoUpdateBonesMatrices?: boolean,
  44933. /** defines the rendering group id to use with the viewer */
  44934. renderingGroupId?: number);
  44935. /** Gets or sets a boolean indicating if the viewer is enabled */
  44936. isEnabled: boolean;
  44937. private _getBonePosition;
  44938. private _getLinesForBonesWithLength;
  44939. private _getLinesForBonesNoLength;
  44940. /** Update the viewer to sync with current skeleton state */
  44941. update(): void;
  44942. /** Release associated resources */
  44943. dispose(): void;
  44944. }
  44945. }
  44946. declare module "babylonjs/Debug/index" {
  44947. export * from "babylonjs/Debug/axesViewer";
  44948. export * from "babylonjs/Debug/boneAxesViewer";
  44949. export * from "babylonjs/Debug/debugLayer";
  44950. export * from "babylonjs/Debug/physicsViewer";
  44951. export * from "babylonjs/Debug/rayHelper";
  44952. export * from "babylonjs/Debug/skeletonViewer";
  44953. }
  44954. declare module "babylonjs/Engines/nullEngine" {
  44955. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44956. import { Scene } from "babylonjs/scene";
  44957. import { Engine } from "babylonjs/Engines/engine";
  44958. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44959. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44960. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44961. import { Effect } from "babylonjs/Materials/effect";
  44962. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44963. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44964. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44965. /**
  44966. * Options to create the null engine
  44967. */
  44968. export class NullEngineOptions {
  44969. /**
  44970. * Render width (Default: 512)
  44971. */
  44972. renderWidth: number;
  44973. /**
  44974. * Render height (Default: 256)
  44975. */
  44976. renderHeight: number;
  44977. /**
  44978. * Texture size (Default: 512)
  44979. */
  44980. textureSize: number;
  44981. /**
  44982. * If delta time between frames should be constant
  44983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44984. */
  44985. deterministicLockstep: boolean;
  44986. /**
  44987. * Maximum about of steps between frames (Default: 4)
  44988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44989. */
  44990. lockstepMaxSteps: number;
  44991. }
  44992. /**
  44993. * The null engine class provides support for headless version of babylon.js.
  44994. * This can be used in server side scenario or for testing purposes
  44995. */
  44996. export class NullEngine extends Engine {
  44997. private _options;
  44998. /**
  44999. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45000. */
  45001. isDeterministicLockStep(): boolean;
  45002. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45003. getLockstepMaxSteps(): number;
  45004. /**
  45005. * Sets hardware scaling, used to save performance if needed
  45006. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45007. */
  45008. getHardwareScalingLevel(): number;
  45009. constructor(options?: NullEngineOptions);
  45010. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45011. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45012. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45013. getRenderWidth(useScreen?: boolean): number;
  45014. getRenderHeight(useScreen?: boolean): number;
  45015. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45016. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45017. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45018. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45019. bindSamplers(effect: Effect): void;
  45020. enableEffect(effect: Effect): void;
  45021. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45022. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45023. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45024. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45025. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45026. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45027. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45028. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45029. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45030. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45031. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45032. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45033. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45034. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45035. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45036. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45037. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45038. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45039. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45040. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45041. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45042. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45043. bindBuffers(vertexBuffers: {
  45044. [key: string]: VertexBuffer;
  45045. }, indexBuffer: DataBuffer, effect: Effect): void;
  45046. wipeCaches(bruteForce?: boolean): void;
  45047. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45048. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45050. /** @hidden */
  45051. _createTexture(): WebGLTexture;
  45052. /** @hidden */
  45053. _releaseTexture(texture: InternalTexture): void;
  45054. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45055. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45056. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45057. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45058. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45059. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45060. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45061. areAllEffectsReady(): boolean;
  45062. /**
  45063. * @hidden
  45064. * Get the current error code of the webGL context
  45065. * @returns the error code
  45066. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45067. */
  45068. getError(): number;
  45069. /** @hidden */
  45070. _getUnpackAlignement(): number;
  45071. /** @hidden */
  45072. _unpackFlipY(value: boolean): void;
  45073. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45074. /**
  45075. * Updates a dynamic vertex buffer.
  45076. * @param vertexBuffer the vertex buffer to update
  45077. * @param data the data used to update the vertex buffer
  45078. * @param byteOffset the byte offset of the data (optional)
  45079. * @param byteLength the byte length of the data (optional)
  45080. */
  45081. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45082. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45083. /** @hidden */
  45084. _bindTexture(channel: number, texture: InternalTexture): void;
  45085. /** @hidden */
  45086. _releaseBuffer(buffer: DataBuffer): boolean;
  45087. releaseEffects(): void;
  45088. displayLoadingUI(): void;
  45089. hideLoadingUI(): void;
  45090. /** @hidden */
  45091. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45092. /** @hidden */
  45093. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45094. /** @hidden */
  45095. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45096. /** @hidden */
  45097. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45098. }
  45099. }
  45100. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45101. import { Nullable, int } from "babylonjs/types";
  45102. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45103. /** @hidden */
  45104. export class _OcclusionDataStorage {
  45105. /** @hidden */
  45106. occlusionInternalRetryCounter: number;
  45107. /** @hidden */
  45108. isOcclusionQueryInProgress: boolean;
  45109. /** @hidden */
  45110. isOccluded: boolean;
  45111. /** @hidden */
  45112. occlusionRetryCount: number;
  45113. /** @hidden */
  45114. occlusionType: number;
  45115. /** @hidden */
  45116. occlusionQueryAlgorithmType: number;
  45117. }
  45118. module "babylonjs/Engines/engine" {
  45119. interface Engine {
  45120. /**
  45121. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45122. * @return the new query
  45123. */
  45124. createQuery(): WebGLQuery;
  45125. /**
  45126. * Delete and release a webGL query
  45127. * @param query defines the query to delete
  45128. * @return the current engine
  45129. */
  45130. deleteQuery(query: WebGLQuery): Engine;
  45131. /**
  45132. * Check if a given query has resolved and got its value
  45133. * @param query defines the query to check
  45134. * @returns true if the query got its value
  45135. */
  45136. isQueryResultAvailable(query: WebGLQuery): boolean;
  45137. /**
  45138. * Gets the value of a given query
  45139. * @param query defines the query to check
  45140. * @returns the value of the query
  45141. */
  45142. getQueryResult(query: WebGLQuery): number;
  45143. /**
  45144. * Initiates an occlusion query
  45145. * @param algorithmType defines the algorithm to use
  45146. * @param query defines the query to use
  45147. * @returns the current engine
  45148. * @see http://doc.babylonjs.com/features/occlusionquery
  45149. */
  45150. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45151. /**
  45152. * Ends an occlusion query
  45153. * @see http://doc.babylonjs.com/features/occlusionquery
  45154. * @param algorithmType defines the algorithm to use
  45155. * @returns the current engine
  45156. */
  45157. endOcclusionQuery(algorithmType: number): Engine;
  45158. /**
  45159. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45160. * Please note that only one query can be issued at a time
  45161. * @returns a time token used to track the time span
  45162. */
  45163. startTimeQuery(): Nullable<_TimeToken>;
  45164. /**
  45165. * Ends a time query
  45166. * @param token defines the token used to measure the time span
  45167. * @returns the time spent (in ns)
  45168. */
  45169. endTimeQuery(token: _TimeToken): int;
  45170. /** @hidden */
  45171. _currentNonTimestampToken: Nullable<_TimeToken>;
  45172. /** @hidden */
  45173. _createTimeQuery(): WebGLQuery;
  45174. /** @hidden */
  45175. _deleteTimeQuery(query: WebGLQuery): void;
  45176. /** @hidden */
  45177. _getGlAlgorithmType(algorithmType: number): number;
  45178. /** @hidden */
  45179. _getTimeQueryResult(query: WebGLQuery): any;
  45180. /** @hidden */
  45181. _getTimeQueryAvailability(query: WebGLQuery): any;
  45182. }
  45183. }
  45184. module "babylonjs/Meshes/abstractMesh" {
  45185. interface AbstractMesh {
  45186. /**
  45187. * Backing filed
  45188. * @hidden
  45189. */
  45190. __occlusionDataStorage: _OcclusionDataStorage;
  45191. /**
  45192. * Access property
  45193. * @hidden
  45194. */
  45195. _occlusionDataStorage: _OcclusionDataStorage;
  45196. /**
  45197. * 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.
  45198. * The default value is -1 which means don't break the query and wait till the result
  45199. * @see http://doc.babylonjs.com/features/occlusionquery
  45200. */
  45201. occlusionRetryCount: number;
  45202. /**
  45203. * 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:
  45204. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45205. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45206. * * 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.
  45207. * @see http://doc.babylonjs.com/features/occlusionquery
  45208. */
  45209. occlusionType: number;
  45210. /**
  45211. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45212. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45213. * * 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.
  45214. * @see http://doc.babylonjs.com/features/occlusionquery
  45215. */
  45216. occlusionQueryAlgorithmType: number;
  45217. /**
  45218. * 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
  45219. * @see http://doc.babylonjs.com/features/occlusionquery
  45220. */
  45221. isOccluded: boolean;
  45222. /**
  45223. * Flag to check the progress status of the query
  45224. * @see http://doc.babylonjs.com/features/occlusionquery
  45225. */
  45226. isOcclusionQueryInProgress: boolean;
  45227. }
  45228. }
  45229. }
  45230. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45231. import { Nullable } from "babylonjs/types";
  45232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45233. /** @hidden */
  45234. export var _forceTransformFeedbackToBundle: boolean;
  45235. module "babylonjs/Engines/engine" {
  45236. interface Engine {
  45237. /**
  45238. * Creates a webGL transform feedback object
  45239. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45240. * @returns the webGL transform feedback object
  45241. */
  45242. createTransformFeedback(): WebGLTransformFeedback;
  45243. /**
  45244. * Delete a webGL transform feedback object
  45245. * @param value defines the webGL transform feedback object to delete
  45246. */
  45247. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45248. /**
  45249. * Bind a webGL transform feedback object to the webgl context
  45250. * @param value defines the webGL transform feedback object to bind
  45251. */
  45252. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45253. /**
  45254. * Begins a transform feedback operation
  45255. * @param usePoints defines if points or triangles must be used
  45256. */
  45257. beginTransformFeedback(usePoints: boolean): void;
  45258. /**
  45259. * Ends a transform feedback operation
  45260. */
  45261. endTransformFeedback(): void;
  45262. /**
  45263. * Specify the varyings to use with transform feedback
  45264. * @param program defines the associated webGL program
  45265. * @param value defines the list of strings representing the varying names
  45266. */
  45267. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45268. /**
  45269. * Bind a webGL buffer for a transform feedback operation
  45270. * @param value defines the webGL buffer to bind
  45271. */
  45272. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45273. }
  45274. }
  45275. }
  45276. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45277. import { Scene } from "babylonjs/scene";
  45278. import { Engine } from "babylonjs/Engines/engine";
  45279. import { Texture } from "babylonjs/Materials/Textures/texture";
  45280. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45281. import "babylonjs/Engines/Extensions/engine.multiRender";
  45282. /**
  45283. * Creation options of the multi render target texture.
  45284. */
  45285. export interface IMultiRenderTargetOptions {
  45286. /**
  45287. * Define if the texture needs to create mip maps after render.
  45288. */
  45289. generateMipMaps?: boolean;
  45290. /**
  45291. * Define the types of all the draw buffers we want to create
  45292. */
  45293. types?: number[];
  45294. /**
  45295. * Define the sampling modes of all the draw buffers we want to create
  45296. */
  45297. samplingModes?: number[];
  45298. /**
  45299. * Define if a depth buffer is required
  45300. */
  45301. generateDepthBuffer?: boolean;
  45302. /**
  45303. * Define if a stencil buffer is required
  45304. */
  45305. generateStencilBuffer?: boolean;
  45306. /**
  45307. * Define if a depth texture is required instead of a depth buffer
  45308. */
  45309. generateDepthTexture?: boolean;
  45310. /**
  45311. * Define the number of desired draw buffers
  45312. */
  45313. textureCount?: number;
  45314. /**
  45315. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45316. */
  45317. doNotChangeAspectRatio?: boolean;
  45318. /**
  45319. * Define the default type of the buffers we are creating
  45320. */
  45321. defaultType?: number;
  45322. }
  45323. /**
  45324. * A multi render target, like a render target provides the ability to render to a texture.
  45325. * Unlike the render target, it can render to several draw buffers in one draw.
  45326. * This is specially interesting in deferred rendering or for any effects requiring more than
  45327. * just one color from a single pass.
  45328. */
  45329. export class MultiRenderTarget extends RenderTargetTexture {
  45330. private _internalTextures;
  45331. private _textures;
  45332. private _multiRenderTargetOptions;
  45333. /**
  45334. * Get if draw buffers are currently supported by the used hardware and browser.
  45335. */
  45336. readonly isSupported: boolean;
  45337. /**
  45338. * Get the list of textures generated by the multi render target.
  45339. */
  45340. readonly textures: Texture[];
  45341. /**
  45342. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45343. */
  45344. readonly depthTexture: Texture;
  45345. /**
  45346. * Set the wrapping mode on U of all the textures we are rendering to.
  45347. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45348. */
  45349. wrapU: number;
  45350. /**
  45351. * Set the wrapping mode on V of all the textures we are rendering to.
  45352. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45353. */
  45354. wrapV: number;
  45355. /**
  45356. * Instantiate a new multi render target texture.
  45357. * A multi render target, like a render target provides the ability to render to a texture.
  45358. * Unlike the render target, it can render to several draw buffers in one draw.
  45359. * This is specially interesting in deferred rendering or for any effects requiring more than
  45360. * just one color from a single pass.
  45361. * @param name Define the name of the texture
  45362. * @param size Define the size of the buffers to render to
  45363. * @param count Define the number of target we are rendering into
  45364. * @param scene Define the scene the texture belongs to
  45365. * @param options Define the options used to create the multi render target
  45366. */
  45367. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45368. /** @hidden */
  45369. _rebuild(): void;
  45370. private _createInternalTextures;
  45371. private _createTextures;
  45372. /**
  45373. * Define the number of samples used if MSAA is enabled.
  45374. */
  45375. samples: number;
  45376. /**
  45377. * Resize all the textures in the multi render target.
  45378. * Be carrefull as it will recreate all the data in the new texture.
  45379. * @param size Define the new size
  45380. */
  45381. resize(size: any): void;
  45382. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45383. /**
  45384. * Dispose the render targets and their associated resources
  45385. */
  45386. dispose(): void;
  45387. /**
  45388. * Release all the underlying texture used as draw buffers.
  45389. */
  45390. releaseInternalTextures(): void;
  45391. }
  45392. }
  45393. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45395. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45396. import { Nullable } from "babylonjs/types";
  45397. module "babylonjs/Engines/engine" {
  45398. interface Engine {
  45399. /**
  45400. * Unbind a list of render target textures from the webGL context
  45401. * This is used only when drawBuffer extension or webGL2 are active
  45402. * @param textures defines the render target textures to unbind
  45403. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45404. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45405. */
  45406. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45407. /**
  45408. * Create a multi render target texture
  45409. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45410. * @param size defines the size of the texture
  45411. * @param options defines the creation options
  45412. * @returns the cube texture as an InternalTexture
  45413. */
  45414. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45415. /**
  45416. * Update the sample count for a given multiple render target texture
  45417. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45418. * @param textures defines the textures to update
  45419. * @param samples defines the sample count to set
  45420. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45421. */
  45422. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45423. }
  45424. }
  45425. }
  45426. declare module "babylonjs/Engines/Extensions/index" {
  45427. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45428. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45429. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45430. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45431. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45432. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45433. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45434. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45435. }
  45436. declare module "babylonjs/Engines/index" {
  45437. export * from "babylonjs/Engines/constants";
  45438. export * from "babylonjs/Engines/engine";
  45439. export * from "babylonjs/Engines/engineStore";
  45440. export * from "babylonjs/Engines/nullEngine";
  45441. export * from "babylonjs/Engines/Extensions/index";
  45442. export * from "babylonjs/Engines/IPipelineContext";
  45443. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45444. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45445. }
  45446. declare module "babylonjs/Events/clipboardEvents" {
  45447. /**
  45448. * Gather the list of clipboard event types as constants.
  45449. */
  45450. export class ClipboardEventTypes {
  45451. /**
  45452. * The clipboard event is fired when a copy command is active (pressed).
  45453. */
  45454. static readonly COPY: number;
  45455. /**
  45456. * The clipboard event is fired when a cut command is active (pressed).
  45457. */
  45458. static readonly CUT: number;
  45459. /**
  45460. * The clipboard event is fired when a paste command is active (pressed).
  45461. */
  45462. static readonly PASTE: number;
  45463. }
  45464. /**
  45465. * This class is used to store clipboard related info for the onClipboardObservable event.
  45466. */
  45467. export class ClipboardInfo {
  45468. /**
  45469. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45470. */
  45471. type: number;
  45472. /**
  45473. * Defines the related dom event
  45474. */
  45475. event: ClipboardEvent;
  45476. /**
  45477. *Creates an instance of ClipboardInfo.
  45478. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45479. * @param event Defines the related dom event
  45480. */
  45481. constructor(
  45482. /**
  45483. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45484. */
  45485. type: number,
  45486. /**
  45487. * Defines the related dom event
  45488. */
  45489. event: ClipboardEvent);
  45490. /**
  45491. * Get the clipboard event's type from the keycode.
  45492. * @param keyCode Defines the keyCode for the current keyboard event.
  45493. * @return {number}
  45494. */
  45495. static GetTypeFromCharacter(keyCode: number): number;
  45496. }
  45497. }
  45498. declare module "babylonjs/Events/index" {
  45499. export * from "babylonjs/Events/keyboardEvents";
  45500. export * from "babylonjs/Events/pointerEvents";
  45501. export * from "babylonjs/Events/clipboardEvents";
  45502. }
  45503. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45504. import { Scene } from "babylonjs/scene";
  45505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45506. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45507. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45508. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45509. /**
  45510. * Google Daydream controller
  45511. */
  45512. export class DaydreamController extends WebVRController {
  45513. /**
  45514. * Base Url for the controller model.
  45515. */
  45516. static MODEL_BASE_URL: string;
  45517. /**
  45518. * File name for the controller model.
  45519. */
  45520. static MODEL_FILENAME: string;
  45521. /**
  45522. * Gamepad Id prefix used to identify Daydream Controller.
  45523. */
  45524. static readonly GAMEPAD_ID_PREFIX: string;
  45525. /**
  45526. * Creates a new DaydreamController from a gamepad
  45527. * @param vrGamepad the gamepad that the controller should be created from
  45528. */
  45529. constructor(vrGamepad: any);
  45530. /**
  45531. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45532. * @param scene scene in which to add meshes
  45533. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45534. */
  45535. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45536. /**
  45537. * Called once for each button that changed state since the last frame
  45538. * @param buttonIdx Which button index changed
  45539. * @param state New state of the button
  45540. * @param changes Which properties on the state changed since last frame
  45541. */
  45542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45543. }
  45544. }
  45545. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45546. import { Scene } from "babylonjs/scene";
  45547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45548. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45549. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45550. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45551. /**
  45552. * Gear VR Controller
  45553. */
  45554. export class GearVRController extends WebVRController {
  45555. /**
  45556. * Base Url for the controller model.
  45557. */
  45558. static MODEL_BASE_URL: string;
  45559. /**
  45560. * File name for the controller model.
  45561. */
  45562. static MODEL_FILENAME: string;
  45563. /**
  45564. * Gamepad Id prefix used to identify this controller.
  45565. */
  45566. static readonly GAMEPAD_ID_PREFIX: string;
  45567. private readonly _buttonIndexToObservableNameMap;
  45568. /**
  45569. * Creates a new GearVRController from a gamepad
  45570. * @param vrGamepad the gamepad that the controller should be created from
  45571. */
  45572. constructor(vrGamepad: any);
  45573. /**
  45574. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45575. * @param scene scene in which to add meshes
  45576. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45577. */
  45578. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45579. /**
  45580. * Called once for each button that changed state since the last frame
  45581. * @param buttonIdx Which button index changed
  45582. * @param state New state of the button
  45583. * @param changes Which properties on the state changed since last frame
  45584. */
  45585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45586. }
  45587. }
  45588. declare module "babylonjs/Gamepads/Controllers/index" {
  45589. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45590. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45591. export * from "babylonjs/Gamepads/Controllers/genericController";
  45592. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45593. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45594. export * from "babylonjs/Gamepads/Controllers/viveController";
  45595. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45596. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45597. }
  45598. declare module "babylonjs/Gamepads/index" {
  45599. export * from "babylonjs/Gamepads/Controllers/index";
  45600. export * from "babylonjs/Gamepads/gamepad";
  45601. export * from "babylonjs/Gamepads/gamepadManager";
  45602. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45603. export * from "babylonjs/Gamepads/xboxGamepad";
  45604. export * from "babylonjs/Gamepads/dualShockGamepad";
  45605. }
  45606. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45607. import { Scene } from "babylonjs/scene";
  45608. import { Vector4 } from "babylonjs/Maths/math.vector";
  45609. import { Color4 } from "babylonjs/Maths/math.color";
  45610. import { Mesh } from "babylonjs/Meshes/mesh";
  45611. import { Nullable } from "babylonjs/types";
  45612. /**
  45613. * Class containing static functions to help procedurally build meshes
  45614. */
  45615. export class PolyhedronBuilder {
  45616. /**
  45617. * Creates a polyhedron mesh
  45618. * * 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
  45619. * * The parameter `size` (positive float, default 1) sets the polygon size
  45620. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45621. * * 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`
  45622. * * 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
  45623. * * 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)`)
  45624. * * 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
  45625. * * 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
  45626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45629. * @param name defines the name of the mesh
  45630. * @param options defines the options used to create the mesh
  45631. * @param scene defines the hosting scene
  45632. * @returns the polyhedron mesh
  45633. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45634. */
  45635. static CreatePolyhedron(name: string, options: {
  45636. type?: number;
  45637. size?: number;
  45638. sizeX?: number;
  45639. sizeY?: number;
  45640. sizeZ?: number;
  45641. custom?: any;
  45642. faceUV?: Vector4[];
  45643. faceColors?: Color4[];
  45644. flat?: boolean;
  45645. updatable?: boolean;
  45646. sideOrientation?: number;
  45647. frontUVs?: Vector4;
  45648. backUVs?: Vector4;
  45649. }, scene?: Nullable<Scene>): Mesh;
  45650. }
  45651. }
  45652. declare module "babylonjs/Gizmos/scaleGizmo" {
  45653. import { Observable } from "babylonjs/Misc/observable";
  45654. import { Nullable } from "babylonjs/types";
  45655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45656. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45657. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45658. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45659. /**
  45660. * Gizmo that enables scaling a mesh along 3 axis
  45661. */
  45662. export class ScaleGizmo extends Gizmo {
  45663. /**
  45664. * Internal gizmo used for interactions on the x axis
  45665. */
  45666. xGizmo: AxisScaleGizmo;
  45667. /**
  45668. * Internal gizmo used for interactions on the y axis
  45669. */
  45670. yGizmo: AxisScaleGizmo;
  45671. /**
  45672. * Internal gizmo used for interactions on the z axis
  45673. */
  45674. zGizmo: AxisScaleGizmo;
  45675. /**
  45676. * Internal gizmo used to scale all axis equally
  45677. */
  45678. uniformScaleGizmo: AxisScaleGizmo;
  45679. private _meshAttached;
  45680. private _updateGizmoRotationToMatchAttachedMesh;
  45681. private _snapDistance;
  45682. private _scaleRatio;
  45683. private _uniformScalingMesh;
  45684. private _octahedron;
  45685. /** Fires an event when any of it's sub gizmos are dragged */
  45686. onDragStartObservable: Observable<unknown>;
  45687. /** Fires an event when any of it's sub gizmos are released from dragging */
  45688. onDragEndObservable: Observable<unknown>;
  45689. attachedMesh: Nullable<AbstractMesh>;
  45690. /**
  45691. * Creates a ScaleGizmo
  45692. * @param gizmoLayer The utility layer the gizmo will be added to
  45693. */
  45694. constructor(gizmoLayer?: UtilityLayerRenderer);
  45695. updateGizmoRotationToMatchAttachedMesh: boolean;
  45696. /**
  45697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45698. */
  45699. snapDistance: number;
  45700. /**
  45701. * Ratio for the scale of the gizmo (Default: 1)
  45702. */
  45703. scaleRatio: number;
  45704. /**
  45705. * Disposes of the gizmo
  45706. */
  45707. dispose(): void;
  45708. }
  45709. }
  45710. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45711. import { Observable } from "babylonjs/Misc/observable";
  45712. import { Nullable } from "babylonjs/types";
  45713. import { Vector3 } from "babylonjs/Maths/math.vector";
  45714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45715. import { Mesh } from "babylonjs/Meshes/mesh";
  45716. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45717. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45718. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45719. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45720. import { Color3 } from "babylonjs/Maths/math.color";
  45721. /**
  45722. * Single axis scale gizmo
  45723. */
  45724. export class AxisScaleGizmo extends Gizmo {
  45725. /**
  45726. * Drag behavior responsible for the gizmos dragging interactions
  45727. */
  45728. dragBehavior: PointerDragBehavior;
  45729. private _pointerObserver;
  45730. /**
  45731. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45732. */
  45733. snapDistance: number;
  45734. /**
  45735. * Event that fires each time the gizmo snaps to a new location.
  45736. * * snapDistance is the the change in distance
  45737. */
  45738. onSnapObservable: Observable<{
  45739. snapDistance: number;
  45740. }>;
  45741. /**
  45742. * If the scaling operation should be done on all axis (default: false)
  45743. */
  45744. uniformScaling: boolean;
  45745. private _isEnabled;
  45746. private _parent;
  45747. private _arrow;
  45748. private _coloredMaterial;
  45749. private _hoverMaterial;
  45750. /**
  45751. * Creates an AxisScaleGizmo
  45752. * @param gizmoLayer The utility layer the gizmo will be added to
  45753. * @param dragAxis The axis which the gizmo will be able to scale on
  45754. * @param color The color of the gizmo
  45755. */
  45756. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45757. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45758. /**
  45759. * If the gizmo is enabled
  45760. */
  45761. isEnabled: boolean;
  45762. /**
  45763. * Disposes of the gizmo
  45764. */
  45765. dispose(): void;
  45766. /**
  45767. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45768. * @param mesh The mesh to replace the default mesh of the gizmo
  45769. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45770. */
  45771. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45772. }
  45773. }
  45774. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45775. import { Observable } from "babylonjs/Misc/observable";
  45776. import { Nullable } from "babylonjs/types";
  45777. import { Vector3 } from "babylonjs/Maths/math.vector";
  45778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45779. import { Mesh } from "babylonjs/Meshes/mesh";
  45780. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45781. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45782. import { Color3 } from "babylonjs/Maths/math.color";
  45783. import "babylonjs/Meshes/Builders/boxBuilder";
  45784. /**
  45785. * Bounding box gizmo
  45786. */
  45787. export class BoundingBoxGizmo extends Gizmo {
  45788. private _lineBoundingBox;
  45789. private _rotateSpheresParent;
  45790. private _scaleBoxesParent;
  45791. private _boundingDimensions;
  45792. private _renderObserver;
  45793. private _pointerObserver;
  45794. private _scaleDragSpeed;
  45795. private _tmpQuaternion;
  45796. private _tmpVector;
  45797. private _tmpRotationMatrix;
  45798. /**
  45799. * 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)
  45800. */
  45801. ignoreChildren: boolean;
  45802. /**
  45803. * 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)
  45804. */
  45805. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45806. /**
  45807. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45808. */
  45809. rotationSphereSize: number;
  45810. /**
  45811. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45812. */
  45813. scaleBoxSize: number;
  45814. /**
  45815. * 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)
  45816. */
  45817. fixedDragMeshScreenSize: boolean;
  45818. /**
  45819. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45820. */
  45821. fixedDragMeshScreenSizeDistanceFactor: number;
  45822. /**
  45823. * Fired when a rotation sphere or scale box is dragged
  45824. */
  45825. onDragStartObservable: Observable<{}>;
  45826. /**
  45827. * Fired when a scale box is dragged
  45828. */
  45829. onScaleBoxDragObservable: Observable<{}>;
  45830. /**
  45831. * Fired when a scale box drag is ended
  45832. */
  45833. onScaleBoxDragEndObservable: Observable<{}>;
  45834. /**
  45835. * Fired when a rotation sphere is dragged
  45836. */
  45837. onRotationSphereDragObservable: Observable<{}>;
  45838. /**
  45839. * Fired when a rotation sphere drag is ended
  45840. */
  45841. onRotationSphereDragEndObservable: Observable<{}>;
  45842. /**
  45843. * 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)
  45844. */
  45845. scalePivot: Nullable<Vector3>;
  45846. /**
  45847. * Mesh used as a pivot to rotate the attached mesh
  45848. */
  45849. private _anchorMesh;
  45850. private _existingMeshScale;
  45851. private _dragMesh;
  45852. private pointerDragBehavior;
  45853. private coloredMaterial;
  45854. private hoverColoredMaterial;
  45855. /**
  45856. * Sets the color of the bounding box gizmo
  45857. * @param color the color to set
  45858. */
  45859. setColor(color: Color3): void;
  45860. /**
  45861. * Creates an BoundingBoxGizmo
  45862. * @param gizmoLayer The utility layer the gizmo will be added to
  45863. * @param color The color of the gizmo
  45864. */
  45865. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45866. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45867. private _selectNode;
  45868. /**
  45869. * Updates the bounding box information for the Gizmo
  45870. */
  45871. updateBoundingBox(): void;
  45872. private _updateRotationSpheres;
  45873. private _updateScaleBoxes;
  45874. /**
  45875. * Enables rotation on the specified axis and disables rotation on the others
  45876. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45877. */
  45878. setEnabledRotationAxis(axis: string): void;
  45879. /**
  45880. * Enables/disables scaling
  45881. * @param enable if scaling should be enabled
  45882. */
  45883. setEnabledScaling(enable: boolean): void;
  45884. private _updateDummy;
  45885. /**
  45886. * Enables a pointer drag behavior on the bounding box of the gizmo
  45887. */
  45888. enableDragBehavior(): void;
  45889. /**
  45890. * Disposes of the gizmo
  45891. */
  45892. dispose(): void;
  45893. /**
  45894. * 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)
  45895. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45896. * @returns the bounding box mesh with the passed in mesh as a child
  45897. */
  45898. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45899. /**
  45900. * CustomMeshes are not supported by this gizmo
  45901. * @param mesh The mesh to replace the default mesh of the gizmo
  45902. */
  45903. setCustomMesh(mesh: Mesh): void;
  45904. }
  45905. }
  45906. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45907. import { Observable } from "babylonjs/Misc/observable";
  45908. import { Nullable } from "babylonjs/types";
  45909. import { Vector3 } from "babylonjs/Maths/math.vector";
  45910. import { Color3 } from "babylonjs/Maths/math.color";
  45911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45912. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45913. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45914. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45915. import "babylonjs/Meshes/Builders/linesBuilder";
  45916. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45917. /**
  45918. * Single plane rotation gizmo
  45919. */
  45920. export class PlaneRotationGizmo extends Gizmo {
  45921. /**
  45922. * Drag behavior responsible for the gizmos dragging interactions
  45923. */
  45924. dragBehavior: PointerDragBehavior;
  45925. private _pointerObserver;
  45926. /**
  45927. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45928. */
  45929. snapDistance: number;
  45930. /**
  45931. * Event that fires each time the gizmo snaps to a new location.
  45932. * * snapDistance is the the change in distance
  45933. */
  45934. onSnapObservable: Observable<{
  45935. snapDistance: number;
  45936. }>;
  45937. private _isEnabled;
  45938. private _parent;
  45939. /**
  45940. * Creates a PlaneRotationGizmo
  45941. * @param gizmoLayer The utility layer the gizmo will be added to
  45942. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45943. * @param color The color of the gizmo
  45944. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45945. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45946. */
  45947. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45948. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45949. /**
  45950. * If the gizmo is enabled
  45951. */
  45952. isEnabled: boolean;
  45953. /**
  45954. * Disposes of the gizmo
  45955. */
  45956. dispose(): void;
  45957. }
  45958. }
  45959. declare module "babylonjs/Gizmos/rotationGizmo" {
  45960. import { Observable } from "babylonjs/Misc/observable";
  45961. import { Nullable } from "babylonjs/types";
  45962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45963. import { Mesh } from "babylonjs/Meshes/mesh";
  45964. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45965. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45966. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45967. /**
  45968. * Gizmo that enables rotating a mesh along 3 axis
  45969. */
  45970. export class RotationGizmo extends Gizmo {
  45971. /**
  45972. * Internal gizmo used for interactions on the x axis
  45973. */
  45974. xGizmo: PlaneRotationGizmo;
  45975. /**
  45976. * Internal gizmo used for interactions on the y axis
  45977. */
  45978. yGizmo: PlaneRotationGizmo;
  45979. /**
  45980. * Internal gizmo used for interactions on the z axis
  45981. */
  45982. zGizmo: PlaneRotationGizmo;
  45983. /** Fires an event when any of it's sub gizmos are dragged */
  45984. onDragStartObservable: Observable<unknown>;
  45985. /** Fires an event when any of it's sub gizmos are released from dragging */
  45986. onDragEndObservable: Observable<unknown>;
  45987. private _meshAttached;
  45988. attachedMesh: Nullable<AbstractMesh>;
  45989. /**
  45990. * Creates a RotationGizmo
  45991. * @param gizmoLayer The utility layer the gizmo will be added to
  45992. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45993. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45994. */
  45995. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45996. updateGizmoRotationToMatchAttachedMesh: boolean;
  45997. /**
  45998. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45999. */
  46000. snapDistance: number;
  46001. /**
  46002. * Ratio for the scale of the gizmo (Default: 1)
  46003. */
  46004. scaleRatio: number;
  46005. /**
  46006. * Disposes of the gizmo
  46007. */
  46008. dispose(): void;
  46009. /**
  46010. * CustomMeshes are not supported by this gizmo
  46011. * @param mesh The mesh to replace the default mesh of the gizmo
  46012. */
  46013. setCustomMesh(mesh: Mesh): void;
  46014. }
  46015. }
  46016. declare module "babylonjs/Gizmos/gizmoManager" {
  46017. import { Observable } from "babylonjs/Misc/observable";
  46018. import { Nullable } from "babylonjs/types";
  46019. import { Scene, IDisposable } from "babylonjs/scene";
  46020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46021. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46022. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46023. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46024. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46025. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46026. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46027. /**
  46028. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46029. */
  46030. export class GizmoManager implements IDisposable {
  46031. private scene;
  46032. /**
  46033. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46034. */
  46035. gizmos: {
  46036. positionGizmo: Nullable<PositionGizmo>;
  46037. rotationGizmo: Nullable<RotationGizmo>;
  46038. scaleGizmo: Nullable<ScaleGizmo>;
  46039. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46040. };
  46041. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46042. clearGizmoOnEmptyPointerEvent: boolean;
  46043. /** Fires an event when the manager is attached to a mesh */
  46044. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46045. private _gizmosEnabled;
  46046. private _pointerObserver;
  46047. private _attachedMesh;
  46048. private _boundingBoxColor;
  46049. private _defaultUtilityLayer;
  46050. private _defaultKeepDepthUtilityLayer;
  46051. /**
  46052. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46053. */
  46054. boundingBoxDragBehavior: SixDofDragBehavior;
  46055. /**
  46056. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46057. */
  46058. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46059. /**
  46060. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46061. */
  46062. usePointerToAttachGizmos: boolean;
  46063. /**
  46064. * Utility layer that the bounding box gizmo belongs to
  46065. */
  46066. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46067. /**
  46068. * Utility layer that all gizmos besides bounding box belong to
  46069. */
  46070. readonly utilityLayer: UtilityLayerRenderer;
  46071. /**
  46072. * Instatiates a gizmo manager
  46073. * @param scene the scene to overlay the gizmos on top of
  46074. */
  46075. constructor(scene: Scene);
  46076. /**
  46077. * Attaches a set of gizmos to the specified mesh
  46078. * @param mesh The mesh the gizmo's should be attached to
  46079. */
  46080. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46081. /**
  46082. * If the position gizmo is enabled
  46083. */
  46084. positionGizmoEnabled: boolean;
  46085. /**
  46086. * If the rotation gizmo is enabled
  46087. */
  46088. rotationGizmoEnabled: boolean;
  46089. /**
  46090. * If the scale gizmo is enabled
  46091. */
  46092. scaleGizmoEnabled: boolean;
  46093. /**
  46094. * If the boundingBox gizmo is enabled
  46095. */
  46096. boundingBoxGizmoEnabled: boolean;
  46097. /**
  46098. * Disposes of the gizmo manager
  46099. */
  46100. dispose(): void;
  46101. }
  46102. }
  46103. declare module "babylonjs/Lights/directionalLight" {
  46104. import { Camera } from "babylonjs/Cameras/camera";
  46105. import { Scene } from "babylonjs/scene";
  46106. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46108. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46109. import { Effect } from "babylonjs/Materials/effect";
  46110. /**
  46111. * A directional light is defined by a direction (what a surprise!).
  46112. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46113. * 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.
  46114. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46115. */
  46116. export class DirectionalLight extends ShadowLight {
  46117. private _shadowFrustumSize;
  46118. /**
  46119. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46120. */
  46121. /**
  46122. * Specifies a fix frustum size for the shadow generation.
  46123. */
  46124. shadowFrustumSize: number;
  46125. private _shadowOrthoScale;
  46126. /**
  46127. * Gets the shadow projection scale against the optimal computed one.
  46128. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46129. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46130. */
  46131. /**
  46132. * Sets the shadow projection scale against the optimal computed one.
  46133. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46134. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46135. */
  46136. shadowOrthoScale: number;
  46137. /**
  46138. * Automatically compute the projection matrix to best fit (including all the casters)
  46139. * on each frame.
  46140. */
  46141. autoUpdateExtends: boolean;
  46142. private _orthoLeft;
  46143. private _orthoRight;
  46144. private _orthoTop;
  46145. private _orthoBottom;
  46146. /**
  46147. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46148. * The directional light is emitted from everywhere in the given direction.
  46149. * It can cast shadows.
  46150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46151. * @param name The friendly name of the light
  46152. * @param direction The direction of the light
  46153. * @param scene The scene the light belongs to
  46154. */
  46155. constructor(name: string, direction: Vector3, scene: Scene);
  46156. /**
  46157. * Returns the string "DirectionalLight".
  46158. * @return The class name
  46159. */
  46160. getClassName(): string;
  46161. /**
  46162. * Returns the integer 1.
  46163. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46164. */
  46165. getTypeID(): number;
  46166. /**
  46167. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46168. * Returns the DirectionalLight Shadow projection matrix.
  46169. */
  46170. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46171. /**
  46172. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46173. * Returns the DirectionalLight Shadow projection matrix.
  46174. */
  46175. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46176. /**
  46177. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46178. * Returns the DirectionalLight Shadow projection matrix.
  46179. */
  46180. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46181. protected _buildUniformLayout(): void;
  46182. /**
  46183. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46184. * @param effect The effect to update
  46185. * @param lightIndex The index of the light in the effect to update
  46186. * @returns The directional light
  46187. */
  46188. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46189. /**
  46190. * Gets the minZ used for shadow according to both the scene and the light.
  46191. *
  46192. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46193. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46194. * @param activeCamera The camera we are returning the min for
  46195. * @returns the depth min z
  46196. */
  46197. getDepthMinZ(activeCamera: Camera): number;
  46198. /**
  46199. * Gets the maxZ used for shadow according to both the scene and the light.
  46200. *
  46201. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46202. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46203. * @param activeCamera The camera we are returning the max for
  46204. * @returns the depth max z
  46205. */
  46206. getDepthMaxZ(activeCamera: Camera): number;
  46207. /**
  46208. * Prepares the list of defines specific to the light type.
  46209. * @param defines the list of defines
  46210. * @param lightIndex defines the index of the light for the effect
  46211. */
  46212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46213. }
  46214. }
  46215. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46216. import { Mesh } from "babylonjs/Meshes/mesh";
  46217. /**
  46218. * Class containing static functions to help procedurally build meshes
  46219. */
  46220. export class HemisphereBuilder {
  46221. /**
  46222. * Creates a hemisphere mesh
  46223. * @param name defines the name of the mesh
  46224. * @param options defines the options used to create the mesh
  46225. * @param scene defines the hosting scene
  46226. * @returns the hemisphere mesh
  46227. */
  46228. static CreateHemisphere(name: string, options: {
  46229. segments?: number;
  46230. diameter?: number;
  46231. sideOrientation?: number;
  46232. }, scene: any): Mesh;
  46233. }
  46234. }
  46235. declare module "babylonjs/Lights/spotLight" {
  46236. import { Nullable } from "babylonjs/types";
  46237. import { Scene } from "babylonjs/scene";
  46238. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46240. import { Effect } from "babylonjs/Materials/effect";
  46241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46242. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46243. /**
  46244. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46245. * These values define a cone of light starting from the position, emitting toward the direction.
  46246. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46247. * and the exponent defines the speed of the decay of the light with distance (reach).
  46248. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46249. */
  46250. export class SpotLight extends ShadowLight {
  46251. private _angle;
  46252. private _innerAngle;
  46253. private _cosHalfAngle;
  46254. private _lightAngleScale;
  46255. private _lightAngleOffset;
  46256. /**
  46257. * Gets the cone angle of the spot light in Radians.
  46258. */
  46259. /**
  46260. * Sets the cone angle of the spot light in Radians.
  46261. */
  46262. angle: number;
  46263. /**
  46264. * Only used in gltf falloff mode, this defines the angle where
  46265. * the directional falloff will start before cutting at angle which could be seen
  46266. * as outer angle.
  46267. */
  46268. /**
  46269. * Only used in gltf falloff mode, this defines the angle where
  46270. * the directional falloff will start before cutting at angle which could be seen
  46271. * as outer angle.
  46272. */
  46273. innerAngle: number;
  46274. private _shadowAngleScale;
  46275. /**
  46276. * Allows scaling the angle of the light for shadow generation only.
  46277. */
  46278. /**
  46279. * Allows scaling the angle of the light for shadow generation only.
  46280. */
  46281. shadowAngleScale: number;
  46282. /**
  46283. * The light decay speed with the distance from the emission spot.
  46284. */
  46285. exponent: number;
  46286. private _projectionTextureMatrix;
  46287. /**
  46288. * Allows reading the projecton texture
  46289. */
  46290. readonly projectionTextureMatrix: Matrix;
  46291. protected _projectionTextureLightNear: number;
  46292. /**
  46293. * Gets the near clip of the Spotlight for texture projection.
  46294. */
  46295. /**
  46296. * Sets the near clip of the Spotlight for texture projection.
  46297. */
  46298. projectionTextureLightNear: number;
  46299. protected _projectionTextureLightFar: number;
  46300. /**
  46301. * Gets the far clip of the Spotlight for texture projection.
  46302. */
  46303. /**
  46304. * Sets the far clip of the Spotlight for texture projection.
  46305. */
  46306. projectionTextureLightFar: number;
  46307. protected _projectionTextureUpDirection: Vector3;
  46308. /**
  46309. * Gets the Up vector of the Spotlight for texture projection.
  46310. */
  46311. /**
  46312. * Sets the Up vector of the Spotlight for texture projection.
  46313. */
  46314. projectionTextureUpDirection: Vector3;
  46315. private _projectionTexture;
  46316. /**
  46317. * Gets the projection texture of the light.
  46318. */
  46319. /**
  46320. * Sets the projection texture of the light.
  46321. */
  46322. projectionTexture: Nullable<BaseTexture>;
  46323. private _projectionTextureViewLightDirty;
  46324. private _projectionTextureProjectionLightDirty;
  46325. private _projectionTextureDirty;
  46326. private _projectionTextureViewTargetVector;
  46327. private _projectionTextureViewLightMatrix;
  46328. private _projectionTextureProjectionLightMatrix;
  46329. private _projectionTextureScalingMatrix;
  46330. /**
  46331. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46332. * It can cast shadows.
  46333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46334. * @param name The light friendly name
  46335. * @param position The position of the spot light in the scene
  46336. * @param direction The direction of the light in the scene
  46337. * @param angle The cone angle of the light in Radians
  46338. * @param exponent The light decay speed with the distance from the emission spot
  46339. * @param scene The scene the lights belongs to
  46340. */
  46341. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46342. /**
  46343. * Returns the string "SpotLight".
  46344. * @returns the class name
  46345. */
  46346. getClassName(): string;
  46347. /**
  46348. * Returns the integer 2.
  46349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46350. */
  46351. getTypeID(): number;
  46352. /**
  46353. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46354. */
  46355. protected _setDirection(value: Vector3): void;
  46356. /**
  46357. * Overrides the position setter to recompute the projection texture view light Matrix.
  46358. */
  46359. protected _setPosition(value: Vector3): void;
  46360. /**
  46361. * 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.
  46362. * Returns the SpotLight.
  46363. */
  46364. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46365. protected _computeProjectionTextureViewLightMatrix(): void;
  46366. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46367. /**
  46368. * Main function for light texture projection matrix computing.
  46369. */
  46370. protected _computeProjectionTextureMatrix(): void;
  46371. protected _buildUniformLayout(): void;
  46372. private _computeAngleValues;
  46373. /**
  46374. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46375. * @param effect The effect to update
  46376. * @param lightIndex The index of the light in the effect to update
  46377. * @returns The spot light
  46378. */
  46379. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46380. /**
  46381. * Disposes the light and the associated resources.
  46382. */
  46383. dispose(): void;
  46384. /**
  46385. * Prepares the list of defines specific to the light type.
  46386. * @param defines the list of defines
  46387. * @param lightIndex defines the index of the light for the effect
  46388. */
  46389. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46390. }
  46391. }
  46392. declare module "babylonjs/Gizmos/lightGizmo" {
  46393. import { Nullable } from "babylonjs/types";
  46394. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46396. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46397. import { Light } from "babylonjs/Lights/light";
  46398. /**
  46399. * Gizmo that enables viewing a light
  46400. */
  46401. export class LightGizmo extends Gizmo {
  46402. private _lightMesh;
  46403. private _material;
  46404. private cachedPosition;
  46405. private cachedForward;
  46406. /**
  46407. * Creates a LightGizmo
  46408. * @param gizmoLayer The utility layer the gizmo will be added to
  46409. */
  46410. constructor(gizmoLayer?: UtilityLayerRenderer);
  46411. private _light;
  46412. /**
  46413. * The light that the gizmo is attached to
  46414. */
  46415. light: Nullable<Light>;
  46416. /**
  46417. * Gets the material used to render the light gizmo
  46418. */
  46419. readonly material: StandardMaterial;
  46420. /**
  46421. * @hidden
  46422. * Updates the gizmo to match the attached mesh's position/rotation
  46423. */
  46424. protected _update(): void;
  46425. private static _Scale;
  46426. /**
  46427. * Creates the lines for a light mesh
  46428. */
  46429. private static _createLightLines;
  46430. /**
  46431. * Disposes of the light gizmo
  46432. */
  46433. dispose(): void;
  46434. private static _CreateHemisphericLightMesh;
  46435. private static _CreatePointLightMesh;
  46436. private static _CreateSpotLightMesh;
  46437. private static _CreateDirectionalLightMesh;
  46438. }
  46439. }
  46440. declare module "babylonjs/Gizmos/index" {
  46441. export * from "babylonjs/Gizmos/axisDragGizmo";
  46442. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46443. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46444. export * from "babylonjs/Gizmos/gizmo";
  46445. export * from "babylonjs/Gizmos/gizmoManager";
  46446. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46447. export * from "babylonjs/Gizmos/positionGizmo";
  46448. export * from "babylonjs/Gizmos/rotationGizmo";
  46449. export * from "babylonjs/Gizmos/scaleGizmo";
  46450. export * from "babylonjs/Gizmos/lightGizmo";
  46451. export * from "babylonjs/Gizmos/planeDragGizmo";
  46452. }
  46453. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46454. /** @hidden */
  46455. export var backgroundFragmentDeclaration: {
  46456. name: string;
  46457. shader: string;
  46458. };
  46459. }
  46460. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46461. /** @hidden */
  46462. export var backgroundUboDeclaration: {
  46463. name: string;
  46464. shader: string;
  46465. };
  46466. }
  46467. declare module "babylonjs/Shaders/background.fragment" {
  46468. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46469. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46470. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46471. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46472. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46473. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46474. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46475. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46476. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46477. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46478. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46479. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46480. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46481. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46482. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46483. /** @hidden */
  46484. export var backgroundPixelShader: {
  46485. name: string;
  46486. shader: string;
  46487. };
  46488. }
  46489. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46490. /** @hidden */
  46491. export var backgroundVertexDeclaration: {
  46492. name: string;
  46493. shader: string;
  46494. };
  46495. }
  46496. declare module "babylonjs/Shaders/background.vertex" {
  46497. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46498. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46499. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46500. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46501. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46502. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46503. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46504. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46505. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46506. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46507. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46508. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46509. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46510. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46511. /** @hidden */
  46512. export var backgroundVertexShader: {
  46513. name: string;
  46514. shader: string;
  46515. };
  46516. }
  46517. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46518. import { Nullable, int, float } from "babylonjs/types";
  46519. import { Scene } from "babylonjs/scene";
  46520. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46523. import { Mesh } from "babylonjs/Meshes/mesh";
  46524. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46525. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46526. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46528. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46529. import { Color3 } from "babylonjs/Maths/math.color";
  46530. import "babylonjs/Shaders/background.fragment";
  46531. import "babylonjs/Shaders/background.vertex";
  46532. /**
  46533. * Background material used to create an efficient environement around your scene.
  46534. */
  46535. export class BackgroundMaterial extends PushMaterial {
  46536. /**
  46537. * Standard reflectance value at parallel view angle.
  46538. */
  46539. static StandardReflectance0: number;
  46540. /**
  46541. * Standard reflectance value at grazing angle.
  46542. */
  46543. static StandardReflectance90: number;
  46544. protected _primaryColor: Color3;
  46545. /**
  46546. * Key light Color (multiply against the environement texture)
  46547. */
  46548. primaryColor: Color3;
  46549. protected __perceptualColor: Nullable<Color3>;
  46550. /**
  46551. * Experimental Internal Use Only.
  46552. *
  46553. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46554. * This acts as a helper to set the primary color to a more "human friendly" value.
  46555. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46556. * output color as close as possible from the chosen value.
  46557. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46558. * part of lighting setup.)
  46559. */
  46560. _perceptualColor: Nullable<Color3>;
  46561. protected _primaryColorShadowLevel: float;
  46562. /**
  46563. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46564. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46565. */
  46566. primaryColorShadowLevel: float;
  46567. protected _primaryColorHighlightLevel: float;
  46568. /**
  46569. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46570. * The primary color is used at the level chosen to define what the white area would look.
  46571. */
  46572. primaryColorHighlightLevel: float;
  46573. protected _reflectionTexture: Nullable<BaseTexture>;
  46574. /**
  46575. * Reflection Texture used in the material.
  46576. * Should be author in a specific way for the best result (refer to the documentation).
  46577. */
  46578. reflectionTexture: Nullable<BaseTexture>;
  46579. protected _reflectionBlur: float;
  46580. /**
  46581. * Reflection Texture level of blur.
  46582. *
  46583. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46584. * texture twice.
  46585. */
  46586. reflectionBlur: float;
  46587. protected _diffuseTexture: Nullable<BaseTexture>;
  46588. /**
  46589. * Diffuse Texture used in the material.
  46590. * Should be author in a specific way for the best result (refer to the documentation).
  46591. */
  46592. diffuseTexture: Nullable<BaseTexture>;
  46593. protected _shadowLights: Nullable<IShadowLight[]>;
  46594. /**
  46595. * Specify the list of lights casting shadow on the material.
  46596. * All scene shadow lights will be included if null.
  46597. */
  46598. shadowLights: Nullable<IShadowLight[]>;
  46599. protected _shadowLevel: float;
  46600. /**
  46601. * Helps adjusting the shadow to a softer level if required.
  46602. * 0 means black shadows and 1 means no shadows.
  46603. */
  46604. shadowLevel: float;
  46605. protected _sceneCenter: Vector3;
  46606. /**
  46607. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46608. * It is usually zero but might be interesting to modify according to your setup.
  46609. */
  46610. sceneCenter: Vector3;
  46611. protected _opacityFresnel: boolean;
  46612. /**
  46613. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46614. * This helps ensuring a nice transition when the camera goes under the ground.
  46615. */
  46616. opacityFresnel: boolean;
  46617. protected _reflectionFresnel: boolean;
  46618. /**
  46619. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46620. * This helps adding a mirror texture on the ground.
  46621. */
  46622. reflectionFresnel: boolean;
  46623. protected _reflectionFalloffDistance: number;
  46624. /**
  46625. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46626. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46627. */
  46628. reflectionFalloffDistance: number;
  46629. protected _reflectionAmount: number;
  46630. /**
  46631. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46632. */
  46633. reflectionAmount: number;
  46634. protected _reflectionReflectance0: number;
  46635. /**
  46636. * This specifies the weight of the reflection at grazing angle.
  46637. */
  46638. reflectionReflectance0: number;
  46639. protected _reflectionReflectance90: number;
  46640. /**
  46641. * This specifies the weight of the reflection at a perpendicular point of view.
  46642. */
  46643. reflectionReflectance90: number;
  46644. /**
  46645. * Sets the reflection reflectance fresnel values according to the default standard
  46646. * empirically know to work well :-)
  46647. */
  46648. reflectionStandardFresnelWeight: number;
  46649. protected _useRGBColor: boolean;
  46650. /**
  46651. * Helps to directly use the maps channels instead of their level.
  46652. */
  46653. useRGBColor: boolean;
  46654. protected _enableNoise: boolean;
  46655. /**
  46656. * This helps reducing the banding effect that could occur on the background.
  46657. */
  46658. enableNoise: boolean;
  46659. /**
  46660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46661. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46662. * Recommended to be keep at 1.0 except for special cases.
  46663. */
  46664. fovMultiplier: number;
  46665. private _fovMultiplier;
  46666. /**
  46667. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46668. */
  46669. useEquirectangularFOV: boolean;
  46670. private _maxSimultaneousLights;
  46671. /**
  46672. * Number of Simultaneous lights allowed on the material.
  46673. */
  46674. maxSimultaneousLights: int;
  46675. /**
  46676. * Default configuration related to image processing available in the Background Material.
  46677. */
  46678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46679. /**
  46680. * Keep track of the image processing observer to allow dispose and replace.
  46681. */
  46682. private _imageProcessingObserver;
  46683. /**
  46684. * Attaches a new image processing configuration to the PBR Material.
  46685. * @param configuration (if null the scene configuration will be use)
  46686. */
  46687. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46688. /**
  46689. * Gets the image processing configuration used either in this material.
  46690. */
  46691. /**
  46692. * Sets the Default image processing configuration used either in the this material.
  46693. *
  46694. * If sets to null, the scene one is in use.
  46695. */
  46696. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46697. /**
  46698. * Gets wether the color curves effect is enabled.
  46699. */
  46700. /**
  46701. * Sets wether the color curves effect is enabled.
  46702. */
  46703. cameraColorCurvesEnabled: boolean;
  46704. /**
  46705. * Gets wether the color grading effect is enabled.
  46706. */
  46707. /**
  46708. * Gets wether the color grading effect is enabled.
  46709. */
  46710. cameraColorGradingEnabled: boolean;
  46711. /**
  46712. * Gets wether tonemapping is enabled or not.
  46713. */
  46714. /**
  46715. * Sets wether tonemapping is enabled or not
  46716. */
  46717. cameraToneMappingEnabled: boolean;
  46718. /**
  46719. * The camera exposure used on this material.
  46720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46721. * This corresponds to a photographic exposure.
  46722. */
  46723. /**
  46724. * The camera exposure used on this material.
  46725. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46726. * This corresponds to a photographic exposure.
  46727. */
  46728. cameraExposure: float;
  46729. /**
  46730. * Gets The camera contrast used on this material.
  46731. */
  46732. /**
  46733. * Sets The camera contrast used on this material.
  46734. */
  46735. cameraContrast: float;
  46736. /**
  46737. * Gets the Color Grading 2D Lookup Texture.
  46738. */
  46739. /**
  46740. * Sets the Color Grading 2D Lookup Texture.
  46741. */
  46742. cameraColorGradingTexture: Nullable<BaseTexture>;
  46743. /**
  46744. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46745. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46746. * 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;
  46747. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46748. */
  46749. /**
  46750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46752. * 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;
  46753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46754. */
  46755. cameraColorCurves: Nullable<ColorCurves>;
  46756. /**
  46757. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46758. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46759. */
  46760. switchToBGR: boolean;
  46761. private _renderTargets;
  46762. private _reflectionControls;
  46763. private _white;
  46764. private _primaryShadowColor;
  46765. private _primaryHighlightColor;
  46766. /**
  46767. * Instantiates a Background Material in the given scene
  46768. * @param name The friendly name of the material
  46769. * @param scene The scene to add the material to
  46770. */
  46771. constructor(name: string, scene: Scene);
  46772. /**
  46773. * Gets a boolean indicating that current material needs to register RTT
  46774. */
  46775. readonly hasRenderTargetTextures: boolean;
  46776. /**
  46777. * The entire material has been created in order to prevent overdraw.
  46778. * @returns false
  46779. */
  46780. needAlphaTesting(): boolean;
  46781. /**
  46782. * The entire material has been created in order to prevent overdraw.
  46783. * @returns true if blending is enable
  46784. */
  46785. needAlphaBlending(): boolean;
  46786. /**
  46787. * Checks wether the material is ready to be rendered for a given mesh.
  46788. * @param mesh The mesh to render
  46789. * @param subMesh The submesh to check against
  46790. * @param useInstances Specify wether or not the material is used with instances
  46791. * @returns true if all the dependencies are ready (Textures, Effects...)
  46792. */
  46793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46794. /**
  46795. * Compute the primary color according to the chosen perceptual color.
  46796. */
  46797. private _computePrimaryColorFromPerceptualColor;
  46798. /**
  46799. * Compute the highlights and shadow colors according to their chosen levels.
  46800. */
  46801. private _computePrimaryColors;
  46802. /**
  46803. * Build the uniform buffer used in the material.
  46804. */
  46805. buildUniformLayout(): void;
  46806. /**
  46807. * Unbind the material.
  46808. */
  46809. unbind(): void;
  46810. /**
  46811. * Bind only the world matrix to the material.
  46812. * @param world The world matrix to bind.
  46813. */
  46814. bindOnlyWorldMatrix(world: Matrix): void;
  46815. /**
  46816. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46817. * @param world The world matrix to bind.
  46818. * @param subMesh The submesh to bind for.
  46819. */
  46820. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46821. /**
  46822. * Dispose the material.
  46823. * @param forceDisposeEffect Force disposal of the associated effect.
  46824. * @param forceDisposeTextures Force disposal of the associated textures.
  46825. */
  46826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46827. /**
  46828. * Clones the material.
  46829. * @param name The cloned name.
  46830. * @returns The cloned material.
  46831. */
  46832. clone(name: string): BackgroundMaterial;
  46833. /**
  46834. * Serializes the current material to its JSON representation.
  46835. * @returns The JSON representation.
  46836. */
  46837. serialize(): any;
  46838. /**
  46839. * Gets the class name of the material
  46840. * @returns "BackgroundMaterial"
  46841. */
  46842. getClassName(): string;
  46843. /**
  46844. * Parse a JSON input to create back a background material.
  46845. * @param source The JSON data to parse
  46846. * @param scene The scene to create the parsed material in
  46847. * @param rootUrl The root url of the assets the material depends upon
  46848. * @returns the instantiated BackgroundMaterial.
  46849. */
  46850. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46851. }
  46852. }
  46853. declare module "babylonjs/Helpers/environmentHelper" {
  46854. import { Observable } from "babylonjs/Misc/observable";
  46855. import { Nullable } from "babylonjs/types";
  46856. import { Scene } from "babylonjs/scene";
  46857. import { Vector3 } from "babylonjs/Maths/math.vector";
  46858. import { Color3 } from "babylonjs/Maths/math.color";
  46859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46860. import { Mesh } from "babylonjs/Meshes/mesh";
  46861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46862. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46863. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46864. import "babylonjs/Meshes/Builders/planeBuilder";
  46865. import "babylonjs/Meshes/Builders/boxBuilder";
  46866. /**
  46867. * Represents the different options available during the creation of
  46868. * a Environment helper.
  46869. *
  46870. * This can control the default ground, skybox and image processing setup of your scene.
  46871. */
  46872. export interface IEnvironmentHelperOptions {
  46873. /**
  46874. * Specifies wether or not to create a ground.
  46875. * True by default.
  46876. */
  46877. createGround: boolean;
  46878. /**
  46879. * Specifies the ground size.
  46880. * 15 by default.
  46881. */
  46882. groundSize: number;
  46883. /**
  46884. * The texture used on the ground for the main color.
  46885. * Comes from the BabylonJS CDN by default.
  46886. *
  46887. * Remarks: Can be either a texture or a url.
  46888. */
  46889. groundTexture: string | BaseTexture;
  46890. /**
  46891. * The color mixed in the ground texture by default.
  46892. * BabylonJS clearColor by default.
  46893. */
  46894. groundColor: Color3;
  46895. /**
  46896. * Specifies the ground opacity.
  46897. * 1 by default.
  46898. */
  46899. groundOpacity: number;
  46900. /**
  46901. * Enables the ground to receive shadows.
  46902. * True by default.
  46903. */
  46904. enableGroundShadow: boolean;
  46905. /**
  46906. * Helps preventing the shadow to be fully black on the ground.
  46907. * 0.5 by default.
  46908. */
  46909. groundShadowLevel: number;
  46910. /**
  46911. * Creates a mirror texture attach to the ground.
  46912. * false by default.
  46913. */
  46914. enableGroundMirror: boolean;
  46915. /**
  46916. * Specifies the ground mirror size ratio.
  46917. * 0.3 by default as the default kernel is 64.
  46918. */
  46919. groundMirrorSizeRatio: number;
  46920. /**
  46921. * Specifies the ground mirror blur kernel size.
  46922. * 64 by default.
  46923. */
  46924. groundMirrorBlurKernel: number;
  46925. /**
  46926. * Specifies the ground mirror visibility amount.
  46927. * 1 by default
  46928. */
  46929. groundMirrorAmount: number;
  46930. /**
  46931. * Specifies the ground mirror reflectance weight.
  46932. * This uses the standard weight of the background material to setup the fresnel effect
  46933. * of the mirror.
  46934. * 1 by default.
  46935. */
  46936. groundMirrorFresnelWeight: number;
  46937. /**
  46938. * Specifies the ground mirror Falloff distance.
  46939. * This can helps reducing the size of the reflection.
  46940. * 0 by Default.
  46941. */
  46942. groundMirrorFallOffDistance: number;
  46943. /**
  46944. * Specifies the ground mirror texture type.
  46945. * Unsigned Int by Default.
  46946. */
  46947. groundMirrorTextureType: number;
  46948. /**
  46949. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46950. * the shown objects.
  46951. */
  46952. groundYBias: number;
  46953. /**
  46954. * Specifies wether or not to create a skybox.
  46955. * True by default.
  46956. */
  46957. createSkybox: boolean;
  46958. /**
  46959. * Specifies the skybox size.
  46960. * 20 by default.
  46961. */
  46962. skyboxSize: number;
  46963. /**
  46964. * The texture used on the skybox for the main color.
  46965. * Comes from the BabylonJS CDN by default.
  46966. *
  46967. * Remarks: Can be either a texture or a url.
  46968. */
  46969. skyboxTexture: string | BaseTexture;
  46970. /**
  46971. * The color mixed in the skybox texture by default.
  46972. * BabylonJS clearColor by default.
  46973. */
  46974. skyboxColor: Color3;
  46975. /**
  46976. * The background rotation around the Y axis of the scene.
  46977. * This helps aligning the key lights of your scene with the background.
  46978. * 0 by default.
  46979. */
  46980. backgroundYRotation: number;
  46981. /**
  46982. * Compute automatically the size of the elements to best fit with the scene.
  46983. */
  46984. sizeAuto: boolean;
  46985. /**
  46986. * Default position of the rootMesh if autoSize is not true.
  46987. */
  46988. rootPosition: Vector3;
  46989. /**
  46990. * Sets up the image processing in the scene.
  46991. * true by default.
  46992. */
  46993. setupImageProcessing: boolean;
  46994. /**
  46995. * The texture used as your environment texture in the scene.
  46996. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46997. *
  46998. * Remarks: Can be either a texture or a url.
  46999. */
  47000. environmentTexture: string | BaseTexture;
  47001. /**
  47002. * The value of the exposure to apply to the scene.
  47003. * 0.6 by default if setupImageProcessing is true.
  47004. */
  47005. cameraExposure: number;
  47006. /**
  47007. * The value of the contrast to apply to the scene.
  47008. * 1.6 by default if setupImageProcessing is true.
  47009. */
  47010. cameraContrast: number;
  47011. /**
  47012. * Specifies wether or not tonemapping should be enabled in the scene.
  47013. * true by default if setupImageProcessing is true.
  47014. */
  47015. toneMappingEnabled: boolean;
  47016. }
  47017. /**
  47018. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47019. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47020. * It also helps with the default setup of your imageProcessing configuration.
  47021. */
  47022. export class EnvironmentHelper {
  47023. /**
  47024. * Default ground texture URL.
  47025. */
  47026. private static _groundTextureCDNUrl;
  47027. /**
  47028. * Default skybox texture URL.
  47029. */
  47030. private static _skyboxTextureCDNUrl;
  47031. /**
  47032. * Default environment texture URL.
  47033. */
  47034. private static _environmentTextureCDNUrl;
  47035. /**
  47036. * Creates the default options for the helper.
  47037. */
  47038. private static _getDefaultOptions;
  47039. private _rootMesh;
  47040. /**
  47041. * Gets the root mesh created by the helper.
  47042. */
  47043. readonly rootMesh: Mesh;
  47044. private _skybox;
  47045. /**
  47046. * Gets the skybox created by the helper.
  47047. */
  47048. readonly skybox: Nullable<Mesh>;
  47049. private _skyboxTexture;
  47050. /**
  47051. * Gets the skybox texture created by the helper.
  47052. */
  47053. readonly skyboxTexture: Nullable<BaseTexture>;
  47054. private _skyboxMaterial;
  47055. /**
  47056. * Gets the skybox material created by the helper.
  47057. */
  47058. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47059. private _ground;
  47060. /**
  47061. * Gets the ground mesh created by the helper.
  47062. */
  47063. readonly ground: Nullable<Mesh>;
  47064. private _groundTexture;
  47065. /**
  47066. * Gets the ground texture created by the helper.
  47067. */
  47068. readonly groundTexture: Nullable<BaseTexture>;
  47069. private _groundMirror;
  47070. /**
  47071. * Gets the ground mirror created by the helper.
  47072. */
  47073. readonly groundMirror: Nullable<MirrorTexture>;
  47074. /**
  47075. * Gets the ground mirror render list to helps pushing the meshes
  47076. * you wish in the ground reflection.
  47077. */
  47078. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47079. private _groundMaterial;
  47080. /**
  47081. * Gets the ground material created by the helper.
  47082. */
  47083. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47084. /**
  47085. * Stores the creation options.
  47086. */
  47087. private readonly _scene;
  47088. private _options;
  47089. /**
  47090. * This observable will be notified with any error during the creation of the environment,
  47091. * mainly texture creation errors.
  47092. */
  47093. onErrorObservable: Observable<{
  47094. message?: string;
  47095. exception?: any;
  47096. }>;
  47097. /**
  47098. * constructor
  47099. * @param options Defines the options we want to customize the helper
  47100. * @param scene The scene to add the material to
  47101. */
  47102. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47103. /**
  47104. * Updates the background according to the new options
  47105. * @param options
  47106. */
  47107. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47108. /**
  47109. * Sets the primary color of all the available elements.
  47110. * @param color the main color to affect to the ground and the background
  47111. */
  47112. setMainColor(color: Color3): void;
  47113. /**
  47114. * Setup the image processing according to the specified options.
  47115. */
  47116. private _setupImageProcessing;
  47117. /**
  47118. * Setup the environment texture according to the specified options.
  47119. */
  47120. private _setupEnvironmentTexture;
  47121. /**
  47122. * Setup the background according to the specified options.
  47123. */
  47124. private _setupBackground;
  47125. /**
  47126. * Get the scene sizes according to the setup.
  47127. */
  47128. private _getSceneSize;
  47129. /**
  47130. * Setup the ground according to the specified options.
  47131. */
  47132. private _setupGround;
  47133. /**
  47134. * Setup the ground material according to the specified options.
  47135. */
  47136. private _setupGroundMaterial;
  47137. /**
  47138. * Setup the ground diffuse texture according to the specified options.
  47139. */
  47140. private _setupGroundDiffuseTexture;
  47141. /**
  47142. * Setup the ground mirror texture according to the specified options.
  47143. */
  47144. private _setupGroundMirrorTexture;
  47145. /**
  47146. * Setup the ground to receive the mirror texture.
  47147. */
  47148. private _setupMirrorInGroundMaterial;
  47149. /**
  47150. * Setup the skybox according to the specified options.
  47151. */
  47152. private _setupSkybox;
  47153. /**
  47154. * Setup the skybox material according to the specified options.
  47155. */
  47156. private _setupSkyboxMaterial;
  47157. /**
  47158. * Setup the skybox reflection texture according to the specified options.
  47159. */
  47160. private _setupSkyboxReflectionTexture;
  47161. private _errorHandler;
  47162. /**
  47163. * Dispose all the elements created by the Helper.
  47164. */
  47165. dispose(): void;
  47166. }
  47167. }
  47168. declare module "babylonjs/Helpers/photoDome" {
  47169. import { Observable } from "babylonjs/Misc/observable";
  47170. import { Nullable } from "babylonjs/types";
  47171. import { Scene } from "babylonjs/scene";
  47172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47173. import { Mesh } from "babylonjs/Meshes/mesh";
  47174. import { Texture } from "babylonjs/Materials/Textures/texture";
  47175. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47176. import "babylonjs/Meshes/Builders/sphereBuilder";
  47177. /**
  47178. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47179. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47180. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47181. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47182. */
  47183. export class PhotoDome extends TransformNode {
  47184. /**
  47185. * Define the image as a Monoscopic panoramic 360 image.
  47186. */
  47187. static readonly MODE_MONOSCOPIC: number;
  47188. /**
  47189. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47190. */
  47191. static readonly MODE_TOPBOTTOM: number;
  47192. /**
  47193. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47194. */
  47195. static readonly MODE_SIDEBYSIDE: number;
  47196. private _useDirectMapping;
  47197. /**
  47198. * The texture being displayed on the sphere
  47199. */
  47200. protected _photoTexture: Texture;
  47201. /**
  47202. * Gets or sets the texture being displayed on the sphere
  47203. */
  47204. photoTexture: Texture;
  47205. /**
  47206. * Observable raised when an error occured while loading the 360 image
  47207. */
  47208. onLoadErrorObservable: Observable<string>;
  47209. /**
  47210. * The skybox material
  47211. */
  47212. protected _material: BackgroundMaterial;
  47213. /**
  47214. * The surface used for the skybox
  47215. */
  47216. protected _mesh: Mesh;
  47217. /**
  47218. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47219. * Also see the options.resolution property.
  47220. */
  47221. fovMultiplier: number;
  47222. private _imageMode;
  47223. /**
  47224. * Gets or set the current video mode for the video. It can be:
  47225. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47226. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47227. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47228. */
  47229. imageMode: number;
  47230. /**
  47231. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47232. * @param name Element's name, child elements will append suffixes for their own names.
  47233. * @param urlsOfPhoto defines the url of the photo to display
  47234. * @param options defines an object containing optional or exposed sub element properties
  47235. * @param onError defines a callback called when an error occured while loading the texture
  47236. */
  47237. constructor(name: string, urlOfPhoto: string, options: {
  47238. resolution?: number;
  47239. size?: number;
  47240. useDirectMapping?: boolean;
  47241. faceForward?: boolean;
  47242. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47243. private _onBeforeCameraRenderObserver;
  47244. private _changeImageMode;
  47245. /**
  47246. * Releases resources associated with this node.
  47247. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47248. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47249. */
  47250. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47251. }
  47252. }
  47253. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47255. /** @hidden */
  47256. export var rgbdDecodePixelShader: {
  47257. name: string;
  47258. shader: string;
  47259. };
  47260. }
  47261. declare module "babylonjs/Misc/brdfTextureTools" {
  47262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47263. import { Scene } from "babylonjs/scene";
  47264. import "babylonjs/Shaders/rgbdDecode.fragment";
  47265. /**
  47266. * Class used to host texture specific utilities
  47267. */
  47268. export class BRDFTextureTools {
  47269. /**
  47270. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47271. * @param texture the texture to expand.
  47272. */
  47273. private static _ExpandDefaultBRDFTexture;
  47274. /**
  47275. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47276. * @param scene defines the hosting scene
  47277. * @returns the environment BRDF texture
  47278. */
  47279. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47280. private static _environmentBRDFBase64Texture;
  47281. }
  47282. }
  47283. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47284. import { Nullable } from "babylonjs/types";
  47285. import { Color3 } from "babylonjs/Maths/math.color";
  47286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47287. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47288. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47289. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47290. import { Engine } from "babylonjs/Engines/engine";
  47291. import { Scene } from "babylonjs/scene";
  47292. /**
  47293. * @hidden
  47294. */
  47295. export interface IMaterialClearCoatDefines {
  47296. CLEARCOAT: boolean;
  47297. CLEARCOAT_DEFAULTIOR: boolean;
  47298. CLEARCOAT_TEXTURE: boolean;
  47299. CLEARCOAT_TEXTUREDIRECTUV: number;
  47300. CLEARCOAT_BUMP: boolean;
  47301. CLEARCOAT_BUMPDIRECTUV: number;
  47302. CLEARCOAT_TINT: boolean;
  47303. CLEARCOAT_TINT_TEXTURE: boolean;
  47304. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47305. /** @hidden */
  47306. _areTexturesDirty: boolean;
  47307. }
  47308. /**
  47309. * Define the code related to the clear coat parameters of the pbr material.
  47310. */
  47311. export class PBRClearCoatConfiguration {
  47312. /**
  47313. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47314. * The default fits with a polyurethane material.
  47315. */
  47316. private static readonly _DefaultIndexOfRefraction;
  47317. private _isEnabled;
  47318. /**
  47319. * Defines if the clear coat is enabled in the material.
  47320. */
  47321. isEnabled: boolean;
  47322. /**
  47323. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47324. */
  47325. intensity: number;
  47326. /**
  47327. * Defines the clear coat layer roughness.
  47328. */
  47329. roughness: number;
  47330. private _indexOfRefraction;
  47331. /**
  47332. * Defines the index of refraction of the clear coat.
  47333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47334. * The default fits with a polyurethane material.
  47335. * Changing the default value is more performance intensive.
  47336. */
  47337. indexOfRefraction: number;
  47338. private _texture;
  47339. /**
  47340. * Stores the clear coat values in a texture.
  47341. */
  47342. texture: Nullable<BaseTexture>;
  47343. private _bumpTexture;
  47344. /**
  47345. * Define the clear coat specific bump texture.
  47346. */
  47347. bumpTexture: Nullable<BaseTexture>;
  47348. private _isTintEnabled;
  47349. /**
  47350. * Defines if the clear coat tint is enabled in the material.
  47351. */
  47352. isTintEnabled: boolean;
  47353. /**
  47354. * Defines the clear coat tint of the material.
  47355. * This is only use if tint is enabled
  47356. */
  47357. tintColor: Color3;
  47358. /**
  47359. * Defines the distance at which the tint color should be found in the
  47360. * clear coat media.
  47361. * This is only use if tint is enabled
  47362. */
  47363. tintColorAtDistance: number;
  47364. /**
  47365. * Defines the clear coat layer thickness.
  47366. * This is only use if tint is enabled
  47367. */
  47368. tintThickness: number;
  47369. private _tintTexture;
  47370. /**
  47371. * Stores the clear tint values in a texture.
  47372. * rgb is tint
  47373. * a is a thickness factor
  47374. */
  47375. tintTexture: Nullable<BaseTexture>;
  47376. /** @hidden */
  47377. private _internalMarkAllSubMeshesAsTexturesDirty;
  47378. /** @hidden */
  47379. _markAllSubMeshesAsTexturesDirty(): void;
  47380. /**
  47381. * Instantiate a new istance of clear coat configuration.
  47382. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47383. */
  47384. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47385. /**
  47386. * Gets wehter the submesh is ready to be used or not.
  47387. * @param defines the list of "defines" to update.
  47388. * @param scene defines the scene the material belongs to.
  47389. * @param engine defines the engine the material belongs to.
  47390. * @param disableBumpMap defines wether the material disables bump or not.
  47391. * @returns - boolean indicating that the submesh is ready or not.
  47392. */
  47393. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47394. /**
  47395. * Checks to see if a texture is used in the material.
  47396. * @param defines the list of "defines" to update.
  47397. * @param scene defines the scene to the material belongs to.
  47398. */
  47399. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47400. /**
  47401. * Binds the material data.
  47402. * @param uniformBuffer defines the Uniform buffer to fill in.
  47403. * @param scene defines the scene the material belongs to.
  47404. * @param engine defines the engine the material belongs to.
  47405. * @param disableBumpMap defines wether the material disables bump or not.
  47406. * @param isFrozen defines wether the material is frozen or not.
  47407. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47408. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47409. */
  47410. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47411. /**
  47412. * Checks to see if a texture is used in the material.
  47413. * @param texture - Base texture to use.
  47414. * @returns - Boolean specifying if a texture is used in the material.
  47415. */
  47416. hasTexture(texture: BaseTexture): boolean;
  47417. /**
  47418. * Returns an array of the actively used textures.
  47419. * @param activeTextures Array of BaseTextures
  47420. */
  47421. getActiveTextures(activeTextures: BaseTexture[]): void;
  47422. /**
  47423. * Returns the animatable textures.
  47424. * @param animatables Array of animatable textures.
  47425. */
  47426. getAnimatables(animatables: IAnimatable[]): void;
  47427. /**
  47428. * Disposes the resources of the material.
  47429. * @param forceDisposeTextures - Forces the disposal of all textures.
  47430. */
  47431. dispose(forceDisposeTextures?: boolean): void;
  47432. /**
  47433. * Get the current class name of the texture useful for serialization or dynamic coding.
  47434. * @returns "PBRClearCoatConfiguration"
  47435. */
  47436. getClassName(): string;
  47437. /**
  47438. * Add fallbacks to the effect fallbacks list.
  47439. * @param defines defines the Base texture to use.
  47440. * @param fallbacks defines the current fallback list.
  47441. * @param currentRank defines the current fallback rank.
  47442. * @returns the new fallback rank.
  47443. */
  47444. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47445. /**
  47446. * Add the required uniforms to the current list.
  47447. * @param uniforms defines the current uniform list.
  47448. */
  47449. static AddUniforms(uniforms: string[]): void;
  47450. /**
  47451. * Add the required samplers to the current list.
  47452. * @param samplers defines the current sampler list.
  47453. */
  47454. static AddSamplers(samplers: string[]): void;
  47455. /**
  47456. * Add the required uniforms to the current buffer.
  47457. * @param uniformBuffer defines the current uniform buffer.
  47458. */
  47459. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47460. /**
  47461. * Makes a duplicate of the current configuration into another one.
  47462. * @param clearCoatConfiguration define the config where to copy the info
  47463. */
  47464. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47465. /**
  47466. * Serializes this clear coat configuration.
  47467. * @returns - An object with the serialized config.
  47468. */
  47469. serialize(): any;
  47470. /**
  47471. * Parses a anisotropy Configuration from a serialized object.
  47472. * @param source - Serialized object.
  47473. * @param scene Defines the scene we are parsing for
  47474. * @param rootUrl Defines the rootUrl to load from
  47475. */
  47476. parse(source: any, scene: Scene, rootUrl: string): void;
  47477. }
  47478. }
  47479. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47480. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47483. import { Vector2 } from "babylonjs/Maths/math.vector";
  47484. import { Scene } from "babylonjs/scene";
  47485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47486. import { Nullable } from "babylonjs/types";
  47487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47488. /**
  47489. * @hidden
  47490. */
  47491. export interface IMaterialAnisotropicDefines {
  47492. ANISOTROPIC: boolean;
  47493. ANISOTROPIC_TEXTURE: boolean;
  47494. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47495. MAINUV1: boolean;
  47496. _areTexturesDirty: boolean;
  47497. _needUVs: boolean;
  47498. }
  47499. /**
  47500. * Define the code related to the anisotropic parameters of the pbr material.
  47501. */
  47502. export class PBRAnisotropicConfiguration {
  47503. private _isEnabled;
  47504. /**
  47505. * Defines if the anisotropy is enabled in the material.
  47506. */
  47507. isEnabled: boolean;
  47508. /**
  47509. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47510. */
  47511. intensity: number;
  47512. /**
  47513. * Defines if the effect is along the tangents, bitangents or in between.
  47514. * By default, the effect is "strectching" the highlights along the tangents.
  47515. */
  47516. direction: Vector2;
  47517. private _texture;
  47518. /**
  47519. * Stores the anisotropy values in a texture.
  47520. * rg is direction (like normal from -1 to 1)
  47521. * b is a intensity
  47522. */
  47523. texture: Nullable<BaseTexture>;
  47524. /** @hidden */
  47525. private _internalMarkAllSubMeshesAsTexturesDirty;
  47526. /** @hidden */
  47527. _markAllSubMeshesAsTexturesDirty(): void;
  47528. /**
  47529. * Instantiate a new istance of anisotropy configuration.
  47530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47531. */
  47532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47533. /**
  47534. * Specifies that the submesh is ready to be used.
  47535. * @param defines the list of "defines" to update.
  47536. * @param scene defines the scene the material belongs to.
  47537. * @returns - boolean indicating that the submesh is ready or not.
  47538. */
  47539. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47540. /**
  47541. * Checks to see if a texture is used in the material.
  47542. * @param defines the list of "defines" to update.
  47543. * @param mesh the mesh we are preparing the defines for.
  47544. * @param scene defines the scene the material belongs to.
  47545. */
  47546. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47547. /**
  47548. * Binds the material data.
  47549. * @param uniformBuffer defines the Uniform buffer to fill in.
  47550. * @param scene defines the scene the material belongs to.
  47551. * @param isFrozen defines wether the material is frozen or not.
  47552. */
  47553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47554. /**
  47555. * Checks to see if a texture is used in the material.
  47556. * @param texture - Base texture to use.
  47557. * @returns - Boolean specifying if a texture is used in the material.
  47558. */
  47559. hasTexture(texture: BaseTexture): boolean;
  47560. /**
  47561. * Returns an array of the actively used textures.
  47562. * @param activeTextures Array of BaseTextures
  47563. */
  47564. getActiveTextures(activeTextures: BaseTexture[]): void;
  47565. /**
  47566. * Returns the animatable textures.
  47567. * @param animatables Array of animatable textures.
  47568. */
  47569. getAnimatables(animatables: IAnimatable[]): void;
  47570. /**
  47571. * Disposes the resources of the material.
  47572. * @param forceDisposeTextures - Forces the disposal of all textures.
  47573. */
  47574. dispose(forceDisposeTextures?: boolean): void;
  47575. /**
  47576. * Get the current class name of the texture useful for serialization or dynamic coding.
  47577. * @returns "PBRAnisotropicConfiguration"
  47578. */
  47579. getClassName(): string;
  47580. /**
  47581. * Add fallbacks to the effect fallbacks list.
  47582. * @param defines defines the Base texture to use.
  47583. * @param fallbacks defines the current fallback list.
  47584. * @param currentRank defines the current fallback rank.
  47585. * @returns the new fallback rank.
  47586. */
  47587. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47588. /**
  47589. * Add the required uniforms to the current list.
  47590. * @param uniforms defines the current uniform list.
  47591. */
  47592. static AddUniforms(uniforms: string[]): void;
  47593. /**
  47594. * Add the required uniforms to the current buffer.
  47595. * @param uniformBuffer defines the current uniform buffer.
  47596. */
  47597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47598. /**
  47599. * Add the required samplers to the current list.
  47600. * @param samplers defines the current sampler list.
  47601. */
  47602. static AddSamplers(samplers: string[]): void;
  47603. /**
  47604. * Makes a duplicate of the current configuration into another one.
  47605. * @param anisotropicConfiguration define the config where to copy the info
  47606. */
  47607. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47608. /**
  47609. * Serializes this anisotropy configuration.
  47610. * @returns - An object with the serialized config.
  47611. */
  47612. serialize(): any;
  47613. /**
  47614. * Parses a anisotropy Configuration from a serialized object.
  47615. * @param source - Serialized object.
  47616. * @param scene Defines the scene we are parsing for
  47617. * @param rootUrl Defines the rootUrl to load from
  47618. */
  47619. parse(source: any, scene: Scene, rootUrl: string): void;
  47620. }
  47621. }
  47622. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47623. import { Scene } from "babylonjs/scene";
  47624. /**
  47625. * @hidden
  47626. */
  47627. export interface IMaterialBRDFDefines {
  47628. BRDF_V_HEIGHT_CORRELATED: boolean;
  47629. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47630. SPHERICAL_HARMONICS: boolean;
  47631. /** @hidden */
  47632. _areMiscDirty: boolean;
  47633. }
  47634. /**
  47635. * Define the code related to the BRDF parameters of the pbr material.
  47636. */
  47637. export class PBRBRDFConfiguration {
  47638. /**
  47639. * Default value used for the energy conservation.
  47640. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47641. */
  47642. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47643. /**
  47644. * Default value used for the Smith Visibility Height Correlated mode.
  47645. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47646. */
  47647. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47648. /**
  47649. * Default value used for the IBL diffuse part.
  47650. * This can help switching back to the polynomials mode globally which is a tiny bit
  47651. * less GPU intensive at the drawback of a lower quality.
  47652. */
  47653. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47654. private _useEnergyConservation;
  47655. /**
  47656. * Defines if the material uses energy conservation.
  47657. */
  47658. useEnergyConservation: boolean;
  47659. private _useSmithVisibilityHeightCorrelated;
  47660. /**
  47661. * LEGACY Mode set to false
  47662. * Defines if the material uses height smith correlated visibility term.
  47663. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47664. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47665. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47666. * Not relying on height correlated will also disable energy conservation.
  47667. */
  47668. useSmithVisibilityHeightCorrelated: boolean;
  47669. private _useSphericalHarmonics;
  47670. /**
  47671. * LEGACY Mode set to false
  47672. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47673. * diffuse part of the IBL.
  47674. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47675. * to the ground truth.
  47676. */
  47677. useSphericalHarmonics: boolean;
  47678. /** @hidden */
  47679. private _internalMarkAllSubMeshesAsMiscDirty;
  47680. /** @hidden */
  47681. _markAllSubMeshesAsMiscDirty(): void;
  47682. /**
  47683. * Instantiate a new istance of clear coat configuration.
  47684. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47685. */
  47686. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47687. /**
  47688. * Checks to see if a texture is used in the material.
  47689. * @param defines the list of "defines" to update.
  47690. */
  47691. prepareDefines(defines: IMaterialBRDFDefines): void;
  47692. /**
  47693. * Get the current class name of the texture useful for serialization or dynamic coding.
  47694. * @returns "PBRClearCoatConfiguration"
  47695. */
  47696. getClassName(): string;
  47697. /**
  47698. * Makes a duplicate of the current configuration into another one.
  47699. * @param brdfConfiguration define the config where to copy the info
  47700. */
  47701. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47702. /**
  47703. * Serializes this BRDF configuration.
  47704. * @returns - An object with the serialized config.
  47705. */
  47706. serialize(): any;
  47707. /**
  47708. * Parses a anisotropy Configuration from a serialized object.
  47709. * @param source - Serialized object.
  47710. * @param scene Defines the scene we are parsing for
  47711. * @param rootUrl Defines the rootUrl to load from
  47712. */
  47713. parse(source: any, scene: Scene, rootUrl: string): void;
  47714. }
  47715. }
  47716. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47717. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47718. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47719. import { Color3 } from "babylonjs/Maths/math.color";
  47720. import { Scene } from "babylonjs/scene";
  47721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47722. import { Nullable } from "babylonjs/types";
  47723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47724. /**
  47725. * @hidden
  47726. */
  47727. export interface IMaterialSheenDefines {
  47728. SHEEN: boolean;
  47729. SHEEN_TEXTURE: boolean;
  47730. SHEEN_TEXTUREDIRECTUV: number;
  47731. SHEEN_LINKWITHALBEDO: boolean;
  47732. /** @hidden */
  47733. _areTexturesDirty: boolean;
  47734. }
  47735. /**
  47736. * Define the code related to the Sheen parameters of the pbr material.
  47737. */
  47738. export class PBRSheenConfiguration {
  47739. private _isEnabled;
  47740. /**
  47741. * Defines if the material uses sheen.
  47742. */
  47743. isEnabled: boolean;
  47744. private _linkSheenWithAlbedo;
  47745. /**
  47746. * Defines if the sheen is linked to the sheen color.
  47747. */
  47748. linkSheenWithAlbedo: boolean;
  47749. /**
  47750. * Defines the sheen intensity.
  47751. */
  47752. intensity: number;
  47753. /**
  47754. * Defines the sheen color.
  47755. */
  47756. color: Color3;
  47757. private _texture;
  47758. /**
  47759. * Stores the sheen tint values in a texture.
  47760. * rgb is tint
  47761. * a is a intensity
  47762. */
  47763. texture: Nullable<BaseTexture>;
  47764. /** @hidden */
  47765. private _internalMarkAllSubMeshesAsTexturesDirty;
  47766. /** @hidden */
  47767. _markAllSubMeshesAsTexturesDirty(): void;
  47768. /**
  47769. * Instantiate a new istance of clear coat configuration.
  47770. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47771. */
  47772. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47773. /**
  47774. * Specifies that the submesh is ready to be used.
  47775. * @param defines the list of "defines" to update.
  47776. * @param scene defines the scene the material belongs to.
  47777. * @returns - boolean indicating that the submesh is ready or not.
  47778. */
  47779. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47780. /**
  47781. * Checks to see if a texture is used in the material.
  47782. * @param defines the list of "defines" to update.
  47783. * @param scene defines the scene the material belongs to.
  47784. */
  47785. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47786. /**
  47787. * Binds the material data.
  47788. * @param uniformBuffer defines the Uniform buffer to fill in.
  47789. * @param scene defines the scene the material belongs to.
  47790. * @param isFrozen defines wether the material is frozen or not.
  47791. */
  47792. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47793. /**
  47794. * Checks to see if a texture is used in the material.
  47795. * @param texture - Base texture to use.
  47796. * @returns - Boolean specifying if a texture is used in the material.
  47797. */
  47798. hasTexture(texture: BaseTexture): boolean;
  47799. /**
  47800. * Returns an array of the actively used textures.
  47801. * @param activeTextures Array of BaseTextures
  47802. */
  47803. getActiveTextures(activeTextures: BaseTexture[]): void;
  47804. /**
  47805. * Returns the animatable textures.
  47806. * @param animatables Array of animatable textures.
  47807. */
  47808. getAnimatables(animatables: IAnimatable[]): void;
  47809. /**
  47810. * Disposes the resources of the material.
  47811. * @param forceDisposeTextures - Forces the disposal of all textures.
  47812. */
  47813. dispose(forceDisposeTextures?: boolean): void;
  47814. /**
  47815. * Get the current class name of the texture useful for serialization or dynamic coding.
  47816. * @returns "PBRSheenConfiguration"
  47817. */
  47818. getClassName(): string;
  47819. /**
  47820. * Add fallbacks to the effect fallbacks list.
  47821. * @param defines defines the Base texture to use.
  47822. * @param fallbacks defines the current fallback list.
  47823. * @param currentRank defines the current fallback rank.
  47824. * @returns the new fallback rank.
  47825. */
  47826. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47827. /**
  47828. * Add the required uniforms to the current list.
  47829. * @param uniforms defines the current uniform list.
  47830. */
  47831. static AddUniforms(uniforms: string[]): void;
  47832. /**
  47833. * Add the required uniforms to the current buffer.
  47834. * @param uniformBuffer defines the current uniform buffer.
  47835. */
  47836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47837. /**
  47838. * Add the required samplers to the current list.
  47839. * @param samplers defines the current sampler list.
  47840. */
  47841. static AddSamplers(samplers: string[]): void;
  47842. /**
  47843. * Makes a duplicate of the current configuration into another one.
  47844. * @param sheenConfiguration define the config where to copy the info
  47845. */
  47846. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47847. /**
  47848. * Serializes this BRDF configuration.
  47849. * @returns - An object with the serialized config.
  47850. */
  47851. serialize(): any;
  47852. /**
  47853. * Parses a anisotropy Configuration from a serialized object.
  47854. * @param source - Serialized object.
  47855. * @param scene Defines the scene we are parsing for
  47856. * @param rootUrl Defines the rootUrl to load from
  47857. */
  47858. parse(source: any, scene: Scene, rootUrl: string): void;
  47859. }
  47860. }
  47861. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47862. import { Nullable } from "babylonjs/types";
  47863. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47864. import { Color3 } from "babylonjs/Maths/math.color";
  47865. import { SmartArray } from "babylonjs/Misc/smartArray";
  47866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47868. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47869. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47870. import { Engine } from "babylonjs/Engines/engine";
  47871. import { Scene } from "babylonjs/scene";
  47872. /**
  47873. * @hidden
  47874. */
  47875. export interface IMaterialSubSurfaceDefines {
  47876. SUBSURFACE: boolean;
  47877. SS_REFRACTION: boolean;
  47878. SS_TRANSLUCENCY: boolean;
  47879. SS_SCATERRING: boolean;
  47880. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47881. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47882. SS_REFRACTIONMAP_3D: boolean;
  47883. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47884. SS_LODINREFRACTIONALPHA: boolean;
  47885. SS_GAMMAREFRACTION: boolean;
  47886. SS_RGBDREFRACTION: boolean;
  47887. SS_LINEARSPECULARREFRACTION: boolean;
  47888. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47889. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47890. /** @hidden */
  47891. _areTexturesDirty: boolean;
  47892. }
  47893. /**
  47894. * Define the code related to the sub surface parameters of the pbr material.
  47895. */
  47896. export class PBRSubSurfaceConfiguration {
  47897. private _isRefractionEnabled;
  47898. /**
  47899. * Defines if the refraction is enabled in the material.
  47900. */
  47901. isRefractionEnabled: boolean;
  47902. private _isTranslucencyEnabled;
  47903. /**
  47904. * Defines if the translucency is enabled in the material.
  47905. */
  47906. isTranslucencyEnabled: boolean;
  47907. private _isScatteringEnabled;
  47908. /**
  47909. * Defines the refraction intensity of the material.
  47910. * The refraction when enabled replaces the Diffuse part of the material.
  47911. * The intensity helps transitionning between diffuse and refraction.
  47912. */
  47913. refractionIntensity: number;
  47914. /**
  47915. * Defines the translucency intensity of the material.
  47916. * When translucency has been enabled, this defines how much of the "translucency"
  47917. * is addded to the diffuse part of the material.
  47918. */
  47919. translucencyIntensity: number;
  47920. /**
  47921. * Defines the scattering intensity of the material.
  47922. * When scattering has been enabled, this defines how much of the "scattered light"
  47923. * is addded to the diffuse part of the material.
  47924. */
  47925. scatteringIntensity: number;
  47926. private _thicknessTexture;
  47927. /**
  47928. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47929. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47930. * 0 would mean minimumThickness
  47931. * 1 would mean maximumThickness
  47932. * The other channels might be use as a mask to vary the different effects intensity.
  47933. */
  47934. thicknessTexture: Nullable<BaseTexture>;
  47935. private _refractionTexture;
  47936. /**
  47937. * Defines the texture to use for refraction.
  47938. */
  47939. refractionTexture: Nullable<BaseTexture>;
  47940. private _indexOfRefraction;
  47941. /**
  47942. * Defines the index of refraction used in the material.
  47943. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47944. */
  47945. indexOfRefraction: number;
  47946. private _invertRefractionY;
  47947. /**
  47948. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47949. */
  47950. invertRefractionY: boolean;
  47951. private _linkRefractionWithTransparency;
  47952. /**
  47953. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47954. * Materials half opaque for instance using refraction could benefit from this control.
  47955. */
  47956. linkRefractionWithTransparency: boolean;
  47957. /**
  47958. * Defines the minimum thickness stored in the thickness map.
  47959. * If no thickness map is defined, this value will be used to simulate thickness.
  47960. */
  47961. minimumThickness: number;
  47962. /**
  47963. * Defines the maximum thickness stored in the thickness map.
  47964. */
  47965. maximumThickness: number;
  47966. /**
  47967. * Defines the volume tint of the material.
  47968. * This is used for both translucency and scattering.
  47969. */
  47970. tintColor: Color3;
  47971. /**
  47972. * Defines the distance at which the tint color should be found in the media.
  47973. * This is used for refraction only.
  47974. */
  47975. tintColorAtDistance: number;
  47976. /**
  47977. * Defines how far each channel transmit through the media.
  47978. * It is defined as a color to simplify it selection.
  47979. */
  47980. diffusionDistance: Color3;
  47981. private _useMaskFromThicknessTexture;
  47982. /**
  47983. * Stores the intensity of the different subsurface effects in the thickness texture.
  47984. * * the green channel is the translucency intensity.
  47985. * * the blue channel is the scattering intensity.
  47986. * * the alpha channel is the refraction intensity.
  47987. */
  47988. useMaskFromThicknessTexture: boolean;
  47989. /** @hidden */
  47990. private _internalMarkAllSubMeshesAsTexturesDirty;
  47991. /** @hidden */
  47992. _markAllSubMeshesAsTexturesDirty(): void;
  47993. /**
  47994. * Instantiate a new istance of sub surface configuration.
  47995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47996. */
  47997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47998. /**
  47999. * Gets wehter the submesh is ready to be used or not.
  48000. * @param defines the list of "defines" to update.
  48001. * @param scene defines the scene the material belongs to.
  48002. * @returns - boolean indicating that the submesh is ready or not.
  48003. */
  48004. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48005. /**
  48006. * Checks to see if a texture is used in the material.
  48007. * @param defines the list of "defines" to update.
  48008. * @param scene defines the scene to the material belongs to.
  48009. */
  48010. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48011. /**
  48012. * Binds the material data.
  48013. * @param uniformBuffer defines the Uniform buffer to fill in.
  48014. * @param scene defines the scene the material belongs to.
  48015. * @param engine defines the engine the material belongs to.
  48016. * @param isFrozen defines wether the material is frozen or not.
  48017. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48018. */
  48019. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48020. /**
  48021. * Unbinds the material from the mesh.
  48022. * @param activeEffect defines the effect that should be unbound from.
  48023. * @returns true if unbound, otherwise false
  48024. */
  48025. unbind(activeEffect: Effect): boolean;
  48026. /**
  48027. * Returns the texture used for refraction or null if none is used.
  48028. * @param scene defines the scene the material belongs to.
  48029. * @returns - Refraction texture if present. If no refraction texture and refraction
  48030. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48031. */
  48032. private _getRefractionTexture;
  48033. /**
  48034. * Returns true if alpha blending should be disabled.
  48035. */
  48036. readonly disableAlphaBlending: boolean;
  48037. /**
  48038. * Fills the list of render target textures.
  48039. * @param renderTargets the list of render targets to update
  48040. */
  48041. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48042. /**
  48043. * Checks to see if a texture is used in the material.
  48044. * @param texture - Base texture to use.
  48045. * @returns - Boolean specifying if a texture is used in the material.
  48046. */
  48047. hasTexture(texture: BaseTexture): boolean;
  48048. /**
  48049. * Gets a boolean indicating that current material needs to register RTT
  48050. * @returns true if this uses a render target otherwise false.
  48051. */
  48052. hasRenderTargetTextures(): boolean;
  48053. /**
  48054. * Returns an array of the actively used textures.
  48055. * @param activeTextures Array of BaseTextures
  48056. */
  48057. getActiveTextures(activeTextures: BaseTexture[]): void;
  48058. /**
  48059. * Returns the animatable textures.
  48060. * @param animatables Array of animatable textures.
  48061. */
  48062. getAnimatables(animatables: IAnimatable[]): void;
  48063. /**
  48064. * Disposes the resources of the material.
  48065. * @param forceDisposeTextures - Forces the disposal of all textures.
  48066. */
  48067. dispose(forceDisposeTextures?: boolean): void;
  48068. /**
  48069. * Get the current class name of the texture useful for serialization or dynamic coding.
  48070. * @returns "PBRSubSurfaceConfiguration"
  48071. */
  48072. getClassName(): string;
  48073. /**
  48074. * Add fallbacks to the effect fallbacks list.
  48075. * @param defines defines the Base texture to use.
  48076. * @param fallbacks defines the current fallback list.
  48077. * @param currentRank defines the current fallback rank.
  48078. * @returns the new fallback rank.
  48079. */
  48080. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48081. /**
  48082. * Add the required uniforms to the current list.
  48083. * @param uniforms defines the current uniform list.
  48084. */
  48085. static AddUniforms(uniforms: string[]): void;
  48086. /**
  48087. * Add the required samplers to the current list.
  48088. * @param samplers defines the current sampler list.
  48089. */
  48090. static AddSamplers(samplers: string[]): void;
  48091. /**
  48092. * Add the required uniforms to the current buffer.
  48093. * @param uniformBuffer defines the current uniform buffer.
  48094. */
  48095. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48096. /**
  48097. * Makes a duplicate of the current configuration into another one.
  48098. * @param configuration define the config where to copy the info
  48099. */
  48100. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48101. /**
  48102. * Serializes this Sub Surface configuration.
  48103. * @returns - An object with the serialized config.
  48104. */
  48105. serialize(): any;
  48106. /**
  48107. * Parses a anisotropy Configuration from a serialized object.
  48108. * @param source - Serialized object.
  48109. * @param scene Defines the scene we are parsing for
  48110. * @param rootUrl Defines the rootUrl to load from
  48111. */
  48112. parse(source: any, scene: Scene, rootUrl: string): void;
  48113. }
  48114. }
  48115. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48116. /** @hidden */
  48117. export var pbrFragmentDeclaration: {
  48118. name: string;
  48119. shader: string;
  48120. };
  48121. }
  48122. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48123. /** @hidden */
  48124. export var pbrUboDeclaration: {
  48125. name: string;
  48126. shader: string;
  48127. };
  48128. }
  48129. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48130. /** @hidden */
  48131. export var pbrFragmentExtraDeclaration: {
  48132. name: string;
  48133. shader: string;
  48134. };
  48135. }
  48136. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48137. /** @hidden */
  48138. export var pbrFragmentSamplersDeclaration: {
  48139. name: string;
  48140. shader: string;
  48141. };
  48142. }
  48143. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48144. /** @hidden */
  48145. export var pbrHelperFunctions: {
  48146. name: string;
  48147. shader: string;
  48148. };
  48149. }
  48150. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48151. /** @hidden */
  48152. export var harmonicsFunctions: {
  48153. name: string;
  48154. shader: string;
  48155. };
  48156. }
  48157. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48158. /** @hidden */
  48159. export var pbrDirectLightingSetupFunctions: {
  48160. name: string;
  48161. shader: string;
  48162. };
  48163. }
  48164. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48165. /** @hidden */
  48166. export var pbrDirectLightingFalloffFunctions: {
  48167. name: string;
  48168. shader: string;
  48169. };
  48170. }
  48171. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48172. /** @hidden */
  48173. export var pbrBRDFFunctions: {
  48174. name: string;
  48175. shader: string;
  48176. };
  48177. }
  48178. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48179. /** @hidden */
  48180. export var pbrDirectLightingFunctions: {
  48181. name: string;
  48182. shader: string;
  48183. };
  48184. }
  48185. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48186. /** @hidden */
  48187. export var pbrIBLFunctions: {
  48188. name: string;
  48189. shader: string;
  48190. };
  48191. }
  48192. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48193. /** @hidden */
  48194. export var pbrDebug: {
  48195. name: string;
  48196. shader: string;
  48197. };
  48198. }
  48199. declare module "babylonjs/Shaders/pbr.fragment" {
  48200. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48201. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48202. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48203. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48204. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48206. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48207. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48208. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48209. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48211. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48212. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48213. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48214. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48215. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48216. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48217. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48218. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48219. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48220. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48221. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48222. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48223. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48224. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48225. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48226. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48227. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48228. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48229. /** @hidden */
  48230. export var pbrPixelShader: {
  48231. name: string;
  48232. shader: string;
  48233. };
  48234. }
  48235. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48236. /** @hidden */
  48237. export var pbrVertexDeclaration: {
  48238. name: string;
  48239. shader: string;
  48240. };
  48241. }
  48242. declare module "babylonjs/Shaders/pbr.vertex" {
  48243. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48244. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48245. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48246. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48247. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48248. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48249. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48251. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48252. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48253. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48256. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48257. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48258. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48259. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48260. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48261. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48262. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48263. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48264. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48265. /** @hidden */
  48266. export var pbrVertexShader: {
  48267. name: string;
  48268. shader: string;
  48269. };
  48270. }
  48271. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48272. import { Nullable } from "babylonjs/types";
  48273. import { Scene } from "babylonjs/scene";
  48274. import { Matrix } from "babylonjs/Maths/math.vector";
  48275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48277. import { Mesh } from "babylonjs/Meshes/mesh";
  48278. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48279. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48280. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48281. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48282. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48283. import { Color3 } from "babylonjs/Maths/math.color";
  48284. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48285. import { Material } from "babylonjs/Materials/material";
  48286. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48287. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48289. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48290. import "babylonjs/Shaders/pbr.fragment";
  48291. import "babylonjs/Shaders/pbr.vertex";
  48292. /**
  48293. * Manages the defines for the PBR Material.
  48294. * @hidden
  48295. */
  48296. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48297. PBR: boolean;
  48298. MAINUV1: boolean;
  48299. MAINUV2: boolean;
  48300. UV1: boolean;
  48301. UV2: boolean;
  48302. ALBEDO: boolean;
  48303. ALBEDODIRECTUV: number;
  48304. VERTEXCOLOR: boolean;
  48305. AMBIENT: boolean;
  48306. AMBIENTDIRECTUV: number;
  48307. AMBIENTINGRAYSCALE: boolean;
  48308. OPACITY: boolean;
  48309. VERTEXALPHA: boolean;
  48310. OPACITYDIRECTUV: number;
  48311. OPACITYRGB: boolean;
  48312. ALPHATEST: boolean;
  48313. DEPTHPREPASS: boolean;
  48314. ALPHABLEND: boolean;
  48315. ALPHAFROMALBEDO: boolean;
  48316. ALPHATESTVALUE: string;
  48317. SPECULAROVERALPHA: boolean;
  48318. RADIANCEOVERALPHA: boolean;
  48319. ALPHAFRESNEL: boolean;
  48320. LINEARALPHAFRESNEL: boolean;
  48321. PREMULTIPLYALPHA: boolean;
  48322. EMISSIVE: boolean;
  48323. EMISSIVEDIRECTUV: number;
  48324. REFLECTIVITY: boolean;
  48325. REFLECTIVITYDIRECTUV: number;
  48326. SPECULARTERM: boolean;
  48327. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48328. MICROSURFACEAUTOMATIC: boolean;
  48329. LODBASEDMICROSFURACE: boolean;
  48330. MICROSURFACEMAP: boolean;
  48331. MICROSURFACEMAPDIRECTUV: number;
  48332. METALLICWORKFLOW: boolean;
  48333. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48334. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48335. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48336. AOSTOREINMETALMAPRED: boolean;
  48337. ENVIRONMENTBRDF: boolean;
  48338. ENVIRONMENTBRDF_RGBD: boolean;
  48339. NORMAL: boolean;
  48340. TANGENT: boolean;
  48341. BUMP: boolean;
  48342. BUMPDIRECTUV: number;
  48343. OBJECTSPACE_NORMALMAP: boolean;
  48344. PARALLAX: boolean;
  48345. PARALLAXOCCLUSION: boolean;
  48346. NORMALXYSCALE: boolean;
  48347. LIGHTMAP: boolean;
  48348. LIGHTMAPDIRECTUV: number;
  48349. USELIGHTMAPASSHADOWMAP: boolean;
  48350. GAMMALIGHTMAP: boolean;
  48351. REFLECTION: boolean;
  48352. REFLECTIONMAP_3D: boolean;
  48353. REFLECTIONMAP_SPHERICAL: boolean;
  48354. REFLECTIONMAP_PLANAR: boolean;
  48355. REFLECTIONMAP_CUBIC: boolean;
  48356. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48357. REFLECTIONMAP_PROJECTION: boolean;
  48358. REFLECTIONMAP_SKYBOX: boolean;
  48359. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48360. REFLECTIONMAP_EXPLICIT: boolean;
  48361. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48362. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48363. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48364. INVERTCUBICMAP: boolean;
  48365. USESPHERICALFROMREFLECTIONMAP: boolean;
  48366. USEIRRADIANCEMAP: boolean;
  48367. SPHERICAL_HARMONICS: boolean;
  48368. USESPHERICALINVERTEX: boolean;
  48369. REFLECTIONMAP_OPPOSITEZ: boolean;
  48370. LODINREFLECTIONALPHA: boolean;
  48371. GAMMAREFLECTION: boolean;
  48372. RGBDREFLECTION: boolean;
  48373. LINEARSPECULARREFLECTION: boolean;
  48374. RADIANCEOCCLUSION: boolean;
  48375. HORIZONOCCLUSION: boolean;
  48376. INSTANCES: boolean;
  48377. NUM_BONE_INFLUENCERS: number;
  48378. BonesPerMesh: number;
  48379. BONETEXTURE: boolean;
  48380. NONUNIFORMSCALING: boolean;
  48381. MORPHTARGETS: boolean;
  48382. MORPHTARGETS_NORMAL: boolean;
  48383. MORPHTARGETS_TANGENT: boolean;
  48384. MORPHTARGETS_UV: boolean;
  48385. NUM_MORPH_INFLUENCERS: number;
  48386. IMAGEPROCESSING: boolean;
  48387. VIGNETTE: boolean;
  48388. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48389. VIGNETTEBLENDMODEOPAQUE: boolean;
  48390. TONEMAPPING: boolean;
  48391. TONEMAPPING_ACES: boolean;
  48392. CONTRAST: boolean;
  48393. COLORCURVES: boolean;
  48394. COLORGRADING: boolean;
  48395. COLORGRADING3D: boolean;
  48396. SAMPLER3DGREENDEPTH: boolean;
  48397. SAMPLER3DBGRMAP: boolean;
  48398. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48399. EXPOSURE: boolean;
  48400. MULTIVIEW: boolean;
  48401. USEPHYSICALLIGHTFALLOFF: boolean;
  48402. USEGLTFLIGHTFALLOFF: boolean;
  48403. TWOSIDEDLIGHTING: boolean;
  48404. SHADOWFLOAT: boolean;
  48405. CLIPPLANE: boolean;
  48406. CLIPPLANE2: boolean;
  48407. CLIPPLANE3: boolean;
  48408. CLIPPLANE4: boolean;
  48409. POINTSIZE: boolean;
  48410. FOG: boolean;
  48411. LOGARITHMICDEPTH: boolean;
  48412. FORCENORMALFORWARD: boolean;
  48413. SPECULARAA: boolean;
  48414. CLEARCOAT: boolean;
  48415. CLEARCOAT_DEFAULTIOR: boolean;
  48416. CLEARCOAT_TEXTURE: boolean;
  48417. CLEARCOAT_TEXTUREDIRECTUV: number;
  48418. CLEARCOAT_BUMP: boolean;
  48419. CLEARCOAT_BUMPDIRECTUV: number;
  48420. CLEARCOAT_TINT: boolean;
  48421. CLEARCOAT_TINT_TEXTURE: boolean;
  48422. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48423. ANISOTROPIC: boolean;
  48424. ANISOTROPIC_TEXTURE: boolean;
  48425. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48426. BRDF_V_HEIGHT_CORRELATED: boolean;
  48427. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48428. SHEEN: boolean;
  48429. SHEEN_TEXTURE: boolean;
  48430. SHEEN_TEXTUREDIRECTUV: number;
  48431. SHEEN_LINKWITHALBEDO: boolean;
  48432. SUBSURFACE: boolean;
  48433. SS_REFRACTION: boolean;
  48434. SS_TRANSLUCENCY: boolean;
  48435. SS_SCATERRING: boolean;
  48436. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48437. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48438. SS_REFRACTIONMAP_3D: boolean;
  48439. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48440. SS_LODINREFRACTIONALPHA: boolean;
  48441. SS_GAMMAREFRACTION: boolean;
  48442. SS_RGBDREFRACTION: boolean;
  48443. SS_LINEARSPECULARREFRACTION: boolean;
  48444. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48445. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48446. UNLIT: boolean;
  48447. DEBUGMODE: number;
  48448. /**
  48449. * Initializes the PBR Material defines.
  48450. */
  48451. constructor();
  48452. /**
  48453. * Resets the PBR Material defines.
  48454. */
  48455. reset(): void;
  48456. }
  48457. /**
  48458. * The Physically based material base class of BJS.
  48459. *
  48460. * This offers the main features of a standard PBR material.
  48461. * For more information, please refer to the documentation :
  48462. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48463. */
  48464. export abstract class PBRBaseMaterial extends PushMaterial {
  48465. /**
  48466. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48467. */
  48468. static readonly PBRMATERIAL_OPAQUE: number;
  48469. /**
  48470. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48471. */
  48472. static readonly PBRMATERIAL_ALPHATEST: number;
  48473. /**
  48474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48475. */
  48476. static readonly PBRMATERIAL_ALPHABLEND: number;
  48477. /**
  48478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48479. * They are also discarded below the alpha cutoff threshold to improve performances.
  48480. */
  48481. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48482. /**
  48483. * Defines the default value of how much AO map is occluding the analytical lights
  48484. * (point spot...).
  48485. */
  48486. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48487. /**
  48488. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48489. */
  48490. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48491. /**
  48492. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48493. * to enhance interoperability with other engines.
  48494. */
  48495. static readonly LIGHTFALLOFF_GLTF: number;
  48496. /**
  48497. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48498. * to enhance interoperability with other materials.
  48499. */
  48500. static readonly LIGHTFALLOFF_STANDARD: number;
  48501. /**
  48502. * Intensity of the direct lights e.g. the four lights available in your scene.
  48503. * This impacts both the direct diffuse and specular highlights.
  48504. */
  48505. protected _directIntensity: number;
  48506. /**
  48507. * Intensity of the emissive part of the material.
  48508. * This helps controlling the emissive effect without modifying the emissive color.
  48509. */
  48510. protected _emissiveIntensity: number;
  48511. /**
  48512. * Intensity of the environment e.g. how much the environment will light the object
  48513. * either through harmonics for rough material or through the refelction for shiny ones.
  48514. */
  48515. protected _environmentIntensity: number;
  48516. /**
  48517. * This is a special control allowing the reduction of the specular highlights coming from the
  48518. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48519. */
  48520. protected _specularIntensity: number;
  48521. /**
  48522. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48523. */
  48524. private _lightingInfos;
  48525. /**
  48526. * Debug Control allowing disabling the bump map on this material.
  48527. */
  48528. protected _disableBumpMap: boolean;
  48529. /**
  48530. * AKA Diffuse Texture in standard nomenclature.
  48531. */
  48532. protected _albedoTexture: Nullable<BaseTexture>;
  48533. /**
  48534. * AKA Occlusion Texture in other nomenclature.
  48535. */
  48536. protected _ambientTexture: Nullable<BaseTexture>;
  48537. /**
  48538. * AKA Occlusion Texture Intensity in other nomenclature.
  48539. */
  48540. protected _ambientTextureStrength: number;
  48541. /**
  48542. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48543. * 1 means it completely occludes it
  48544. * 0 mean it has no impact
  48545. */
  48546. protected _ambientTextureImpactOnAnalyticalLights: number;
  48547. /**
  48548. * Stores the alpha values in a texture.
  48549. */
  48550. protected _opacityTexture: Nullable<BaseTexture>;
  48551. /**
  48552. * Stores the reflection values in a texture.
  48553. */
  48554. protected _reflectionTexture: Nullable<BaseTexture>;
  48555. /**
  48556. * Stores the emissive values in a texture.
  48557. */
  48558. protected _emissiveTexture: Nullable<BaseTexture>;
  48559. /**
  48560. * AKA Specular texture in other nomenclature.
  48561. */
  48562. protected _reflectivityTexture: Nullable<BaseTexture>;
  48563. /**
  48564. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48565. */
  48566. protected _metallicTexture: Nullable<BaseTexture>;
  48567. /**
  48568. * Specifies the metallic scalar of the metallic/roughness workflow.
  48569. * Can also be used to scale the metalness values of the metallic texture.
  48570. */
  48571. protected _metallic: Nullable<number>;
  48572. /**
  48573. * Specifies the roughness scalar of the metallic/roughness workflow.
  48574. * Can also be used to scale the roughness values of the metallic texture.
  48575. */
  48576. protected _roughness: Nullable<number>;
  48577. /**
  48578. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48579. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48580. */
  48581. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48582. /**
  48583. * Stores surface normal data used to displace a mesh in a texture.
  48584. */
  48585. protected _bumpTexture: Nullable<BaseTexture>;
  48586. /**
  48587. * Stores the pre-calculated light information of a mesh in a texture.
  48588. */
  48589. protected _lightmapTexture: Nullable<BaseTexture>;
  48590. /**
  48591. * The color of a material in ambient lighting.
  48592. */
  48593. protected _ambientColor: Color3;
  48594. /**
  48595. * AKA Diffuse Color in other nomenclature.
  48596. */
  48597. protected _albedoColor: Color3;
  48598. /**
  48599. * AKA Specular Color in other nomenclature.
  48600. */
  48601. protected _reflectivityColor: Color3;
  48602. /**
  48603. * The color applied when light is reflected from a material.
  48604. */
  48605. protected _reflectionColor: Color3;
  48606. /**
  48607. * The color applied when light is emitted from a material.
  48608. */
  48609. protected _emissiveColor: Color3;
  48610. /**
  48611. * AKA Glossiness in other nomenclature.
  48612. */
  48613. protected _microSurface: number;
  48614. /**
  48615. * Specifies that the material will use the light map as a show map.
  48616. */
  48617. protected _useLightmapAsShadowmap: boolean;
  48618. /**
  48619. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48620. * makes the reflect vector face the model (under horizon).
  48621. */
  48622. protected _useHorizonOcclusion: boolean;
  48623. /**
  48624. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48625. * too much the area relying on ambient texture to define their ambient occlusion.
  48626. */
  48627. protected _useRadianceOcclusion: boolean;
  48628. /**
  48629. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48630. */
  48631. protected _useAlphaFromAlbedoTexture: boolean;
  48632. /**
  48633. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48634. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48635. */
  48636. protected _useSpecularOverAlpha: boolean;
  48637. /**
  48638. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48639. */
  48640. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48641. /**
  48642. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48643. */
  48644. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48645. /**
  48646. * Specifies if the metallic texture contains the roughness information in its green channel.
  48647. */
  48648. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48649. /**
  48650. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48651. */
  48652. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48653. /**
  48654. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48655. */
  48656. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48657. /**
  48658. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48659. */
  48660. protected _useAmbientInGrayScale: boolean;
  48661. /**
  48662. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48663. * The material will try to infer what glossiness each pixel should be.
  48664. */
  48665. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48666. /**
  48667. * Defines the falloff type used in this material.
  48668. * It by default is Physical.
  48669. */
  48670. protected _lightFalloff: number;
  48671. /**
  48672. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48673. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48674. */
  48675. protected _useRadianceOverAlpha: boolean;
  48676. /**
  48677. * Allows using an object space normal map (instead of tangent space).
  48678. */
  48679. protected _useObjectSpaceNormalMap: boolean;
  48680. /**
  48681. * Allows using the bump map in parallax mode.
  48682. */
  48683. protected _useParallax: boolean;
  48684. /**
  48685. * Allows using the bump map in parallax occlusion mode.
  48686. */
  48687. protected _useParallaxOcclusion: boolean;
  48688. /**
  48689. * Controls the scale bias of the parallax mode.
  48690. */
  48691. protected _parallaxScaleBias: number;
  48692. /**
  48693. * If sets to true, disables all the lights affecting the material.
  48694. */
  48695. protected _disableLighting: boolean;
  48696. /**
  48697. * Number of Simultaneous lights allowed on the material.
  48698. */
  48699. protected _maxSimultaneousLights: number;
  48700. /**
  48701. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48702. */
  48703. protected _invertNormalMapX: boolean;
  48704. /**
  48705. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48706. */
  48707. protected _invertNormalMapY: boolean;
  48708. /**
  48709. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48710. */
  48711. protected _twoSidedLighting: boolean;
  48712. /**
  48713. * Defines the alpha limits in alpha test mode.
  48714. */
  48715. protected _alphaCutOff: number;
  48716. /**
  48717. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48718. */
  48719. protected _forceAlphaTest: boolean;
  48720. /**
  48721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48722. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48723. */
  48724. protected _useAlphaFresnel: boolean;
  48725. /**
  48726. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48727. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48728. */
  48729. protected _useLinearAlphaFresnel: boolean;
  48730. /**
  48731. * The transparency mode of the material.
  48732. */
  48733. protected _transparencyMode: Nullable<number>;
  48734. /**
  48735. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48736. * from cos thetav and roughness:
  48737. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48738. */
  48739. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48740. /**
  48741. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48742. */
  48743. protected _forceIrradianceInFragment: boolean;
  48744. /**
  48745. * Force normal to face away from face.
  48746. */
  48747. protected _forceNormalForward: boolean;
  48748. /**
  48749. * Enables specular anti aliasing in the PBR shader.
  48750. * It will both interacts on the Geometry for analytical and IBL lighting.
  48751. * It also prefilter the roughness map based on the bump values.
  48752. */
  48753. protected _enableSpecularAntiAliasing: boolean;
  48754. /**
  48755. * Default configuration related to image processing available in the PBR Material.
  48756. */
  48757. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48758. /**
  48759. * Keep track of the image processing observer to allow dispose and replace.
  48760. */
  48761. private _imageProcessingObserver;
  48762. /**
  48763. * Attaches a new image processing configuration to the PBR Material.
  48764. * @param configuration
  48765. */
  48766. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48767. /**
  48768. * Stores the available render targets.
  48769. */
  48770. private _renderTargets;
  48771. /**
  48772. * Sets the global ambient color for the material used in lighting calculations.
  48773. */
  48774. private _globalAmbientColor;
  48775. /**
  48776. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48777. */
  48778. private _useLogarithmicDepth;
  48779. /**
  48780. * If set to true, no lighting calculations will be applied.
  48781. */
  48782. private _unlit;
  48783. private _debugMode;
  48784. /**
  48785. * @hidden
  48786. * This is reserved for the inspector.
  48787. * Defines the material debug mode.
  48788. * It helps seeing only some components of the material while troubleshooting.
  48789. */
  48790. debugMode: number;
  48791. /**
  48792. * @hidden
  48793. * This is reserved for the inspector.
  48794. * Specify from where on screen the debug mode should start.
  48795. * The value goes from -1 (full screen) to 1 (not visible)
  48796. * It helps with side by side comparison against the final render
  48797. * This defaults to -1
  48798. */
  48799. private debugLimit;
  48800. /**
  48801. * @hidden
  48802. * This is reserved for the inspector.
  48803. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48804. * You can use the factor to better multiply the final value.
  48805. */
  48806. private debugFactor;
  48807. /**
  48808. * Defines the clear coat layer parameters for the material.
  48809. */
  48810. readonly clearCoat: PBRClearCoatConfiguration;
  48811. /**
  48812. * Defines the anisotropic parameters for the material.
  48813. */
  48814. readonly anisotropy: PBRAnisotropicConfiguration;
  48815. /**
  48816. * Defines the BRDF parameters for the material.
  48817. */
  48818. readonly brdf: PBRBRDFConfiguration;
  48819. /**
  48820. * Defines the Sheen parameters for the material.
  48821. */
  48822. readonly sheen: PBRSheenConfiguration;
  48823. /**
  48824. * Defines the SubSurface parameters for the material.
  48825. */
  48826. readonly subSurface: PBRSubSurfaceConfiguration;
  48827. /**
  48828. * Custom callback helping to override the default shader used in the material.
  48829. */
  48830. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48831. /**
  48832. * Instantiates a new PBRMaterial instance.
  48833. *
  48834. * @param name The material name
  48835. * @param scene The scene the material will be use in.
  48836. */
  48837. constructor(name: string, scene: Scene);
  48838. /**
  48839. * Gets a boolean indicating that current material needs to register RTT
  48840. */
  48841. readonly hasRenderTargetTextures: boolean;
  48842. /**
  48843. * Gets the name of the material class.
  48844. */
  48845. getClassName(): string;
  48846. /**
  48847. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48848. */
  48849. /**
  48850. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48851. */
  48852. useLogarithmicDepth: boolean;
  48853. /**
  48854. * Gets the current transparency mode.
  48855. */
  48856. /**
  48857. * Sets the transparency mode of the material.
  48858. *
  48859. * | Value | Type | Description |
  48860. * | ----- | ----------------------------------- | ----------- |
  48861. * | 0 | OPAQUE | |
  48862. * | 1 | ALPHATEST | |
  48863. * | 2 | ALPHABLEND | |
  48864. * | 3 | ALPHATESTANDBLEND | |
  48865. *
  48866. */
  48867. transparencyMode: Nullable<number>;
  48868. /**
  48869. * Returns true if alpha blending should be disabled.
  48870. */
  48871. private readonly _disableAlphaBlending;
  48872. /**
  48873. * Specifies whether or not this material should be rendered in alpha blend mode.
  48874. */
  48875. needAlphaBlending(): boolean;
  48876. /**
  48877. * Specifies if the mesh will require alpha blending.
  48878. * @param mesh - BJS mesh.
  48879. */
  48880. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48881. /**
  48882. * Specifies whether or not this material should be rendered in alpha test mode.
  48883. */
  48884. needAlphaTesting(): boolean;
  48885. /**
  48886. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48887. */
  48888. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48889. /**
  48890. * Gets the texture used for the alpha test.
  48891. */
  48892. getAlphaTestTexture(): Nullable<BaseTexture>;
  48893. /**
  48894. * Specifies that the submesh is ready to be used.
  48895. * @param mesh - BJS mesh.
  48896. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48897. * @param useInstances - Specifies that instances should be used.
  48898. * @returns - boolean indicating that the submesh is ready or not.
  48899. */
  48900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48901. /**
  48902. * Specifies if the material uses metallic roughness workflow.
  48903. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48904. */
  48905. isMetallicWorkflow(): boolean;
  48906. private _prepareEffect;
  48907. private _prepareDefines;
  48908. /**
  48909. * Force shader compilation
  48910. */
  48911. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48912. clipPlane: boolean;
  48913. }>): void;
  48914. /**
  48915. * Initializes the uniform buffer layout for the shader.
  48916. */
  48917. buildUniformLayout(): void;
  48918. /**
  48919. * Unbinds the material from the mesh
  48920. */
  48921. unbind(): void;
  48922. /**
  48923. * Binds the submesh data.
  48924. * @param world - The world matrix.
  48925. * @param mesh - The BJS mesh.
  48926. * @param subMesh - A submesh of the BJS mesh.
  48927. */
  48928. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48929. /**
  48930. * Returns the animatable textures.
  48931. * @returns - Array of animatable textures.
  48932. */
  48933. getAnimatables(): IAnimatable[];
  48934. /**
  48935. * Returns the texture used for reflections.
  48936. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48937. */
  48938. private _getReflectionTexture;
  48939. /**
  48940. * Returns an array of the actively used textures.
  48941. * @returns - Array of BaseTextures
  48942. */
  48943. getActiveTextures(): BaseTexture[];
  48944. /**
  48945. * Checks to see if a texture is used in the material.
  48946. * @param texture - Base texture to use.
  48947. * @returns - Boolean specifying if a texture is used in the material.
  48948. */
  48949. hasTexture(texture: BaseTexture): boolean;
  48950. /**
  48951. * Disposes the resources of the material.
  48952. * @param forceDisposeEffect - Forces the disposal of effects.
  48953. * @param forceDisposeTextures - Forces the disposal of all textures.
  48954. */
  48955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48956. }
  48957. }
  48958. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48959. import { Nullable } from "babylonjs/types";
  48960. import { Scene } from "babylonjs/scene";
  48961. import { Color3 } from "babylonjs/Maths/math.color";
  48962. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48963. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48965. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48966. /**
  48967. * The Physically based material of BJS.
  48968. *
  48969. * This offers the main features of a standard PBR material.
  48970. * For more information, please refer to the documentation :
  48971. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48972. */
  48973. export class PBRMaterial extends PBRBaseMaterial {
  48974. /**
  48975. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48976. */
  48977. static readonly PBRMATERIAL_OPAQUE: number;
  48978. /**
  48979. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48980. */
  48981. static readonly PBRMATERIAL_ALPHATEST: number;
  48982. /**
  48983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48984. */
  48985. static readonly PBRMATERIAL_ALPHABLEND: number;
  48986. /**
  48987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48988. * They are also discarded below the alpha cutoff threshold to improve performances.
  48989. */
  48990. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48991. /**
  48992. * Defines the default value of how much AO map is occluding the analytical lights
  48993. * (point spot...).
  48994. */
  48995. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48996. /**
  48997. * Intensity of the direct lights e.g. the four lights available in your scene.
  48998. * This impacts both the direct diffuse and specular highlights.
  48999. */
  49000. directIntensity: number;
  49001. /**
  49002. * Intensity of the emissive part of the material.
  49003. * This helps controlling the emissive effect without modifying the emissive color.
  49004. */
  49005. emissiveIntensity: number;
  49006. /**
  49007. * Intensity of the environment e.g. how much the environment will light the object
  49008. * either through harmonics for rough material or through the refelction for shiny ones.
  49009. */
  49010. environmentIntensity: number;
  49011. /**
  49012. * This is a special control allowing the reduction of the specular highlights coming from the
  49013. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49014. */
  49015. specularIntensity: number;
  49016. /**
  49017. * Debug Control allowing disabling the bump map on this material.
  49018. */
  49019. disableBumpMap: boolean;
  49020. /**
  49021. * AKA Diffuse Texture in standard nomenclature.
  49022. */
  49023. albedoTexture: BaseTexture;
  49024. /**
  49025. * AKA Occlusion Texture in other nomenclature.
  49026. */
  49027. ambientTexture: BaseTexture;
  49028. /**
  49029. * AKA Occlusion Texture Intensity in other nomenclature.
  49030. */
  49031. ambientTextureStrength: number;
  49032. /**
  49033. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49034. * 1 means it completely occludes it
  49035. * 0 mean it has no impact
  49036. */
  49037. ambientTextureImpactOnAnalyticalLights: number;
  49038. /**
  49039. * Stores the alpha values in a texture.
  49040. */
  49041. opacityTexture: BaseTexture;
  49042. /**
  49043. * Stores the reflection values in a texture.
  49044. */
  49045. reflectionTexture: Nullable<BaseTexture>;
  49046. /**
  49047. * Stores the emissive values in a texture.
  49048. */
  49049. emissiveTexture: BaseTexture;
  49050. /**
  49051. * AKA Specular texture in other nomenclature.
  49052. */
  49053. reflectivityTexture: BaseTexture;
  49054. /**
  49055. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49056. */
  49057. metallicTexture: BaseTexture;
  49058. /**
  49059. * Specifies the metallic scalar of the metallic/roughness workflow.
  49060. * Can also be used to scale the metalness values of the metallic texture.
  49061. */
  49062. metallic: Nullable<number>;
  49063. /**
  49064. * Specifies the roughness scalar of the metallic/roughness workflow.
  49065. * Can also be used to scale the roughness values of the metallic texture.
  49066. */
  49067. roughness: Nullable<number>;
  49068. /**
  49069. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49070. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49071. */
  49072. microSurfaceTexture: BaseTexture;
  49073. /**
  49074. * Stores surface normal data used to displace a mesh in a texture.
  49075. */
  49076. bumpTexture: BaseTexture;
  49077. /**
  49078. * Stores the pre-calculated light information of a mesh in a texture.
  49079. */
  49080. lightmapTexture: BaseTexture;
  49081. /**
  49082. * Stores the refracted light information in a texture.
  49083. */
  49084. refractionTexture: Nullable<BaseTexture>;
  49085. /**
  49086. * The color of a material in ambient lighting.
  49087. */
  49088. ambientColor: Color3;
  49089. /**
  49090. * AKA Diffuse Color in other nomenclature.
  49091. */
  49092. albedoColor: Color3;
  49093. /**
  49094. * AKA Specular Color in other nomenclature.
  49095. */
  49096. reflectivityColor: Color3;
  49097. /**
  49098. * The color reflected from the material.
  49099. */
  49100. reflectionColor: Color3;
  49101. /**
  49102. * The color emitted from the material.
  49103. */
  49104. emissiveColor: Color3;
  49105. /**
  49106. * AKA Glossiness in other nomenclature.
  49107. */
  49108. microSurface: number;
  49109. /**
  49110. * source material index of refraction (IOR)' / 'destination material IOR.
  49111. */
  49112. indexOfRefraction: number;
  49113. /**
  49114. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49115. */
  49116. invertRefractionY: boolean;
  49117. /**
  49118. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49119. * Materials half opaque for instance using refraction could benefit from this control.
  49120. */
  49121. linkRefractionWithTransparency: boolean;
  49122. /**
  49123. * If true, the light map contains occlusion information instead of lighting info.
  49124. */
  49125. useLightmapAsShadowmap: boolean;
  49126. /**
  49127. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49128. */
  49129. useAlphaFromAlbedoTexture: boolean;
  49130. /**
  49131. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49132. */
  49133. forceAlphaTest: boolean;
  49134. /**
  49135. * Defines the alpha limits in alpha test mode.
  49136. */
  49137. alphaCutOff: number;
  49138. /**
  49139. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49140. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49141. */
  49142. useSpecularOverAlpha: boolean;
  49143. /**
  49144. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49145. */
  49146. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49147. /**
  49148. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49149. */
  49150. useRoughnessFromMetallicTextureAlpha: boolean;
  49151. /**
  49152. * Specifies if the metallic texture contains the roughness information in its green channel.
  49153. */
  49154. useRoughnessFromMetallicTextureGreen: boolean;
  49155. /**
  49156. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49157. */
  49158. useMetallnessFromMetallicTextureBlue: boolean;
  49159. /**
  49160. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49161. */
  49162. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49163. /**
  49164. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49165. */
  49166. useAmbientInGrayScale: boolean;
  49167. /**
  49168. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49169. * The material will try to infer what glossiness each pixel should be.
  49170. */
  49171. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49172. /**
  49173. * BJS is using an harcoded light falloff based on a manually sets up range.
  49174. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49175. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49176. */
  49177. /**
  49178. * BJS is using an harcoded light falloff based on a manually sets up range.
  49179. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49180. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49181. */
  49182. usePhysicalLightFalloff: boolean;
  49183. /**
  49184. * In order to support the falloff compatibility with gltf, a special mode has been added
  49185. * to reproduce the gltf light falloff.
  49186. */
  49187. /**
  49188. * In order to support the falloff compatibility with gltf, a special mode has been added
  49189. * to reproduce the gltf light falloff.
  49190. */
  49191. useGLTFLightFalloff: boolean;
  49192. /**
  49193. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49194. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49195. */
  49196. useRadianceOverAlpha: boolean;
  49197. /**
  49198. * Allows using an object space normal map (instead of tangent space).
  49199. */
  49200. useObjectSpaceNormalMap: boolean;
  49201. /**
  49202. * Allows using the bump map in parallax mode.
  49203. */
  49204. useParallax: boolean;
  49205. /**
  49206. * Allows using the bump map in parallax occlusion mode.
  49207. */
  49208. useParallaxOcclusion: boolean;
  49209. /**
  49210. * Controls the scale bias of the parallax mode.
  49211. */
  49212. parallaxScaleBias: number;
  49213. /**
  49214. * If sets to true, disables all the lights affecting the material.
  49215. */
  49216. disableLighting: boolean;
  49217. /**
  49218. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49219. */
  49220. forceIrradianceInFragment: boolean;
  49221. /**
  49222. * Number of Simultaneous lights allowed on the material.
  49223. */
  49224. maxSimultaneousLights: number;
  49225. /**
  49226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49227. */
  49228. invertNormalMapX: boolean;
  49229. /**
  49230. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49231. */
  49232. invertNormalMapY: boolean;
  49233. /**
  49234. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49235. */
  49236. twoSidedLighting: boolean;
  49237. /**
  49238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49239. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49240. */
  49241. useAlphaFresnel: boolean;
  49242. /**
  49243. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49244. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49245. */
  49246. useLinearAlphaFresnel: boolean;
  49247. /**
  49248. * Let user defines the brdf lookup texture used for IBL.
  49249. * A default 8bit version is embedded but you could point at :
  49250. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49251. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49252. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49253. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49254. */
  49255. environmentBRDFTexture: Nullable<BaseTexture>;
  49256. /**
  49257. * Force normal to face away from face.
  49258. */
  49259. forceNormalForward: boolean;
  49260. /**
  49261. * Enables specular anti aliasing in the PBR shader.
  49262. * It will both interacts on the Geometry for analytical and IBL lighting.
  49263. * It also prefilter the roughness map based on the bump values.
  49264. */
  49265. enableSpecularAntiAliasing: boolean;
  49266. /**
  49267. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49268. * makes the reflect vector face the model (under horizon).
  49269. */
  49270. useHorizonOcclusion: boolean;
  49271. /**
  49272. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49273. * too much the area relying on ambient texture to define their ambient occlusion.
  49274. */
  49275. useRadianceOcclusion: boolean;
  49276. /**
  49277. * If set to true, no lighting calculations will be applied.
  49278. */
  49279. unlit: boolean;
  49280. /**
  49281. * Gets the image processing configuration used either in this material.
  49282. */
  49283. /**
  49284. * Sets the Default image processing configuration used either in the this material.
  49285. *
  49286. * If sets to null, the scene one is in use.
  49287. */
  49288. imageProcessingConfiguration: ImageProcessingConfiguration;
  49289. /**
  49290. * Gets wether the color curves effect is enabled.
  49291. */
  49292. /**
  49293. * Sets wether the color curves effect is enabled.
  49294. */
  49295. cameraColorCurvesEnabled: boolean;
  49296. /**
  49297. * Gets wether the color grading effect is enabled.
  49298. */
  49299. /**
  49300. * Gets wether the color grading effect is enabled.
  49301. */
  49302. cameraColorGradingEnabled: boolean;
  49303. /**
  49304. * Gets wether tonemapping is enabled or not.
  49305. */
  49306. /**
  49307. * Sets wether tonemapping is enabled or not
  49308. */
  49309. cameraToneMappingEnabled: boolean;
  49310. /**
  49311. * The camera exposure used on this material.
  49312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49313. * This corresponds to a photographic exposure.
  49314. */
  49315. /**
  49316. * The camera exposure used on this material.
  49317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49318. * This corresponds to a photographic exposure.
  49319. */
  49320. cameraExposure: number;
  49321. /**
  49322. * Gets The camera contrast used on this material.
  49323. */
  49324. /**
  49325. * Sets The camera contrast used on this material.
  49326. */
  49327. cameraContrast: number;
  49328. /**
  49329. * Gets the Color Grading 2D Lookup Texture.
  49330. */
  49331. /**
  49332. * Sets the Color Grading 2D Lookup Texture.
  49333. */
  49334. cameraColorGradingTexture: Nullable<BaseTexture>;
  49335. /**
  49336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49338. * 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;
  49339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49340. */
  49341. /**
  49342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49344. * 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;
  49345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49346. */
  49347. cameraColorCurves: Nullable<ColorCurves>;
  49348. /**
  49349. * Instantiates a new PBRMaterial instance.
  49350. *
  49351. * @param name The material name
  49352. * @param scene The scene the material will be use in.
  49353. */
  49354. constructor(name: string, scene: Scene);
  49355. /**
  49356. * Returns the name of this material class.
  49357. */
  49358. getClassName(): string;
  49359. /**
  49360. * Makes a duplicate of the current material.
  49361. * @param name - name to use for the new material.
  49362. */
  49363. clone(name: string): PBRMaterial;
  49364. /**
  49365. * Serializes this PBR Material.
  49366. * @returns - An object with the serialized material.
  49367. */
  49368. serialize(): any;
  49369. /**
  49370. * Parses a PBR Material from a serialized object.
  49371. * @param source - Serialized object.
  49372. * @param scene - BJS scene instance.
  49373. * @param rootUrl - url for the scene object
  49374. * @returns - PBRMaterial
  49375. */
  49376. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49377. }
  49378. }
  49379. declare module "babylonjs/Misc/dds" {
  49380. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49381. import { Engine } from "babylonjs/Engines/engine";
  49382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49383. import { Nullable } from "babylonjs/types";
  49384. import { Scene } from "babylonjs/scene";
  49385. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49386. /**
  49387. * Direct draw surface info
  49388. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49389. */
  49390. export interface DDSInfo {
  49391. /**
  49392. * Width of the texture
  49393. */
  49394. width: number;
  49395. /**
  49396. * Width of the texture
  49397. */
  49398. height: number;
  49399. /**
  49400. * Number of Mipmaps for the texture
  49401. * @see https://en.wikipedia.org/wiki/Mipmap
  49402. */
  49403. mipmapCount: number;
  49404. /**
  49405. * If the textures format is a known fourCC format
  49406. * @see https://www.fourcc.org/
  49407. */
  49408. isFourCC: boolean;
  49409. /**
  49410. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49411. */
  49412. isRGB: boolean;
  49413. /**
  49414. * If the texture is a lumincance format
  49415. */
  49416. isLuminance: boolean;
  49417. /**
  49418. * If this is a cube texture
  49419. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49420. */
  49421. isCube: boolean;
  49422. /**
  49423. * If the texture is a compressed format eg. FOURCC_DXT1
  49424. */
  49425. isCompressed: boolean;
  49426. /**
  49427. * The dxgiFormat of the texture
  49428. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49429. */
  49430. dxgiFormat: number;
  49431. /**
  49432. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49433. */
  49434. textureType: number;
  49435. /**
  49436. * Sphericle polynomial created for the dds texture
  49437. */
  49438. sphericalPolynomial?: SphericalPolynomial;
  49439. }
  49440. /**
  49441. * Class used to provide DDS decompression tools
  49442. */
  49443. export class DDSTools {
  49444. /**
  49445. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49446. */
  49447. static StoreLODInAlphaChannel: boolean;
  49448. /**
  49449. * Gets DDS information from an array buffer
  49450. * @param arrayBuffer defines the array buffer to read data from
  49451. * @returns the DDS information
  49452. */
  49453. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49454. private static _FloatView;
  49455. private static _Int32View;
  49456. private static _ToHalfFloat;
  49457. private static _FromHalfFloat;
  49458. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49459. private static _GetHalfFloatRGBAArrayBuffer;
  49460. private static _GetFloatRGBAArrayBuffer;
  49461. private static _GetFloatAsUIntRGBAArrayBuffer;
  49462. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49463. private static _GetRGBAArrayBuffer;
  49464. private static _ExtractLongWordOrder;
  49465. private static _GetRGBArrayBuffer;
  49466. private static _GetLuminanceArrayBuffer;
  49467. /**
  49468. * Uploads DDS Levels to a Babylon Texture
  49469. * @hidden
  49470. */
  49471. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49472. }
  49473. module "babylonjs/Engines/engine" {
  49474. interface Engine {
  49475. /**
  49476. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49477. * @param rootUrl defines the url where the file to load is located
  49478. * @param scene defines the current scene
  49479. * @param lodScale defines scale to apply to the mip map selection
  49480. * @param lodOffset defines offset to apply to the mip map selection
  49481. * @param onLoad defines an optional callback raised when the texture is loaded
  49482. * @param onError defines an optional callback raised if there is an issue to load the texture
  49483. * @param format defines the format of the data
  49484. * @param forcedExtension defines the extension to use to pick the right loader
  49485. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49486. * @returns the cube texture as an InternalTexture
  49487. */
  49488. 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;
  49489. }
  49490. }
  49491. }
  49492. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49493. import { Nullable } from "babylonjs/types";
  49494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49495. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49496. /**
  49497. * Implementation of the DDS Texture Loader.
  49498. * @hidden
  49499. */
  49500. export class _DDSTextureLoader implements IInternalTextureLoader {
  49501. /**
  49502. * Defines wether the loader supports cascade loading the different faces.
  49503. */
  49504. readonly supportCascades: boolean;
  49505. /**
  49506. * This returns if the loader support the current file information.
  49507. * @param extension defines the file extension of the file being loaded
  49508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49509. * @param fallback defines the fallback internal texture if any
  49510. * @param isBase64 defines whether the texture is encoded as a base64
  49511. * @param isBuffer defines whether the texture data are stored as a buffer
  49512. * @returns true if the loader can load the specified file
  49513. */
  49514. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49515. /**
  49516. * Transform the url before loading if required.
  49517. * @param rootUrl the url of the texture
  49518. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49519. * @returns the transformed texture
  49520. */
  49521. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49522. /**
  49523. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49524. * @param rootUrl the url of the texture
  49525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49526. * @returns the fallback texture
  49527. */
  49528. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49529. /**
  49530. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49531. * @param data contains the texture data
  49532. * @param texture defines the BabylonJS internal texture
  49533. * @param createPolynomials will be true if polynomials have been requested
  49534. * @param onLoad defines the callback to trigger once the texture is ready
  49535. * @param onError defines the callback to trigger in case of error
  49536. */
  49537. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49538. /**
  49539. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49540. * @param data contains the texture data
  49541. * @param texture defines the BabylonJS internal texture
  49542. * @param callback defines the method to call once ready to upload
  49543. */
  49544. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49545. }
  49546. }
  49547. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49548. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49549. /** @hidden */
  49550. export var rgbdEncodePixelShader: {
  49551. name: string;
  49552. shader: string;
  49553. };
  49554. }
  49555. declare module "babylonjs/Misc/environmentTextureTools" {
  49556. import { Nullable } from "babylonjs/types";
  49557. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49559. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49560. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49561. import "babylonjs/Shaders/rgbdEncode.fragment";
  49562. import "babylonjs/Shaders/rgbdDecode.fragment";
  49563. /**
  49564. * Raw texture data and descriptor sufficient for WebGL texture upload
  49565. */
  49566. export interface EnvironmentTextureInfo {
  49567. /**
  49568. * Version of the environment map
  49569. */
  49570. version: number;
  49571. /**
  49572. * Width of image
  49573. */
  49574. width: number;
  49575. /**
  49576. * Irradiance information stored in the file.
  49577. */
  49578. irradiance: any;
  49579. /**
  49580. * Specular information stored in the file.
  49581. */
  49582. specular: any;
  49583. }
  49584. /**
  49585. * Sets of helpers addressing the serialization and deserialization of environment texture
  49586. * stored in a BabylonJS env file.
  49587. * Those files are usually stored as .env files.
  49588. */
  49589. export class EnvironmentTextureTools {
  49590. /**
  49591. * Magic number identifying the env file.
  49592. */
  49593. private static _MagicBytes;
  49594. /**
  49595. * Gets the environment info from an env file.
  49596. * @param data The array buffer containing the .env bytes.
  49597. * @returns the environment file info (the json header) if successfully parsed.
  49598. */
  49599. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49600. /**
  49601. * Creates an environment texture from a loaded cube texture.
  49602. * @param texture defines the cube texture to convert in env file
  49603. * @return a promise containing the environment data if succesfull.
  49604. */
  49605. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49606. /**
  49607. * Creates a JSON representation of the spherical data.
  49608. * @param texture defines the texture containing the polynomials
  49609. * @return the JSON representation of the spherical info
  49610. */
  49611. private static _CreateEnvTextureIrradiance;
  49612. /**
  49613. * Uploads the texture info contained in the env file to the GPU.
  49614. * @param texture defines the internal texture to upload to
  49615. * @param arrayBuffer defines the buffer cotaining the data to load
  49616. * @param info defines the texture info retrieved through the GetEnvInfo method
  49617. * @returns a promise
  49618. */
  49619. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49620. /**
  49621. * Uploads the levels of image data to the GPU.
  49622. * @param texture defines the internal texture to upload to
  49623. * @param imageData defines the array buffer views of image data [mipmap][face]
  49624. * @returns a promise
  49625. */
  49626. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49627. /**
  49628. * Uploads spherical polynomials information to the texture.
  49629. * @param texture defines the texture we are trying to upload the information to
  49630. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49631. */
  49632. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49633. /** @hidden */
  49634. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49635. }
  49636. }
  49637. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49638. import { Nullable } from "babylonjs/types";
  49639. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49640. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49641. /**
  49642. * Implementation of the ENV Texture Loader.
  49643. * @hidden
  49644. */
  49645. export class _ENVTextureLoader implements IInternalTextureLoader {
  49646. /**
  49647. * Defines wether the loader supports cascade loading the different faces.
  49648. */
  49649. readonly supportCascades: boolean;
  49650. /**
  49651. * This returns if the loader support the current file information.
  49652. * @param extension defines the file extension of the file being loaded
  49653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49654. * @param fallback defines the fallback internal texture if any
  49655. * @param isBase64 defines whether the texture is encoded as a base64
  49656. * @param isBuffer defines whether the texture data are stored as a buffer
  49657. * @returns true if the loader can load the specified file
  49658. */
  49659. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49660. /**
  49661. * Transform the url before loading if required.
  49662. * @param rootUrl the url of the texture
  49663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49664. * @returns the transformed texture
  49665. */
  49666. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49667. /**
  49668. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49669. * @param rootUrl the url of the texture
  49670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49671. * @returns the fallback texture
  49672. */
  49673. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49674. /**
  49675. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49676. * @param data contains the texture data
  49677. * @param texture defines the BabylonJS internal texture
  49678. * @param createPolynomials will be true if polynomials have been requested
  49679. * @param onLoad defines the callback to trigger once the texture is ready
  49680. * @param onError defines the callback to trigger in case of error
  49681. */
  49682. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49683. /**
  49684. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49685. * @param data contains the texture data
  49686. * @param texture defines the BabylonJS internal texture
  49687. * @param callback defines the method to call once ready to upload
  49688. */
  49689. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49690. }
  49691. }
  49692. declare module "babylonjs/Misc/khronosTextureContainer" {
  49693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49694. /**
  49695. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49696. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49697. */
  49698. export class KhronosTextureContainer {
  49699. /** contents of the KTX container file */
  49700. arrayBuffer: any;
  49701. private static HEADER_LEN;
  49702. private static COMPRESSED_2D;
  49703. private static COMPRESSED_3D;
  49704. private static TEX_2D;
  49705. private static TEX_3D;
  49706. /**
  49707. * Gets the openGL type
  49708. */
  49709. glType: number;
  49710. /**
  49711. * Gets the openGL type size
  49712. */
  49713. glTypeSize: number;
  49714. /**
  49715. * Gets the openGL format
  49716. */
  49717. glFormat: number;
  49718. /**
  49719. * Gets the openGL internal format
  49720. */
  49721. glInternalFormat: number;
  49722. /**
  49723. * Gets the base internal format
  49724. */
  49725. glBaseInternalFormat: number;
  49726. /**
  49727. * Gets image width in pixel
  49728. */
  49729. pixelWidth: number;
  49730. /**
  49731. * Gets image height in pixel
  49732. */
  49733. pixelHeight: number;
  49734. /**
  49735. * Gets image depth in pixels
  49736. */
  49737. pixelDepth: number;
  49738. /**
  49739. * Gets the number of array elements
  49740. */
  49741. numberOfArrayElements: number;
  49742. /**
  49743. * Gets the number of faces
  49744. */
  49745. numberOfFaces: number;
  49746. /**
  49747. * Gets the number of mipmap levels
  49748. */
  49749. numberOfMipmapLevels: number;
  49750. /**
  49751. * Gets the bytes of key value data
  49752. */
  49753. bytesOfKeyValueData: number;
  49754. /**
  49755. * Gets the load type
  49756. */
  49757. loadType: number;
  49758. /**
  49759. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49760. */
  49761. isInvalid: boolean;
  49762. /**
  49763. * Creates a new KhronosTextureContainer
  49764. * @param arrayBuffer contents of the KTX container file
  49765. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49766. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49767. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49768. */
  49769. constructor(
  49770. /** contents of the KTX container file */
  49771. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49772. /**
  49773. * Uploads KTX content to a Babylon Texture.
  49774. * It is assumed that the texture has already been created & is currently bound
  49775. * @hidden
  49776. */
  49777. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49778. private _upload2DCompressedLevels;
  49779. }
  49780. }
  49781. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49782. import { Nullable } from "babylonjs/types";
  49783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49784. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49785. /**
  49786. * Implementation of the KTX Texture Loader.
  49787. * @hidden
  49788. */
  49789. export class _KTXTextureLoader implements IInternalTextureLoader {
  49790. /**
  49791. * Defines wether the loader supports cascade loading the different faces.
  49792. */
  49793. readonly supportCascades: boolean;
  49794. /**
  49795. * This returns if the loader support the current file information.
  49796. * @param extension defines the file extension of the file being loaded
  49797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49798. * @param fallback defines the fallback internal texture if any
  49799. * @param isBase64 defines whether the texture is encoded as a base64
  49800. * @param isBuffer defines whether the texture data are stored as a buffer
  49801. * @returns true if the loader can load the specified file
  49802. */
  49803. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49804. /**
  49805. * Transform the url before loading if required.
  49806. * @param rootUrl the url of the texture
  49807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49808. * @returns the transformed texture
  49809. */
  49810. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49811. /**
  49812. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49813. * @param rootUrl the url of the texture
  49814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49815. * @returns the fallback texture
  49816. */
  49817. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49818. /**
  49819. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49820. * @param data contains the texture data
  49821. * @param texture defines the BabylonJS internal texture
  49822. * @param createPolynomials will be true if polynomials have been requested
  49823. * @param onLoad defines the callback to trigger once the texture is ready
  49824. * @param onError defines the callback to trigger in case of error
  49825. */
  49826. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49827. /**
  49828. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49829. * @param data contains the texture data
  49830. * @param texture defines the BabylonJS internal texture
  49831. * @param callback defines the method to call once ready to upload
  49832. */
  49833. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49834. }
  49835. }
  49836. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49837. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49838. import { Scene } from "babylonjs/scene";
  49839. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49840. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49841. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49842. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49843. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49844. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49846. /**
  49847. * Options for the default xr helper
  49848. */
  49849. export class WebXRDefaultExperienceOptions {
  49850. /**
  49851. * Floor meshes that should be used for teleporting
  49852. */
  49853. floorMeshes: Array<AbstractMesh>;
  49854. }
  49855. /**
  49856. * Default experience which provides a similar setup to the previous webVRExperience
  49857. */
  49858. export class WebXRDefaultExperience {
  49859. /**
  49860. * Base experience
  49861. */
  49862. baseExperience: WebXRExperienceHelper;
  49863. /**
  49864. * Input experience extension
  49865. */
  49866. input: WebXRInput;
  49867. /**
  49868. * Loads the controller models
  49869. */
  49870. controllerModelLoader: WebXRControllerModelLoader;
  49871. /**
  49872. * Enables laser pointer and selection
  49873. */
  49874. pointerSelection: WebXRControllerPointerSelection;
  49875. /**
  49876. * Enables teleportation
  49877. */
  49878. teleportation: WebXRControllerTeleportation;
  49879. /**
  49880. * Enables ui for enetering/exiting xr
  49881. */
  49882. enterExitUI: WebXREnterExitUI;
  49883. /**
  49884. * Default output canvas xr should render to
  49885. */
  49886. outputCanvas: WebXRManagedOutputCanvas;
  49887. /**
  49888. * Creates the default xr experience
  49889. * @param scene scene
  49890. * @param options options for basic configuration
  49891. * @returns resulting WebXRDefaultExperience
  49892. */
  49893. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49894. private constructor();
  49895. /**
  49896. * DIsposes of the experience helper
  49897. */
  49898. dispose(): void;
  49899. }
  49900. }
  49901. declare module "babylonjs/Helpers/sceneHelpers" {
  49902. import { Nullable } from "babylonjs/types";
  49903. import { Mesh } from "babylonjs/Meshes/mesh";
  49904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49905. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49906. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49907. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49908. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49909. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49910. import "babylonjs/Meshes/Builders/boxBuilder";
  49911. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49912. /** @hidden */
  49913. export var _forceSceneHelpersToBundle: boolean;
  49914. module "babylonjs/scene" {
  49915. interface Scene {
  49916. /**
  49917. * Creates a default light for the scene.
  49918. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49919. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49920. */
  49921. createDefaultLight(replace?: boolean): void;
  49922. /**
  49923. * Creates a default camera for the scene.
  49924. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49925. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49926. * @param replace has default false, when true replaces the active camera in the scene
  49927. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49928. */
  49929. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49930. /**
  49931. * Creates a default camera and a default light.
  49932. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49933. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49934. * @param replace has the default false, when true replaces the active camera/light in the scene
  49935. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49936. */
  49937. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49938. /**
  49939. * Creates a new sky box
  49940. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49941. * @param environmentTexture defines the texture to use as environment texture
  49942. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49943. * @param scale defines the overall scale of the skybox
  49944. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49945. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49946. * @returns a new mesh holding the sky box
  49947. */
  49948. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49949. /**
  49950. * Creates a new environment
  49951. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49952. * @param options defines the options you can use to configure the environment
  49953. * @returns the new EnvironmentHelper
  49954. */
  49955. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49956. /**
  49957. * Creates a new VREXperienceHelper
  49958. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49959. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49960. * @returns a new VREXperienceHelper
  49961. */
  49962. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49963. /**
  49964. * Creates a new WebXRDefaultExperience
  49965. * @see http://doc.babylonjs.com/how_to/webxr
  49966. * @param options experience options
  49967. * @returns a promise for a new WebXRDefaultExperience
  49968. */
  49969. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49970. }
  49971. }
  49972. }
  49973. declare module "babylonjs/Maths/math.vertexFormat" {
  49974. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49975. /**
  49976. * Contains position and normal vectors for a vertex
  49977. */
  49978. export class PositionNormalVertex {
  49979. /** the position of the vertex (defaut: 0,0,0) */
  49980. position: Vector3;
  49981. /** the normal of the vertex (defaut: 0,1,0) */
  49982. normal: Vector3;
  49983. /**
  49984. * Creates a PositionNormalVertex
  49985. * @param position the position of the vertex (defaut: 0,0,0)
  49986. * @param normal the normal of the vertex (defaut: 0,1,0)
  49987. */
  49988. constructor(
  49989. /** the position of the vertex (defaut: 0,0,0) */
  49990. position?: Vector3,
  49991. /** the normal of the vertex (defaut: 0,1,0) */
  49992. normal?: Vector3);
  49993. /**
  49994. * Clones the PositionNormalVertex
  49995. * @returns the cloned PositionNormalVertex
  49996. */
  49997. clone(): PositionNormalVertex;
  49998. }
  49999. /**
  50000. * Contains position, normal and uv vectors for a vertex
  50001. */
  50002. export class PositionNormalTextureVertex {
  50003. /** the position of the vertex (defaut: 0,0,0) */
  50004. position: Vector3;
  50005. /** the normal of the vertex (defaut: 0,1,0) */
  50006. normal: Vector3;
  50007. /** the uv of the vertex (default: 0,0) */
  50008. uv: Vector2;
  50009. /**
  50010. * Creates a PositionNormalTextureVertex
  50011. * @param position the position of the vertex (defaut: 0,0,0)
  50012. * @param normal the normal of the vertex (defaut: 0,1,0)
  50013. * @param uv the uv of the vertex (default: 0,0)
  50014. */
  50015. constructor(
  50016. /** the position of the vertex (defaut: 0,0,0) */
  50017. position?: Vector3,
  50018. /** the normal of the vertex (defaut: 0,1,0) */
  50019. normal?: Vector3,
  50020. /** the uv of the vertex (default: 0,0) */
  50021. uv?: Vector2);
  50022. /**
  50023. * Clones the PositionNormalTextureVertex
  50024. * @returns the cloned PositionNormalTextureVertex
  50025. */
  50026. clone(): PositionNormalTextureVertex;
  50027. }
  50028. }
  50029. declare module "babylonjs/Maths/math" {
  50030. export * from "babylonjs/Maths/math.axis";
  50031. export * from "babylonjs/Maths/math.color";
  50032. export * from "babylonjs/Maths/math.constants";
  50033. export * from "babylonjs/Maths/math.frustum";
  50034. export * from "babylonjs/Maths/math.path";
  50035. export * from "babylonjs/Maths/math.plane";
  50036. export * from "babylonjs/Maths/math.size";
  50037. export * from "babylonjs/Maths/math.vector";
  50038. export * from "babylonjs/Maths/math.vertexFormat";
  50039. export * from "babylonjs/Maths/math.viewport";
  50040. }
  50041. declare module "babylonjs/Helpers/videoDome" {
  50042. import { Scene } from "babylonjs/scene";
  50043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50044. import { Mesh } from "babylonjs/Meshes/mesh";
  50045. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50046. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50047. import "babylonjs/Meshes/Builders/sphereBuilder";
  50048. /**
  50049. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50050. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50051. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50052. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50053. */
  50054. export class VideoDome extends TransformNode {
  50055. /**
  50056. * Define the video source as a Monoscopic panoramic 360 video.
  50057. */
  50058. static readonly MODE_MONOSCOPIC: number;
  50059. /**
  50060. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50061. */
  50062. static readonly MODE_TOPBOTTOM: number;
  50063. /**
  50064. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50065. */
  50066. static readonly MODE_SIDEBYSIDE: number;
  50067. private _halfDome;
  50068. private _useDirectMapping;
  50069. /**
  50070. * The video texture being displayed on the sphere
  50071. */
  50072. protected _videoTexture: VideoTexture;
  50073. /**
  50074. * Gets the video texture being displayed on the sphere
  50075. */
  50076. readonly videoTexture: VideoTexture;
  50077. /**
  50078. * The skybox material
  50079. */
  50080. protected _material: BackgroundMaterial;
  50081. /**
  50082. * The surface used for the skybox
  50083. */
  50084. protected _mesh: Mesh;
  50085. /**
  50086. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50087. */
  50088. private _halfDomeMask;
  50089. /**
  50090. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50091. * Also see the options.resolution property.
  50092. */
  50093. fovMultiplier: number;
  50094. private _videoMode;
  50095. /**
  50096. * Gets or set the current video mode for the video. It can be:
  50097. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50098. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50099. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50100. */
  50101. videoMode: number;
  50102. /**
  50103. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50104. *
  50105. */
  50106. /**
  50107. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50108. */
  50109. halfDome: boolean;
  50110. /**
  50111. * Oberserver used in Stereoscopic VR Mode.
  50112. */
  50113. private _onBeforeCameraRenderObserver;
  50114. /**
  50115. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50116. * @param name Element's name, child elements will append suffixes for their own names.
  50117. * @param urlsOrVideo defines the url(s) or the video element to use
  50118. * @param options An object containing optional or exposed sub element properties
  50119. */
  50120. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50121. resolution?: number;
  50122. clickToPlay?: boolean;
  50123. autoPlay?: boolean;
  50124. loop?: boolean;
  50125. size?: number;
  50126. poster?: string;
  50127. faceForward?: boolean;
  50128. useDirectMapping?: boolean;
  50129. halfDomeMode?: boolean;
  50130. }, scene: Scene);
  50131. private _changeVideoMode;
  50132. /**
  50133. * Releases resources associated with this node.
  50134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50136. */
  50137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50138. }
  50139. }
  50140. declare module "babylonjs/Helpers/index" {
  50141. export * from "babylonjs/Helpers/environmentHelper";
  50142. export * from "babylonjs/Helpers/photoDome";
  50143. export * from "babylonjs/Helpers/sceneHelpers";
  50144. export * from "babylonjs/Helpers/videoDome";
  50145. }
  50146. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50147. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50148. import { IDisposable } from "babylonjs/scene";
  50149. import { Engine } from "babylonjs/Engines/engine";
  50150. /**
  50151. * This class can be used to get instrumentation data from a Babylon engine
  50152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50153. */
  50154. export class EngineInstrumentation implements IDisposable {
  50155. /**
  50156. * Define the instrumented engine.
  50157. */
  50158. engine: Engine;
  50159. private _captureGPUFrameTime;
  50160. private _gpuFrameTimeToken;
  50161. private _gpuFrameTime;
  50162. private _captureShaderCompilationTime;
  50163. private _shaderCompilationTime;
  50164. private _onBeginFrameObserver;
  50165. private _onEndFrameObserver;
  50166. private _onBeforeShaderCompilationObserver;
  50167. private _onAfterShaderCompilationObserver;
  50168. /**
  50169. * Gets the perf counter used for GPU frame time
  50170. */
  50171. readonly gpuFrameTimeCounter: PerfCounter;
  50172. /**
  50173. * Gets the GPU frame time capture status
  50174. */
  50175. /**
  50176. * Enable or disable the GPU frame time capture
  50177. */
  50178. captureGPUFrameTime: boolean;
  50179. /**
  50180. * Gets the perf counter used for shader compilation time
  50181. */
  50182. readonly shaderCompilationTimeCounter: PerfCounter;
  50183. /**
  50184. * Gets the shader compilation time capture status
  50185. */
  50186. /**
  50187. * Enable or disable the shader compilation time capture
  50188. */
  50189. captureShaderCompilationTime: boolean;
  50190. /**
  50191. * Instantiates a new engine instrumentation.
  50192. * This class can be used to get instrumentation data from a Babylon engine
  50193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50194. * @param engine Defines the engine to instrument
  50195. */
  50196. constructor(
  50197. /**
  50198. * Define the instrumented engine.
  50199. */
  50200. engine: Engine);
  50201. /**
  50202. * Dispose and release associated resources.
  50203. */
  50204. dispose(): void;
  50205. }
  50206. }
  50207. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50208. import { Scene, IDisposable } from "babylonjs/scene";
  50209. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50210. /**
  50211. * This class can be used to get instrumentation data from a Babylon engine
  50212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50213. */
  50214. export class SceneInstrumentation implements IDisposable {
  50215. /**
  50216. * Defines the scene to instrument
  50217. */
  50218. scene: Scene;
  50219. private _captureActiveMeshesEvaluationTime;
  50220. private _activeMeshesEvaluationTime;
  50221. private _captureRenderTargetsRenderTime;
  50222. private _renderTargetsRenderTime;
  50223. private _captureFrameTime;
  50224. private _frameTime;
  50225. private _captureRenderTime;
  50226. private _renderTime;
  50227. private _captureInterFrameTime;
  50228. private _interFrameTime;
  50229. private _captureParticlesRenderTime;
  50230. private _particlesRenderTime;
  50231. private _captureSpritesRenderTime;
  50232. private _spritesRenderTime;
  50233. private _capturePhysicsTime;
  50234. private _physicsTime;
  50235. private _captureAnimationsTime;
  50236. private _animationsTime;
  50237. private _captureCameraRenderTime;
  50238. private _cameraRenderTime;
  50239. private _onBeforeActiveMeshesEvaluationObserver;
  50240. private _onAfterActiveMeshesEvaluationObserver;
  50241. private _onBeforeRenderTargetsRenderObserver;
  50242. private _onAfterRenderTargetsRenderObserver;
  50243. private _onAfterRenderObserver;
  50244. private _onBeforeDrawPhaseObserver;
  50245. private _onAfterDrawPhaseObserver;
  50246. private _onBeforeAnimationsObserver;
  50247. private _onBeforeParticlesRenderingObserver;
  50248. private _onAfterParticlesRenderingObserver;
  50249. private _onBeforeSpritesRenderingObserver;
  50250. private _onAfterSpritesRenderingObserver;
  50251. private _onBeforePhysicsObserver;
  50252. private _onAfterPhysicsObserver;
  50253. private _onAfterAnimationsObserver;
  50254. private _onBeforeCameraRenderObserver;
  50255. private _onAfterCameraRenderObserver;
  50256. /**
  50257. * Gets the perf counter used for active meshes evaluation time
  50258. */
  50259. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50260. /**
  50261. * Gets the active meshes evaluation time capture status
  50262. */
  50263. /**
  50264. * Enable or disable the active meshes evaluation time capture
  50265. */
  50266. captureActiveMeshesEvaluationTime: boolean;
  50267. /**
  50268. * Gets the perf counter used for render targets render time
  50269. */
  50270. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50271. /**
  50272. * Gets the render targets render time capture status
  50273. */
  50274. /**
  50275. * Enable or disable the render targets render time capture
  50276. */
  50277. captureRenderTargetsRenderTime: boolean;
  50278. /**
  50279. * Gets the perf counter used for particles render time
  50280. */
  50281. readonly particlesRenderTimeCounter: PerfCounter;
  50282. /**
  50283. * Gets the particles render time capture status
  50284. */
  50285. /**
  50286. * Enable or disable the particles render time capture
  50287. */
  50288. captureParticlesRenderTime: boolean;
  50289. /**
  50290. * Gets the perf counter used for sprites render time
  50291. */
  50292. readonly spritesRenderTimeCounter: PerfCounter;
  50293. /**
  50294. * Gets the sprites render time capture status
  50295. */
  50296. /**
  50297. * Enable or disable the sprites render time capture
  50298. */
  50299. captureSpritesRenderTime: boolean;
  50300. /**
  50301. * Gets the perf counter used for physics time
  50302. */
  50303. readonly physicsTimeCounter: PerfCounter;
  50304. /**
  50305. * Gets the physics time capture status
  50306. */
  50307. /**
  50308. * Enable or disable the physics time capture
  50309. */
  50310. capturePhysicsTime: boolean;
  50311. /**
  50312. * Gets the perf counter used for animations time
  50313. */
  50314. readonly animationsTimeCounter: PerfCounter;
  50315. /**
  50316. * Gets the animations time capture status
  50317. */
  50318. /**
  50319. * Enable or disable the animations time capture
  50320. */
  50321. captureAnimationsTime: boolean;
  50322. /**
  50323. * Gets the perf counter used for frame time capture
  50324. */
  50325. readonly frameTimeCounter: PerfCounter;
  50326. /**
  50327. * Gets the frame time capture status
  50328. */
  50329. /**
  50330. * Enable or disable the frame time capture
  50331. */
  50332. captureFrameTime: boolean;
  50333. /**
  50334. * Gets the perf counter used for inter-frames time capture
  50335. */
  50336. readonly interFrameTimeCounter: PerfCounter;
  50337. /**
  50338. * Gets the inter-frames time capture status
  50339. */
  50340. /**
  50341. * Enable or disable the inter-frames time capture
  50342. */
  50343. captureInterFrameTime: boolean;
  50344. /**
  50345. * Gets the perf counter used for render time capture
  50346. */
  50347. readonly renderTimeCounter: PerfCounter;
  50348. /**
  50349. * Gets the render time capture status
  50350. */
  50351. /**
  50352. * Enable or disable the render time capture
  50353. */
  50354. captureRenderTime: boolean;
  50355. /**
  50356. * Gets the perf counter used for camera render time capture
  50357. */
  50358. readonly cameraRenderTimeCounter: PerfCounter;
  50359. /**
  50360. * Gets the camera render time capture status
  50361. */
  50362. /**
  50363. * Enable or disable the camera render time capture
  50364. */
  50365. captureCameraRenderTime: boolean;
  50366. /**
  50367. * Gets the perf counter used for draw calls
  50368. */
  50369. readonly drawCallsCounter: PerfCounter;
  50370. /**
  50371. * Instantiates a new scene instrumentation.
  50372. * This class can be used to get instrumentation data from a Babylon engine
  50373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50374. * @param scene Defines the scene to instrument
  50375. */
  50376. constructor(
  50377. /**
  50378. * Defines the scene to instrument
  50379. */
  50380. scene: Scene);
  50381. /**
  50382. * Dispose and release associated resources.
  50383. */
  50384. dispose(): void;
  50385. }
  50386. }
  50387. declare module "babylonjs/Instrumentation/index" {
  50388. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50389. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50390. export * from "babylonjs/Instrumentation/timeToken";
  50391. }
  50392. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50393. /** @hidden */
  50394. export var glowMapGenerationPixelShader: {
  50395. name: string;
  50396. shader: string;
  50397. };
  50398. }
  50399. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50400. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50407. /** @hidden */
  50408. export var glowMapGenerationVertexShader: {
  50409. name: string;
  50410. shader: string;
  50411. };
  50412. }
  50413. declare module "babylonjs/Layers/effectLayer" {
  50414. import { Observable } from "babylonjs/Misc/observable";
  50415. import { Nullable } from "babylonjs/types";
  50416. import { Camera } from "babylonjs/Cameras/camera";
  50417. import { Scene } from "babylonjs/scene";
  50418. import { ISize } from "babylonjs/Maths/math.size";
  50419. import { Color4 } from "babylonjs/Maths/math.color";
  50420. import { Engine } from "babylonjs/Engines/engine";
  50421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50423. import { Mesh } from "babylonjs/Meshes/mesh";
  50424. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50427. import { Effect } from "babylonjs/Materials/effect";
  50428. import { Material } from "babylonjs/Materials/material";
  50429. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50430. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50431. /**
  50432. * Effect layer options. This helps customizing the behaviour
  50433. * of the effect layer.
  50434. */
  50435. export interface IEffectLayerOptions {
  50436. /**
  50437. * Multiplication factor apply to the canvas size to compute the render target size
  50438. * used to generated the objects (the smaller the faster).
  50439. */
  50440. mainTextureRatio: number;
  50441. /**
  50442. * Enforces a fixed size texture to ensure effect stability across devices.
  50443. */
  50444. mainTextureFixedSize?: number;
  50445. /**
  50446. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50447. */
  50448. alphaBlendingMode: number;
  50449. /**
  50450. * The camera attached to the layer.
  50451. */
  50452. camera: Nullable<Camera>;
  50453. /**
  50454. * The rendering group to draw the layer in.
  50455. */
  50456. renderingGroupId: number;
  50457. }
  50458. /**
  50459. * The effect layer Helps adding post process effect blended with the main pass.
  50460. *
  50461. * This can be for instance use to generate glow or higlight effects on the scene.
  50462. *
  50463. * The effect layer class can not be used directly and is intented to inherited from to be
  50464. * customized per effects.
  50465. */
  50466. export abstract class EffectLayer {
  50467. private _vertexBuffers;
  50468. private _indexBuffer;
  50469. private _cachedDefines;
  50470. private _effectLayerMapGenerationEffect;
  50471. private _effectLayerOptions;
  50472. private _mergeEffect;
  50473. protected _scene: Scene;
  50474. protected _engine: Engine;
  50475. protected _maxSize: number;
  50476. protected _mainTextureDesiredSize: ISize;
  50477. protected _mainTexture: RenderTargetTexture;
  50478. protected _shouldRender: boolean;
  50479. protected _postProcesses: PostProcess[];
  50480. protected _textures: BaseTexture[];
  50481. protected _emissiveTextureAndColor: {
  50482. texture: Nullable<BaseTexture>;
  50483. color: Color4;
  50484. };
  50485. /**
  50486. * The name of the layer
  50487. */
  50488. name: string;
  50489. /**
  50490. * The clear color of the texture used to generate the glow map.
  50491. */
  50492. neutralColor: Color4;
  50493. /**
  50494. * Specifies wether the highlight layer is enabled or not.
  50495. */
  50496. isEnabled: boolean;
  50497. /**
  50498. * Gets the camera attached to the layer.
  50499. */
  50500. readonly camera: Nullable<Camera>;
  50501. /**
  50502. * Gets the rendering group id the layer should render in.
  50503. */
  50504. renderingGroupId: number;
  50505. /**
  50506. * An event triggered when the effect layer has been disposed.
  50507. */
  50508. onDisposeObservable: Observable<EffectLayer>;
  50509. /**
  50510. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50511. */
  50512. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50513. /**
  50514. * An event triggered when the generated texture is being merged in the scene.
  50515. */
  50516. onBeforeComposeObservable: Observable<EffectLayer>;
  50517. /**
  50518. * An event triggered when the generated texture has been merged in the scene.
  50519. */
  50520. onAfterComposeObservable: Observable<EffectLayer>;
  50521. /**
  50522. * An event triggered when the efffect layer changes its size.
  50523. */
  50524. onSizeChangedObservable: Observable<EffectLayer>;
  50525. /** @hidden */
  50526. static _SceneComponentInitialization: (scene: Scene) => void;
  50527. /**
  50528. * Instantiates a new effect Layer and references it in the scene.
  50529. * @param name The name of the layer
  50530. * @param scene The scene to use the layer in
  50531. */
  50532. constructor(
  50533. /** The Friendly of the effect in the scene */
  50534. name: string, scene: Scene);
  50535. /**
  50536. * Get the effect name of the layer.
  50537. * @return The effect name
  50538. */
  50539. abstract getEffectName(): string;
  50540. /**
  50541. * Checks for the readiness of the element composing the layer.
  50542. * @param subMesh the mesh to check for
  50543. * @param useInstances specify wether or not to use instances to render the mesh
  50544. * @return true if ready otherwise, false
  50545. */
  50546. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50547. /**
  50548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50549. * @returns true if the effect requires stencil during the main canvas render pass.
  50550. */
  50551. abstract needStencil(): boolean;
  50552. /**
  50553. * Create the merge effect. This is the shader use to blit the information back
  50554. * to the main canvas at the end of the scene rendering.
  50555. * @returns The effect containing the shader used to merge the effect on the main canvas
  50556. */
  50557. protected abstract _createMergeEffect(): Effect;
  50558. /**
  50559. * Creates the render target textures and post processes used in the effect layer.
  50560. */
  50561. protected abstract _createTextureAndPostProcesses(): void;
  50562. /**
  50563. * Implementation specific of rendering the generating effect on the main canvas.
  50564. * @param effect The effect used to render through
  50565. */
  50566. protected abstract _internalRender(effect: Effect): void;
  50567. /**
  50568. * Sets the required values for both the emissive texture and and the main color.
  50569. */
  50570. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50571. /**
  50572. * Free any resources and references associated to a mesh.
  50573. * Internal use
  50574. * @param mesh The mesh to free.
  50575. */
  50576. abstract _disposeMesh(mesh: Mesh): void;
  50577. /**
  50578. * Serializes this layer (Glow or Highlight for example)
  50579. * @returns a serialized layer object
  50580. */
  50581. abstract serialize?(): any;
  50582. /**
  50583. * Initializes the effect layer with the required options.
  50584. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50585. */
  50586. protected _init(options: Partial<IEffectLayerOptions>): void;
  50587. /**
  50588. * Generates the index buffer of the full screen quad blending to the main canvas.
  50589. */
  50590. private _generateIndexBuffer;
  50591. /**
  50592. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50593. */
  50594. private _generateVertexBuffer;
  50595. /**
  50596. * Sets the main texture desired size which is the closest power of two
  50597. * of the engine canvas size.
  50598. */
  50599. private _setMainTextureSize;
  50600. /**
  50601. * Creates the main texture for the effect layer.
  50602. */
  50603. protected _createMainTexture(): void;
  50604. /**
  50605. * Adds specific effects defines.
  50606. * @param defines The defines to add specifics to.
  50607. */
  50608. protected _addCustomEffectDefines(defines: string[]): void;
  50609. /**
  50610. * Checks for the readiness of the element composing the layer.
  50611. * @param subMesh the mesh to check for
  50612. * @param useInstances specify wether or not to use instances to render the mesh
  50613. * @param emissiveTexture the associated emissive texture used to generate the glow
  50614. * @return true if ready otherwise, false
  50615. */
  50616. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50617. /**
  50618. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50619. */
  50620. render(): void;
  50621. /**
  50622. * Determine if a given mesh will be used in the current effect.
  50623. * @param mesh mesh to test
  50624. * @returns true if the mesh will be used
  50625. */
  50626. hasMesh(mesh: AbstractMesh): boolean;
  50627. /**
  50628. * Returns true if the layer contains information to display, otherwise false.
  50629. * @returns true if the glow layer should be rendered
  50630. */
  50631. shouldRender(): boolean;
  50632. /**
  50633. * Returns true if the mesh should render, otherwise false.
  50634. * @param mesh The mesh to render
  50635. * @returns true if it should render otherwise false
  50636. */
  50637. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50638. /**
  50639. * Returns true if the mesh can be rendered, otherwise false.
  50640. * @param mesh The mesh to render
  50641. * @param material The material used on the mesh
  50642. * @returns true if it can be rendered otherwise false
  50643. */
  50644. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50645. /**
  50646. * Returns true if the mesh should render, otherwise false.
  50647. * @param mesh The mesh to render
  50648. * @returns true if it should render otherwise false
  50649. */
  50650. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50651. /**
  50652. * Renders the submesh passed in parameter to the generation map.
  50653. */
  50654. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50655. /**
  50656. * Rebuild the required buffers.
  50657. * @hidden Internal use only.
  50658. */
  50659. _rebuild(): void;
  50660. /**
  50661. * Dispose only the render target textures and post process.
  50662. */
  50663. private _disposeTextureAndPostProcesses;
  50664. /**
  50665. * Dispose the highlight layer and free resources.
  50666. */
  50667. dispose(): void;
  50668. /**
  50669. * Gets the class name of the effect layer
  50670. * @returns the string with the class name of the effect layer
  50671. */
  50672. getClassName(): string;
  50673. /**
  50674. * Creates an effect layer from parsed effect layer data
  50675. * @param parsedEffectLayer defines effect layer data
  50676. * @param scene defines the current scene
  50677. * @param rootUrl defines the root URL containing the effect layer information
  50678. * @returns a parsed effect Layer
  50679. */
  50680. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50681. }
  50682. }
  50683. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50684. import { Scene } from "babylonjs/scene";
  50685. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50686. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50687. import { AbstractScene } from "babylonjs/abstractScene";
  50688. module "babylonjs/abstractScene" {
  50689. interface AbstractScene {
  50690. /**
  50691. * The list of effect layers (highlights/glow) added to the scene
  50692. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50693. * @see http://doc.babylonjs.com/how_to/glow_layer
  50694. */
  50695. effectLayers: Array<EffectLayer>;
  50696. /**
  50697. * Removes the given effect layer from this scene.
  50698. * @param toRemove defines the effect layer to remove
  50699. * @returns the index of the removed effect layer
  50700. */
  50701. removeEffectLayer(toRemove: EffectLayer): number;
  50702. /**
  50703. * Adds the given effect layer to this scene
  50704. * @param newEffectLayer defines the effect layer to add
  50705. */
  50706. addEffectLayer(newEffectLayer: EffectLayer): void;
  50707. }
  50708. }
  50709. /**
  50710. * Defines the layer scene component responsible to manage any effect layers
  50711. * in a given scene.
  50712. */
  50713. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50714. /**
  50715. * The component name helpfull to identify the component in the list of scene components.
  50716. */
  50717. readonly name: string;
  50718. /**
  50719. * The scene the component belongs to.
  50720. */
  50721. scene: Scene;
  50722. private _engine;
  50723. private _renderEffects;
  50724. private _needStencil;
  50725. private _previousStencilState;
  50726. /**
  50727. * Creates a new instance of the component for the given scene
  50728. * @param scene Defines the scene to register the component in
  50729. */
  50730. constructor(scene: Scene);
  50731. /**
  50732. * Registers the component in a given scene
  50733. */
  50734. register(): void;
  50735. /**
  50736. * Rebuilds the elements related to this component in case of
  50737. * context lost for instance.
  50738. */
  50739. rebuild(): void;
  50740. /**
  50741. * Serializes the component data to the specified json object
  50742. * @param serializationObject The object to serialize to
  50743. */
  50744. serialize(serializationObject: any): void;
  50745. /**
  50746. * Adds all the elements from the container to the scene
  50747. * @param container the container holding the elements
  50748. */
  50749. addFromContainer(container: AbstractScene): void;
  50750. /**
  50751. * Removes all the elements in the container from the scene
  50752. * @param container contains the elements to remove
  50753. * @param dispose if the removed element should be disposed (default: false)
  50754. */
  50755. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50756. /**
  50757. * Disposes the component and the associated ressources.
  50758. */
  50759. dispose(): void;
  50760. private _isReadyForMesh;
  50761. private _renderMainTexture;
  50762. private _setStencil;
  50763. private _setStencilBack;
  50764. private _draw;
  50765. private _drawCamera;
  50766. private _drawRenderingGroup;
  50767. }
  50768. }
  50769. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50770. /** @hidden */
  50771. export var glowMapMergePixelShader: {
  50772. name: string;
  50773. shader: string;
  50774. };
  50775. }
  50776. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50777. /** @hidden */
  50778. export var glowMapMergeVertexShader: {
  50779. name: string;
  50780. shader: string;
  50781. };
  50782. }
  50783. declare module "babylonjs/Layers/glowLayer" {
  50784. import { Nullable } from "babylonjs/types";
  50785. import { Camera } from "babylonjs/Cameras/camera";
  50786. import { Scene } from "babylonjs/scene";
  50787. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50789. import { Mesh } from "babylonjs/Meshes/mesh";
  50790. import { Texture } from "babylonjs/Materials/Textures/texture";
  50791. import { Effect } from "babylonjs/Materials/effect";
  50792. import { Material } from "babylonjs/Materials/material";
  50793. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50794. import { Color4 } from "babylonjs/Maths/math.color";
  50795. import "babylonjs/Shaders/glowMapMerge.fragment";
  50796. import "babylonjs/Shaders/glowMapMerge.vertex";
  50797. import "babylonjs/Layers/effectLayerSceneComponent";
  50798. module "babylonjs/abstractScene" {
  50799. interface AbstractScene {
  50800. /**
  50801. * Return a the first highlight layer of the scene with a given name.
  50802. * @param name The name of the highlight layer to look for.
  50803. * @return The highlight layer if found otherwise null.
  50804. */
  50805. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50806. }
  50807. }
  50808. /**
  50809. * Glow layer options. This helps customizing the behaviour
  50810. * of the glow layer.
  50811. */
  50812. export interface IGlowLayerOptions {
  50813. /**
  50814. * Multiplication factor apply to the canvas size to compute the render target size
  50815. * used to generated the glowing objects (the smaller the faster).
  50816. */
  50817. mainTextureRatio: number;
  50818. /**
  50819. * Enforces a fixed size texture to ensure resize independant blur.
  50820. */
  50821. mainTextureFixedSize?: number;
  50822. /**
  50823. * How big is the kernel of the blur texture.
  50824. */
  50825. blurKernelSize: number;
  50826. /**
  50827. * The camera attached to the layer.
  50828. */
  50829. camera: Nullable<Camera>;
  50830. /**
  50831. * Enable MSAA by chosing the number of samples.
  50832. */
  50833. mainTextureSamples?: number;
  50834. /**
  50835. * The rendering group to draw the layer in.
  50836. */
  50837. renderingGroupId: number;
  50838. }
  50839. /**
  50840. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50841. *
  50842. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50843. * glowy meshes to your scene.
  50844. *
  50845. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50846. */
  50847. export class GlowLayer extends EffectLayer {
  50848. /**
  50849. * Effect Name of the layer.
  50850. */
  50851. static readonly EffectName: string;
  50852. /**
  50853. * The default blur kernel size used for the glow.
  50854. */
  50855. static DefaultBlurKernelSize: number;
  50856. /**
  50857. * The default texture size ratio used for the glow.
  50858. */
  50859. static DefaultTextureRatio: number;
  50860. /**
  50861. * Sets the kernel size of the blur.
  50862. */
  50863. /**
  50864. * Gets the kernel size of the blur.
  50865. */
  50866. blurKernelSize: number;
  50867. /**
  50868. * Sets the glow intensity.
  50869. */
  50870. /**
  50871. * Gets the glow intensity.
  50872. */
  50873. intensity: number;
  50874. private _options;
  50875. private _intensity;
  50876. private _horizontalBlurPostprocess1;
  50877. private _verticalBlurPostprocess1;
  50878. private _horizontalBlurPostprocess2;
  50879. private _verticalBlurPostprocess2;
  50880. private _blurTexture1;
  50881. private _blurTexture2;
  50882. private _postProcesses1;
  50883. private _postProcesses2;
  50884. private _includedOnlyMeshes;
  50885. private _excludedMeshes;
  50886. /**
  50887. * Callback used to let the user override the color selection on a per mesh basis
  50888. */
  50889. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50890. /**
  50891. * Callback used to let the user override the texture selection on a per mesh basis
  50892. */
  50893. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50894. /**
  50895. * Instantiates a new glow Layer and references it to the scene.
  50896. * @param name The name of the layer
  50897. * @param scene The scene to use the layer in
  50898. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50899. */
  50900. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50901. /**
  50902. * Get the effect name of the layer.
  50903. * @return The effect name
  50904. */
  50905. getEffectName(): string;
  50906. /**
  50907. * Create the merge effect. This is the shader use to blit the information back
  50908. * to the main canvas at the end of the scene rendering.
  50909. */
  50910. protected _createMergeEffect(): Effect;
  50911. /**
  50912. * Creates the render target textures and post processes used in the glow layer.
  50913. */
  50914. protected _createTextureAndPostProcesses(): void;
  50915. /**
  50916. * Checks for the readiness of the element composing the layer.
  50917. * @param subMesh the mesh to check for
  50918. * @param useInstances specify wether or not to use instances to render the mesh
  50919. * @param emissiveTexture the associated emissive texture used to generate the glow
  50920. * @return true if ready otherwise, false
  50921. */
  50922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50923. /**
  50924. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50925. */
  50926. needStencil(): boolean;
  50927. /**
  50928. * Returns true if the mesh can be rendered, otherwise false.
  50929. * @param mesh The mesh to render
  50930. * @param material The material used on the mesh
  50931. * @returns true if it can be rendered otherwise false
  50932. */
  50933. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50934. /**
  50935. * Implementation specific of rendering the generating effect on the main canvas.
  50936. * @param effect The effect used to render through
  50937. */
  50938. protected _internalRender(effect: Effect): void;
  50939. /**
  50940. * Sets the required values for both the emissive texture and and the main color.
  50941. */
  50942. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50943. /**
  50944. * Returns true if the mesh should render, otherwise false.
  50945. * @param mesh The mesh to render
  50946. * @returns true if it should render otherwise false
  50947. */
  50948. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50949. /**
  50950. * Adds specific effects defines.
  50951. * @param defines The defines to add specifics to.
  50952. */
  50953. protected _addCustomEffectDefines(defines: string[]): void;
  50954. /**
  50955. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50956. * @param mesh The mesh to exclude from the glow layer
  50957. */
  50958. addExcludedMesh(mesh: Mesh): void;
  50959. /**
  50960. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50961. * @param mesh The mesh to remove
  50962. */
  50963. removeExcludedMesh(mesh: Mesh): void;
  50964. /**
  50965. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50966. * @param mesh The mesh to include in the glow layer
  50967. */
  50968. addIncludedOnlyMesh(mesh: Mesh): void;
  50969. /**
  50970. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50971. * @param mesh The mesh to remove
  50972. */
  50973. removeIncludedOnlyMesh(mesh: Mesh): void;
  50974. /**
  50975. * Determine if a given mesh will be used in the glow layer
  50976. * @param mesh The mesh to test
  50977. * @returns true if the mesh will be highlighted by the current glow layer
  50978. */
  50979. hasMesh(mesh: AbstractMesh): boolean;
  50980. /**
  50981. * Free any resources and references associated to a mesh.
  50982. * Internal use
  50983. * @param mesh The mesh to free.
  50984. * @hidden
  50985. */
  50986. _disposeMesh(mesh: Mesh): void;
  50987. /**
  50988. * Gets the class name of the effect layer
  50989. * @returns the string with the class name of the effect layer
  50990. */
  50991. getClassName(): string;
  50992. /**
  50993. * Serializes this glow layer
  50994. * @returns a serialized glow layer object
  50995. */
  50996. serialize(): any;
  50997. /**
  50998. * Creates a Glow Layer from parsed glow layer data
  50999. * @param parsedGlowLayer defines glow layer data
  51000. * @param scene defines the current scene
  51001. * @param rootUrl defines the root URL containing the glow layer information
  51002. * @returns a parsed Glow Layer
  51003. */
  51004. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51005. }
  51006. }
  51007. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51008. /** @hidden */
  51009. export var glowBlurPostProcessPixelShader: {
  51010. name: string;
  51011. shader: string;
  51012. };
  51013. }
  51014. declare module "babylonjs/Layers/highlightLayer" {
  51015. import { Observable } from "babylonjs/Misc/observable";
  51016. import { Nullable } from "babylonjs/types";
  51017. import { Camera } from "babylonjs/Cameras/camera";
  51018. import { Scene } from "babylonjs/scene";
  51019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51021. import { Mesh } from "babylonjs/Meshes/mesh";
  51022. import { Effect } from "babylonjs/Materials/effect";
  51023. import { Material } from "babylonjs/Materials/material";
  51024. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51025. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51026. import "babylonjs/Shaders/glowMapMerge.fragment";
  51027. import "babylonjs/Shaders/glowMapMerge.vertex";
  51028. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51029. module "babylonjs/abstractScene" {
  51030. interface AbstractScene {
  51031. /**
  51032. * Return a the first highlight layer of the scene with a given name.
  51033. * @param name The name of the highlight layer to look for.
  51034. * @return The highlight layer if found otherwise null.
  51035. */
  51036. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51037. }
  51038. }
  51039. /**
  51040. * Highlight layer options. This helps customizing the behaviour
  51041. * of the highlight layer.
  51042. */
  51043. export interface IHighlightLayerOptions {
  51044. /**
  51045. * Multiplication factor apply to the canvas size to compute the render target size
  51046. * used to generated the glowing objects (the smaller the faster).
  51047. */
  51048. mainTextureRatio: number;
  51049. /**
  51050. * Enforces a fixed size texture to ensure resize independant blur.
  51051. */
  51052. mainTextureFixedSize?: number;
  51053. /**
  51054. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51055. * of the picture to blur (the smaller the faster).
  51056. */
  51057. blurTextureSizeRatio: number;
  51058. /**
  51059. * How big in texel of the blur texture is the vertical blur.
  51060. */
  51061. blurVerticalSize: number;
  51062. /**
  51063. * How big in texel of the blur texture is the horizontal blur.
  51064. */
  51065. blurHorizontalSize: number;
  51066. /**
  51067. * Alpha blending mode used to apply the blur. Default is combine.
  51068. */
  51069. alphaBlendingMode: number;
  51070. /**
  51071. * The camera attached to the layer.
  51072. */
  51073. camera: Nullable<Camera>;
  51074. /**
  51075. * Should we display highlight as a solid stroke?
  51076. */
  51077. isStroke?: boolean;
  51078. /**
  51079. * The rendering group to draw the layer in.
  51080. */
  51081. renderingGroupId: number;
  51082. }
  51083. /**
  51084. * The highlight layer Helps adding a glow effect around a mesh.
  51085. *
  51086. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51087. * glowy meshes to your scene.
  51088. *
  51089. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51090. */
  51091. export class HighlightLayer extends EffectLayer {
  51092. name: string;
  51093. /**
  51094. * Effect Name of the highlight layer.
  51095. */
  51096. static readonly EffectName: string;
  51097. /**
  51098. * The neutral color used during the preparation of the glow effect.
  51099. * This is black by default as the blend operation is a blend operation.
  51100. */
  51101. static NeutralColor: Color4;
  51102. /**
  51103. * Stencil value used for glowing meshes.
  51104. */
  51105. static GlowingMeshStencilReference: number;
  51106. /**
  51107. * Stencil value used for the other meshes in the scene.
  51108. */
  51109. static NormalMeshStencilReference: number;
  51110. /**
  51111. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51112. */
  51113. innerGlow: boolean;
  51114. /**
  51115. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51116. */
  51117. outerGlow: boolean;
  51118. /**
  51119. * Specifies the horizontal size of the blur.
  51120. */
  51121. /**
  51122. * Gets the horizontal size of the blur.
  51123. */
  51124. blurHorizontalSize: number;
  51125. /**
  51126. * Specifies the vertical size of the blur.
  51127. */
  51128. /**
  51129. * Gets the vertical size of the blur.
  51130. */
  51131. blurVerticalSize: number;
  51132. /**
  51133. * An event triggered when the highlight layer is being blurred.
  51134. */
  51135. onBeforeBlurObservable: Observable<HighlightLayer>;
  51136. /**
  51137. * An event triggered when the highlight layer has been blurred.
  51138. */
  51139. onAfterBlurObservable: Observable<HighlightLayer>;
  51140. private _instanceGlowingMeshStencilReference;
  51141. private _options;
  51142. private _downSamplePostprocess;
  51143. private _horizontalBlurPostprocess;
  51144. private _verticalBlurPostprocess;
  51145. private _blurTexture;
  51146. private _meshes;
  51147. private _excludedMeshes;
  51148. /**
  51149. * Instantiates a new highlight Layer and references it to the scene..
  51150. * @param name The name of the layer
  51151. * @param scene The scene to use the layer in
  51152. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51153. */
  51154. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51155. /**
  51156. * Get the effect name of the layer.
  51157. * @return The effect name
  51158. */
  51159. getEffectName(): string;
  51160. /**
  51161. * Create the merge effect. This is the shader use to blit the information back
  51162. * to the main canvas at the end of the scene rendering.
  51163. */
  51164. protected _createMergeEffect(): Effect;
  51165. /**
  51166. * Creates the render target textures and post processes used in the highlight layer.
  51167. */
  51168. protected _createTextureAndPostProcesses(): void;
  51169. /**
  51170. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51171. */
  51172. needStencil(): boolean;
  51173. /**
  51174. * Checks for the readiness of the element composing the layer.
  51175. * @param subMesh the mesh to check for
  51176. * @param useInstances specify wether or not to use instances to render the mesh
  51177. * @param emissiveTexture the associated emissive texture used to generate the glow
  51178. * @return true if ready otherwise, false
  51179. */
  51180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51181. /**
  51182. * Implementation specific of rendering the generating effect on the main canvas.
  51183. * @param effect The effect used to render through
  51184. */
  51185. protected _internalRender(effect: Effect): void;
  51186. /**
  51187. * Returns true if the layer contains information to display, otherwise false.
  51188. */
  51189. shouldRender(): boolean;
  51190. /**
  51191. * Returns true if the mesh should render, otherwise false.
  51192. * @param mesh The mesh to render
  51193. * @returns true if it should render otherwise false
  51194. */
  51195. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51196. /**
  51197. * Sets the required values for both the emissive texture and and the main color.
  51198. */
  51199. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51200. /**
  51201. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51202. * @param mesh The mesh to exclude from the highlight layer
  51203. */
  51204. addExcludedMesh(mesh: Mesh): void;
  51205. /**
  51206. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51207. * @param mesh The mesh to highlight
  51208. */
  51209. removeExcludedMesh(mesh: Mesh): void;
  51210. /**
  51211. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51212. * @param mesh mesh to test
  51213. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51214. */
  51215. hasMesh(mesh: AbstractMesh): boolean;
  51216. /**
  51217. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51218. * @param mesh The mesh to highlight
  51219. * @param color The color of the highlight
  51220. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51221. */
  51222. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51223. /**
  51224. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51225. * @param mesh The mesh to highlight
  51226. */
  51227. removeMesh(mesh: Mesh): void;
  51228. /**
  51229. * Force the stencil to the normal expected value for none glowing parts
  51230. */
  51231. private _defaultStencilReference;
  51232. /**
  51233. * Free any resources and references associated to a mesh.
  51234. * Internal use
  51235. * @param mesh The mesh to free.
  51236. * @hidden
  51237. */
  51238. _disposeMesh(mesh: Mesh): void;
  51239. /**
  51240. * Dispose the highlight layer and free resources.
  51241. */
  51242. dispose(): void;
  51243. /**
  51244. * Gets the class name of the effect layer
  51245. * @returns the string with the class name of the effect layer
  51246. */
  51247. getClassName(): string;
  51248. /**
  51249. * Serializes this Highlight layer
  51250. * @returns a serialized Highlight layer object
  51251. */
  51252. serialize(): any;
  51253. /**
  51254. * Creates a Highlight layer from parsed Highlight layer data
  51255. * @param parsedHightlightLayer defines the Highlight layer data
  51256. * @param scene defines the current scene
  51257. * @param rootUrl defines the root URL containing the Highlight layer information
  51258. * @returns a parsed Highlight layer
  51259. */
  51260. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51261. }
  51262. }
  51263. declare module "babylonjs/Layers/layerSceneComponent" {
  51264. import { Scene } from "babylonjs/scene";
  51265. import { ISceneComponent } from "babylonjs/sceneComponent";
  51266. import { Layer } from "babylonjs/Layers/layer";
  51267. import { AbstractScene } from "babylonjs/abstractScene";
  51268. module "babylonjs/abstractScene" {
  51269. interface AbstractScene {
  51270. /**
  51271. * The list of layers (background and foreground) of the scene
  51272. */
  51273. layers: Array<Layer>;
  51274. }
  51275. }
  51276. /**
  51277. * Defines the layer scene component responsible to manage any layers
  51278. * in a given scene.
  51279. */
  51280. export class LayerSceneComponent implements ISceneComponent {
  51281. /**
  51282. * The component name helpfull to identify the component in the list of scene components.
  51283. */
  51284. readonly name: string;
  51285. /**
  51286. * The scene the component belongs to.
  51287. */
  51288. scene: Scene;
  51289. private _engine;
  51290. /**
  51291. * Creates a new instance of the component for the given scene
  51292. * @param scene Defines the scene to register the component in
  51293. */
  51294. constructor(scene: Scene);
  51295. /**
  51296. * Registers the component in a given scene
  51297. */
  51298. register(): void;
  51299. /**
  51300. * Rebuilds the elements related to this component in case of
  51301. * context lost for instance.
  51302. */
  51303. rebuild(): void;
  51304. /**
  51305. * Disposes the component and the associated ressources.
  51306. */
  51307. dispose(): void;
  51308. private _draw;
  51309. private _drawCameraPredicate;
  51310. private _drawCameraBackground;
  51311. private _drawCameraForeground;
  51312. private _drawRenderTargetPredicate;
  51313. private _drawRenderTargetBackground;
  51314. private _drawRenderTargetForeground;
  51315. /**
  51316. * Adds all the elements from the container to the scene
  51317. * @param container the container holding the elements
  51318. */
  51319. addFromContainer(container: AbstractScene): void;
  51320. /**
  51321. * Removes all the elements in the container from the scene
  51322. * @param container contains the elements to remove
  51323. * @param dispose if the removed element should be disposed (default: false)
  51324. */
  51325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51326. }
  51327. }
  51328. declare module "babylonjs/Shaders/layer.fragment" {
  51329. /** @hidden */
  51330. export var layerPixelShader: {
  51331. name: string;
  51332. shader: string;
  51333. };
  51334. }
  51335. declare module "babylonjs/Shaders/layer.vertex" {
  51336. /** @hidden */
  51337. export var layerVertexShader: {
  51338. name: string;
  51339. shader: string;
  51340. };
  51341. }
  51342. declare module "babylonjs/Layers/layer" {
  51343. import { Observable } from "babylonjs/Misc/observable";
  51344. import { Nullable } from "babylonjs/types";
  51345. import { Scene } from "babylonjs/scene";
  51346. import { Vector2 } from "babylonjs/Maths/math.vector";
  51347. import { Color4 } from "babylonjs/Maths/math.color";
  51348. import { Texture } from "babylonjs/Materials/Textures/texture";
  51349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51350. import "babylonjs/Shaders/layer.fragment";
  51351. import "babylonjs/Shaders/layer.vertex";
  51352. /**
  51353. * This represents a full screen 2d layer.
  51354. * This can be useful to display a picture in the background of your scene for instance.
  51355. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51356. */
  51357. export class Layer {
  51358. /**
  51359. * Define the name of the layer.
  51360. */
  51361. name: string;
  51362. /**
  51363. * Define the texture the layer should display.
  51364. */
  51365. texture: Nullable<Texture>;
  51366. /**
  51367. * Is the layer in background or foreground.
  51368. */
  51369. isBackground: boolean;
  51370. /**
  51371. * Define the color of the layer (instead of texture).
  51372. */
  51373. color: Color4;
  51374. /**
  51375. * Define the scale of the layer in order to zoom in out of the texture.
  51376. */
  51377. scale: Vector2;
  51378. /**
  51379. * Define an offset for the layer in order to shift the texture.
  51380. */
  51381. offset: Vector2;
  51382. /**
  51383. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51384. */
  51385. alphaBlendingMode: number;
  51386. /**
  51387. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51388. * Alpha test will not mix with the background color in case of transparency.
  51389. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51390. */
  51391. alphaTest: boolean;
  51392. /**
  51393. * Define a mask to restrict the layer to only some of the scene cameras.
  51394. */
  51395. layerMask: number;
  51396. /**
  51397. * Define the list of render target the layer is visible into.
  51398. */
  51399. renderTargetTextures: RenderTargetTexture[];
  51400. /**
  51401. * Define if the layer is only used in renderTarget or if it also
  51402. * renders in the main frame buffer of the canvas.
  51403. */
  51404. renderOnlyInRenderTargetTextures: boolean;
  51405. private _scene;
  51406. private _vertexBuffers;
  51407. private _indexBuffer;
  51408. private _effect;
  51409. private _alphaTestEffect;
  51410. /**
  51411. * An event triggered when the layer is disposed.
  51412. */
  51413. onDisposeObservable: Observable<Layer>;
  51414. private _onDisposeObserver;
  51415. /**
  51416. * Back compatibility with callback before the onDisposeObservable existed.
  51417. * The set callback will be triggered when the layer has been disposed.
  51418. */
  51419. onDispose: () => void;
  51420. /**
  51421. * An event triggered before rendering the scene
  51422. */
  51423. onBeforeRenderObservable: Observable<Layer>;
  51424. private _onBeforeRenderObserver;
  51425. /**
  51426. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51427. * The set callback will be triggered just before rendering the layer.
  51428. */
  51429. onBeforeRender: () => void;
  51430. /**
  51431. * An event triggered after rendering the scene
  51432. */
  51433. onAfterRenderObservable: Observable<Layer>;
  51434. private _onAfterRenderObserver;
  51435. /**
  51436. * Back compatibility with callback before the onAfterRenderObservable existed.
  51437. * The set callback will be triggered just after rendering the layer.
  51438. */
  51439. onAfterRender: () => void;
  51440. /**
  51441. * Instantiates a new layer.
  51442. * This represents a full screen 2d layer.
  51443. * This can be useful to display a picture in the background of your scene for instance.
  51444. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51445. * @param name Define the name of the layer in the scene
  51446. * @param imgUrl Define the url of the texture to display in the layer
  51447. * @param scene Define the scene the layer belongs to
  51448. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51449. * @param color Defines a color for the layer
  51450. */
  51451. constructor(
  51452. /**
  51453. * Define the name of the layer.
  51454. */
  51455. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51456. private _createIndexBuffer;
  51457. /** @hidden */
  51458. _rebuild(): void;
  51459. /**
  51460. * Renders the layer in the scene.
  51461. */
  51462. render(): void;
  51463. /**
  51464. * Disposes and releases the associated ressources.
  51465. */
  51466. dispose(): void;
  51467. }
  51468. }
  51469. declare module "babylonjs/Layers/index" {
  51470. export * from "babylonjs/Layers/effectLayer";
  51471. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51472. export * from "babylonjs/Layers/glowLayer";
  51473. export * from "babylonjs/Layers/highlightLayer";
  51474. export * from "babylonjs/Layers/layer";
  51475. export * from "babylonjs/Layers/layerSceneComponent";
  51476. }
  51477. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51478. /** @hidden */
  51479. export var lensFlarePixelShader: {
  51480. name: string;
  51481. shader: string;
  51482. };
  51483. }
  51484. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51485. /** @hidden */
  51486. export var lensFlareVertexShader: {
  51487. name: string;
  51488. shader: string;
  51489. };
  51490. }
  51491. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51492. import { Scene } from "babylonjs/scene";
  51493. import { Vector3 } from "babylonjs/Maths/math.vector";
  51494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51495. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51496. import "babylonjs/Shaders/lensFlare.fragment";
  51497. import "babylonjs/Shaders/lensFlare.vertex";
  51498. import { Viewport } from "babylonjs/Maths/math.viewport";
  51499. /**
  51500. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51501. * It is usually composed of several `lensFlare`.
  51502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51503. */
  51504. export class LensFlareSystem {
  51505. /**
  51506. * Define the name of the lens flare system
  51507. */
  51508. name: string;
  51509. /**
  51510. * List of lens flares used in this system.
  51511. */
  51512. lensFlares: LensFlare[];
  51513. /**
  51514. * Define a limit from the border the lens flare can be visible.
  51515. */
  51516. borderLimit: number;
  51517. /**
  51518. * Define a viewport border we do not want to see the lens flare in.
  51519. */
  51520. viewportBorder: number;
  51521. /**
  51522. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51523. */
  51524. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51525. /**
  51526. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51527. */
  51528. layerMask: number;
  51529. /**
  51530. * Define the id of the lens flare system in the scene.
  51531. * (equal to name by default)
  51532. */
  51533. id: string;
  51534. private _scene;
  51535. private _emitter;
  51536. private _vertexBuffers;
  51537. private _indexBuffer;
  51538. private _effect;
  51539. private _positionX;
  51540. private _positionY;
  51541. private _isEnabled;
  51542. /** @hidden */
  51543. static _SceneComponentInitialization: (scene: Scene) => void;
  51544. /**
  51545. * Instantiates a lens flare system.
  51546. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51547. * It is usually composed of several `lensFlare`.
  51548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51549. * @param name Define the name of the lens flare system in the scene
  51550. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51551. * @param scene Define the scene the lens flare system belongs to
  51552. */
  51553. constructor(
  51554. /**
  51555. * Define the name of the lens flare system
  51556. */
  51557. name: string, emitter: any, scene: Scene);
  51558. /**
  51559. * Define if the lens flare system is enabled.
  51560. */
  51561. isEnabled: boolean;
  51562. /**
  51563. * Get the scene the effects belongs to.
  51564. * @returns the scene holding the lens flare system
  51565. */
  51566. getScene(): Scene;
  51567. /**
  51568. * Get the emitter of the lens flare system.
  51569. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51570. * @returns the emitter of the lens flare system
  51571. */
  51572. getEmitter(): any;
  51573. /**
  51574. * Set the emitter of the lens flare system.
  51575. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51576. * @param newEmitter Define the new emitter of the system
  51577. */
  51578. setEmitter(newEmitter: any): void;
  51579. /**
  51580. * Get the lens flare system emitter position.
  51581. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51582. * @returns the position
  51583. */
  51584. getEmitterPosition(): Vector3;
  51585. /**
  51586. * @hidden
  51587. */
  51588. computeEffectivePosition(globalViewport: Viewport): boolean;
  51589. /** @hidden */
  51590. _isVisible(): boolean;
  51591. /**
  51592. * @hidden
  51593. */
  51594. render(): boolean;
  51595. /**
  51596. * Dispose and release the lens flare with its associated resources.
  51597. */
  51598. dispose(): void;
  51599. /**
  51600. * Parse a lens flare system from a JSON repressentation
  51601. * @param parsedLensFlareSystem Define the JSON to parse
  51602. * @param scene Define the scene the parsed system should be instantiated in
  51603. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51604. * @returns the parsed system
  51605. */
  51606. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51607. /**
  51608. * Serialize the current Lens Flare System into a JSON representation.
  51609. * @returns the serialized JSON
  51610. */
  51611. serialize(): any;
  51612. }
  51613. }
  51614. declare module "babylonjs/LensFlares/lensFlare" {
  51615. import { Nullable } from "babylonjs/types";
  51616. import { Color3 } from "babylonjs/Maths/math.color";
  51617. import { Texture } from "babylonjs/Materials/Textures/texture";
  51618. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51619. /**
  51620. * This represents one of the lens effect in a `lensFlareSystem`.
  51621. * It controls one of the indiviual texture used in the effect.
  51622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51623. */
  51624. export class LensFlare {
  51625. /**
  51626. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51627. */
  51628. size: number;
  51629. /**
  51630. * 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.
  51631. */
  51632. position: number;
  51633. /**
  51634. * Define the lens color.
  51635. */
  51636. color: Color3;
  51637. /**
  51638. * Define the lens texture.
  51639. */
  51640. texture: Nullable<Texture>;
  51641. /**
  51642. * Define the alpha mode to render this particular lens.
  51643. */
  51644. alphaMode: number;
  51645. private _system;
  51646. /**
  51647. * Creates a new Lens Flare.
  51648. * This represents one of the lens effect in a `lensFlareSystem`.
  51649. * It controls one of the indiviual texture used in the effect.
  51650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51651. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51652. * @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.
  51653. * @param color Define the lens color
  51654. * @param imgUrl Define the lens texture url
  51655. * @param system Define the `lensFlareSystem` this flare is part of
  51656. * @returns The newly created Lens Flare
  51657. */
  51658. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51659. /**
  51660. * Instantiates a new Lens Flare.
  51661. * This represents one of the lens effect in a `lensFlareSystem`.
  51662. * It controls one of the indiviual texture used in the effect.
  51663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51664. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51665. * @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.
  51666. * @param color Define the lens color
  51667. * @param imgUrl Define the lens texture url
  51668. * @param system Define the `lensFlareSystem` this flare is part of
  51669. */
  51670. constructor(
  51671. /**
  51672. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51673. */
  51674. size: number,
  51675. /**
  51676. * 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.
  51677. */
  51678. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51679. /**
  51680. * Dispose and release the lens flare with its associated resources.
  51681. */
  51682. dispose(): void;
  51683. }
  51684. }
  51685. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51686. import { Nullable } from "babylonjs/types";
  51687. import { Scene } from "babylonjs/scene";
  51688. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51689. import { AbstractScene } from "babylonjs/abstractScene";
  51690. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51691. module "babylonjs/abstractScene" {
  51692. interface AbstractScene {
  51693. /**
  51694. * The list of lens flare system added to the scene
  51695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51696. */
  51697. lensFlareSystems: Array<LensFlareSystem>;
  51698. /**
  51699. * Removes the given lens flare system from this scene.
  51700. * @param toRemove The lens flare system to remove
  51701. * @returns The index of the removed lens flare system
  51702. */
  51703. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51704. /**
  51705. * Adds the given lens flare system to this scene
  51706. * @param newLensFlareSystem The lens flare system to add
  51707. */
  51708. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51709. /**
  51710. * Gets a lens flare system using its name
  51711. * @param name defines the name to look for
  51712. * @returns the lens flare system or null if not found
  51713. */
  51714. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51715. /**
  51716. * Gets a lens flare system using its id
  51717. * @param id defines the id to look for
  51718. * @returns the lens flare system or null if not found
  51719. */
  51720. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51721. }
  51722. }
  51723. /**
  51724. * Defines the lens flare scene component responsible to manage any lens flares
  51725. * in a given scene.
  51726. */
  51727. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51728. /**
  51729. * The component name helpfull to identify the component in the list of scene components.
  51730. */
  51731. readonly name: string;
  51732. /**
  51733. * The scene the component belongs to.
  51734. */
  51735. scene: Scene;
  51736. /**
  51737. * Creates a new instance of the component for the given scene
  51738. * @param scene Defines the scene to register the component in
  51739. */
  51740. constructor(scene: Scene);
  51741. /**
  51742. * Registers the component in a given scene
  51743. */
  51744. register(): void;
  51745. /**
  51746. * Rebuilds the elements related to this component in case of
  51747. * context lost for instance.
  51748. */
  51749. rebuild(): void;
  51750. /**
  51751. * Adds all the elements from the container to the scene
  51752. * @param container the container holding the elements
  51753. */
  51754. addFromContainer(container: AbstractScene): void;
  51755. /**
  51756. * Removes all the elements in the container from the scene
  51757. * @param container contains the elements to remove
  51758. * @param dispose if the removed element should be disposed (default: false)
  51759. */
  51760. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51761. /**
  51762. * Serializes the component data to the specified json object
  51763. * @param serializationObject The object to serialize to
  51764. */
  51765. serialize(serializationObject: any): void;
  51766. /**
  51767. * Disposes the component and the associated ressources.
  51768. */
  51769. dispose(): void;
  51770. private _draw;
  51771. }
  51772. }
  51773. declare module "babylonjs/LensFlares/index" {
  51774. export * from "babylonjs/LensFlares/lensFlare";
  51775. export * from "babylonjs/LensFlares/lensFlareSystem";
  51776. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51777. }
  51778. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51779. import { Scene } from "babylonjs/scene";
  51780. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51781. import { AbstractScene } from "babylonjs/abstractScene";
  51782. /**
  51783. * Defines the shadow generator component responsible to manage any shadow generators
  51784. * in a given scene.
  51785. */
  51786. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51787. /**
  51788. * The component name helpfull to identify the component in the list of scene components.
  51789. */
  51790. readonly name: string;
  51791. /**
  51792. * The scene the component belongs to.
  51793. */
  51794. scene: Scene;
  51795. /**
  51796. * Creates a new instance of the component for the given scene
  51797. * @param scene Defines the scene to register the component in
  51798. */
  51799. constructor(scene: Scene);
  51800. /**
  51801. * Registers the component in a given scene
  51802. */
  51803. register(): void;
  51804. /**
  51805. * Rebuilds the elements related to this component in case of
  51806. * context lost for instance.
  51807. */
  51808. rebuild(): void;
  51809. /**
  51810. * Serializes the component data to the specified json object
  51811. * @param serializationObject The object to serialize to
  51812. */
  51813. serialize(serializationObject: any): void;
  51814. /**
  51815. * Adds all the elements from the container to the scene
  51816. * @param container the container holding the elements
  51817. */
  51818. addFromContainer(container: AbstractScene): void;
  51819. /**
  51820. * Removes all the elements in the container from the scene
  51821. * @param container contains the elements to remove
  51822. * @param dispose if the removed element should be disposed (default: false)
  51823. */
  51824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51825. /**
  51826. * Rebuilds the elements related to this component in case of
  51827. * context lost for instance.
  51828. */
  51829. dispose(): void;
  51830. private _gatherRenderTargets;
  51831. }
  51832. }
  51833. declare module "babylonjs/Lights/Shadows/index" {
  51834. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51835. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51836. }
  51837. declare module "babylonjs/Lights/pointLight" {
  51838. import { Scene } from "babylonjs/scene";
  51839. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51841. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51842. import { Effect } from "babylonjs/Materials/effect";
  51843. /**
  51844. * A point light is a light defined by an unique point in world space.
  51845. * The light is emitted in every direction from this point.
  51846. * A good example of a point light is a standard light bulb.
  51847. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51848. */
  51849. export class PointLight extends ShadowLight {
  51850. private _shadowAngle;
  51851. /**
  51852. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51853. * This specifies what angle the shadow will use to be created.
  51854. *
  51855. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51856. */
  51857. /**
  51858. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51859. * This specifies what angle the shadow will use to be created.
  51860. *
  51861. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51862. */
  51863. shadowAngle: number;
  51864. /**
  51865. * Gets the direction if it has been set.
  51866. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51867. */
  51868. /**
  51869. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51870. */
  51871. direction: Vector3;
  51872. /**
  51873. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51874. * A PointLight emits the light in every direction.
  51875. * It can cast shadows.
  51876. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51877. * ```javascript
  51878. * var pointLight = new PointLight("pl", camera.position, scene);
  51879. * ```
  51880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51881. * @param name The light friendly name
  51882. * @param position The position of the point light in the scene
  51883. * @param scene The scene the lights belongs to
  51884. */
  51885. constructor(name: string, position: Vector3, scene: Scene);
  51886. /**
  51887. * Returns the string "PointLight"
  51888. * @returns the class name
  51889. */
  51890. getClassName(): string;
  51891. /**
  51892. * Returns the integer 0.
  51893. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51894. */
  51895. getTypeID(): number;
  51896. /**
  51897. * Specifies wether or not the shadowmap should be a cube texture.
  51898. * @returns true if the shadowmap needs to be a cube texture.
  51899. */
  51900. needCube(): boolean;
  51901. /**
  51902. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51903. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51904. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51905. */
  51906. getShadowDirection(faceIndex?: number): Vector3;
  51907. /**
  51908. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51909. * - fov = PI / 2
  51910. * - aspect ratio : 1.0
  51911. * - z-near and far equal to the active camera minZ and maxZ.
  51912. * Returns the PointLight.
  51913. */
  51914. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51915. protected _buildUniformLayout(): void;
  51916. /**
  51917. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51918. * @param effect The effect to update
  51919. * @param lightIndex The index of the light in the effect to update
  51920. * @returns The point light
  51921. */
  51922. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51923. /**
  51924. * Prepares the list of defines specific to the light type.
  51925. * @param defines the list of defines
  51926. * @param lightIndex defines the index of the light for the effect
  51927. */
  51928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51929. }
  51930. }
  51931. declare module "babylonjs/Lights/index" {
  51932. export * from "babylonjs/Lights/light";
  51933. export * from "babylonjs/Lights/shadowLight";
  51934. export * from "babylonjs/Lights/Shadows/index";
  51935. export * from "babylonjs/Lights/directionalLight";
  51936. export * from "babylonjs/Lights/hemisphericLight";
  51937. export * from "babylonjs/Lights/pointLight";
  51938. export * from "babylonjs/Lights/spotLight";
  51939. }
  51940. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51941. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51942. /**
  51943. * Header information of HDR texture files.
  51944. */
  51945. export interface HDRInfo {
  51946. /**
  51947. * The height of the texture in pixels.
  51948. */
  51949. height: number;
  51950. /**
  51951. * The width of the texture in pixels.
  51952. */
  51953. width: number;
  51954. /**
  51955. * The index of the beginning of the data in the binary file.
  51956. */
  51957. dataPosition: number;
  51958. }
  51959. /**
  51960. * This groups tools to convert HDR texture to native colors array.
  51961. */
  51962. export class HDRTools {
  51963. private static Ldexp;
  51964. private static Rgbe2float;
  51965. private static readStringLine;
  51966. /**
  51967. * Reads header information from an RGBE texture stored in a native array.
  51968. * More information on this format are available here:
  51969. * https://en.wikipedia.org/wiki/RGBE_image_format
  51970. *
  51971. * @param uint8array The binary file stored in native array.
  51972. * @return The header information.
  51973. */
  51974. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51975. /**
  51976. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51977. * This RGBE texture needs to store the information as a panorama.
  51978. *
  51979. * More information on this format are available here:
  51980. * https://en.wikipedia.org/wiki/RGBE_image_format
  51981. *
  51982. * @param buffer The binary file stored in an array buffer.
  51983. * @param size The expected size of the extracted cubemap.
  51984. * @return The Cube Map information.
  51985. */
  51986. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51987. /**
  51988. * Returns the pixels data extracted from an RGBE texture.
  51989. * This pixels will be stored left to right up to down in the R G B order in one array.
  51990. *
  51991. * More information on this format are available here:
  51992. * https://en.wikipedia.org/wiki/RGBE_image_format
  51993. *
  51994. * @param uint8array The binary file stored in an array buffer.
  51995. * @param hdrInfo The header information of the file.
  51996. * @return The pixels data in RGB right to left up to down order.
  51997. */
  51998. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51999. private static RGBE_ReadPixels_RLE;
  52000. }
  52001. }
  52002. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52003. import { Nullable } from "babylonjs/types";
  52004. import { Scene } from "babylonjs/scene";
  52005. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52007. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52008. /**
  52009. * This represents a texture coming from an HDR input.
  52010. *
  52011. * The only supported format is currently panorama picture stored in RGBE format.
  52012. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52013. */
  52014. export class HDRCubeTexture extends BaseTexture {
  52015. private static _facesMapping;
  52016. private _generateHarmonics;
  52017. private _noMipmap;
  52018. private _textureMatrix;
  52019. private _size;
  52020. private _onLoad;
  52021. private _onError;
  52022. /**
  52023. * The texture URL.
  52024. */
  52025. url: string;
  52026. /**
  52027. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52028. */
  52029. coordinatesMode: number;
  52030. protected _isBlocking: boolean;
  52031. /**
  52032. * Sets wether or not the texture is blocking during loading.
  52033. */
  52034. /**
  52035. * Gets wether or not the texture is blocking during loading.
  52036. */
  52037. isBlocking: boolean;
  52038. protected _rotationY: number;
  52039. /**
  52040. * Sets texture matrix rotation angle around Y axis in radians.
  52041. */
  52042. /**
  52043. * Gets texture matrix rotation angle around Y axis radians.
  52044. */
  52045. rotationY: number;
  52046. /**
  52047. * Gets or sets the center of the bounding box associated with the cube texture
  52048. * It must define where the camera used to render the texture was set
  52049. */
  52050. boundingBoxPosition: Vector3;
  52051. private _boundingBoxSize;
  52052. /**
  52053. * Gets or sets the size of the bounding box associated with the cube texture
  52054. * When defined, the cubemap will switch to local mode
  52055. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52056. * @example https://www.babylonjs-playground.com/#RNASML
  52057. */
  52058. boundingBoxSize: Vector3;
  52059. /**
  52060. * Instantiates an HDRTexture from the following parameters.
  52061. *
  52062. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52063. * @param scene The scene the texture will be used in
  52064. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52065. * @param noMipmap Forces to not generate the mipmap if true
  52066. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52067. * @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)
  52068. * @param reserved Reserved flag for internal use.
  52069. */
  52070. 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>);
  52071. /**
  52072. * Get the current class name of the texture useful for serialization or dynamic coding.
  52073. * @returns "HDRCubeTexture"
  52074. */
  52075. getClassName(): string;
  52076. /**
  52077. * Occurs when the file is raw .hdr file.
  52078. */
  52079. private loadTexture;
  52080. clone(): HDRCubeTexture;
  52081. delayLoad(): void;
  52082. /**
  52083. * Get the texture reflection matrix used to rotate/transform the reflection.
  52084. * @returns the reflection matrix
  52085. */
  52086. getReflectionTextureMatrix(): Matrix;
  52087. /**
  52088. * Set the texture reflection matrix used to rotate/transform the reflection.
  52089. * @param value Define the reflection matrix to set
  52090. */
  52091. setReflectionTextureMatrix(value: Matrix): void;
  52092. /**
  52093. * Parses a JSON representation of an HDR Texture in order to create the texture
  52094. * @param parsedTexture Define the JSON representation
  52095. * @param scene Define the scene the texture should be created in
  52096. * @param rootUrl Define the root url in case we need to load relative dependencies
  52097. * @returns the newly created texture after parsing
  52098. */
  52099. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52100. serialize(): any;
  52101. }
  52102. }
  52103. declare module "babylonjs/Physics/physicsEngine" {
  52104. import { Nullable } from "babylonjs/types";
  52105. import { Vector3 } from "babylonjs/Maths/math.vector";
  52106. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52107. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52108. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52109. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52110. /**
  52111. * Class used to control physics engine
  52112. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52113. */
  52114. export class PhysicsEngine implements IPhysicsEngine {
  52115. private _physicsPlugin;
  52116. /**
  52117. * Global value used to control the smallest number supported by the simulation
  52118. */
  52119. static Epsilon: number;
  52120. private _impostors;
  52121. private _joints;
  52122. /**
  52123. * Gets the gravity vector used by the simulation
  52124. */
  52125. gravity: Vector3;
  52126. /**
  52127. * Factory used to create the default physics plugin.
  52128. * @returns The default physics plugin
  52129. */
  52130. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52131. /**
  52132. * Creates a new Physics Engine
  52133. * @param gravity defines the gravity vector used by the simulation
  52134. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52135. */
  52136. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52137. /**
  52138. * Sets the gravity vector used by the simulation
  52139. * @param gravity defines the gravity vector to use
  52140. */
  52141. setGravity(gravity: Vector3): void;
  52142. /**
  52143. * Set the time step of the physics engine.
  52144. * Default is 1/60.
  52145. * To slow it down, enter 1/600 for example.
  52146. * To speed it up, 1/30
  52147. * @param newTimeStep defines the new timestep to apply to this world.
  52148. */
  52149. setTimeStep(newTimeStep?: number): void;
  52150. /**
  52151. * Get the time step of the physics engine.
  52152. * @returns the current time step
  52153. */
  52154. getTimeStep(): number;
  52155. /**
  52156. * Release all resources
  52157. */
  52158. dispose(): void;
  52159. /**
  52160. * Gets the name of the current physics plugin
  52161. * @returns the name of the plugin
  52162. */
  52163. getPhysicsPluginName(): string;
  52164. /**
  52165. * Adding a new impostor for the impostor tracking.
  52166. * This will be done by the impostor itself.
  52167. * @param impostor the impostor to add
  52168. */
  52169. addImpostor(impostor: PhysicsImpostor): void;
  52170. /**
  52171. * Remove an impostor from the engine.
  52172. * This impostor and its mesh will not longer be updated by the physics engine.
  52173. * @param impostor the impostor to remove
  52174. */
  52175. removeImpostor(impostor: PhysicsImpostor): void;
  52176. /**
  52177. * Add a joint to the physics engine
  52178. * @param mainImpostor defines the main impostor to which the joint is added.
  52179. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52180. * @param joint defines the joint that will connect both impostors.
  52181. */
  52182. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52183. /**
  52184. * Removes a joint from the simulation
  52185. * @param mainImpostor defines the impostor used with the joint
  52186. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52187. * @param joint defines the joint to remove
  52188. */
  52189. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52190. /**
  52191. * Called by the scene. No need to call it.
  52192. * @param delta defines the timespam between frames
  52193. */
  52194. _step(delta: number): void;
  52195. /**
  52196. * Gets the current plugin used to run the simulation
  52197. * @returns current plugin
  52198. */
  52199. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52200. /**
  52201. * Gets the list of physic impostors
  52202. * @returns an array of PhysicsImpostor
  52203. */
  52204. getImpostors(): Array<PhysicsImpostor>;
  52205. /**
  52206. * Gets the impostor for a physics enabled object
  52207. * @param object defines the object impersonated by the impostor
  52208. * @returns the PhysicsImpostor or null if not found
  52209. */
  52210. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52211. /**
  52212. * Gets the impostor for a physics body object
  52213. * @param body defines physics body used by the impostor
  52214. * @returns the PhysicsImpostor or null if not found
  52215. */
  52216. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52217. /**
  52218. * Does a raycast in the physics world
  52219. * @param from when should the ray start?
  52220. * @param to when should the ray end?
  52221. * @returns PhysicsRaycastResult
  52222. */
  52223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52224. }
  52225. }
  52226. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52227. import { Nullable } from "babylonjs/types";
  52228. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52230. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52231. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52232. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52233. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52234. /** @hidden */
  52235. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52236. private _useDeltaForWorldStep;
  52237. world: any;
  52238. name: string;
  52239. private _physicsMaterials;
  52240. private _fixedTimeStep;
  52241. private _cannonRaycastResult;
  52242. private _raycastResult;
  52243. private _physicsBodysToRemoveAfterStep;
  52244. BJSCANNON: any;
  52245. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52246. setGravity(gravity: Vector3): void;
  52247. setTimeStep(timeStep: number): void;
  52248. getTimeStep(): number;
  52249. executeStep(delta: number): void;
  52250. private _removeMarkedPhysicsBodiesFromWorld;
  52251. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52252. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52253. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52254. private _processChildMeshes;
  52255. removePhysicsBody(impostor: PhysicsImpostor): void;
  52256. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52257. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52258. private _addMaterial;
  52259. private _checkWithEpsilon;
  52260. private _createShape;
  52261. private _createHeightmap;
  52262. private _minus90X;
  52263. private _plus90X;
  52264. private _tmpPosition;
  52265. private _tmpDeltaPosition;
  52266. private _tmpUnityRotation;
  52267. private _updatePhysicsBodyTransformation;
  52268. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52270. isSupported(): boolean;
  52271. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52272. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52273. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52274. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52275. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52276. getBodyMass(impostor: PhysicsImpostor): number;
  52277. getBodyFriction(impostor: PhysicsImpostor): number;
  52278. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52279. getBodyRestitution(impostor: PhysicsImpostor): number;
  52280. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52281. sleepBody(impostor: PhysicsImpostor): void;
  52282. wakeUpBody(impostor: PhysicsImpostor): void;
  52283. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52284. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52285. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52286. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52287. getRadius(impostor: PhysicsImpostor): number;
  52288. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52289. dispose(): void;
  52290. private _extendNamespace;
  52291. /**
  52292. * Does a raycast in the physics world
  52293. * @param from when should the ray start?
  52294. * @param to when should the ray end?
  52295. * @returns PhysicsRaycastResult
  52296. */
  52297. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52298. }
  52299. }
  52300. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52301. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52302. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52303. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52305. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52306. import { Nullable } from "babylonjs/types";
  52307. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52308. /** @hidden */
  52309. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52310. world: any;
  52311. name: string;
  52312. BJSOIMO: any;
  52313. private _raycastResult;
  52314. constructor(iterations?: number, oimoInjection?: any);
  52315. setGravity(gravity: Vector3): void;
  52316. setTimeStep(timeStep: number): void;
  52317. getTimeStep(): number;
  52318. private _tmpImpostorsArray;
  52319. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52320. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52321. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52322. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52323. private _tmpPositionVector;
  52324. removePhysicsBody(impostor: PhysicsImpostor): void;
  52325. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52326. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52327. isSupported(): boolean;
  52328. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52329. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52334. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52335. getBodyMass(impostor: PhysicsImpostor): number;
  52336. getBodyFriction(impostor: PhysicsImpostor): number;
  52337. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52338. getBodyRestitution(impostor: PhysicsImpostor): number;
  52339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52340. sleepBody(impostor: PhysicsImpostor): void;
  52341. wakeUpBody(impostor: PhysicsImpostor): void;
  52342. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52343. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52344. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52345. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52346. getRadius(impostor: PhysicsImpostor): number;
  52347. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52348. dispose(): void;
  52349. /**
  52350. * Does a raycast in the physics world
  52351. * @param from when should the ray start?
  52352. * @param to when should the ray end?
  52353. * @returns PhysicsRaycastResult
  52354. */
  52355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52356. }
  52357. }
  52358. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52359. import { Nullable } from "babylonjs/types";
  52360. import { Scene } from "babylonjs/scene";
  52361. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52362. import { Color4 } from "babylonjs/Maths/math.color";
  52363. import { Mesh } from "babylonjs/Meshes/mesh";
  52364. /**
  52365. * Class containing static functions to help procedurally build meshes
  52366. */
  52367. export class RibbonBuilder {
  52368. /**
  52369. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52370. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52371. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52372. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52373. * * 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
  52374. * * 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
  52375. * * 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
  52376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52379. * * 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
  52380. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52381. * * 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
  52382. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52384. * @param name defines the name of the mesh
  52385. * @param options defines the options used to create the mesh
  52386. * @param scene defines the hosting scene
  52387. * @returns the ribbon mesh
  52388. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52390. */
  52391. static CreateRibbon(name: string, options: {
  52392. pathArray: Vector3[][];
  52393. closeArray?: boolean;
  52394. closePath?: boolean;
  52395. offset?: number;
  52396. updatable?: boolean;
  52397. sideOrientation?: number;
  52398. frontUVs?: Vector4;
  52399. backUVs?: Vector4;
  52400. instance?: Mesh;
  52401. invertUV?: boolean;
  52402. uvs?: Vector2[];
  52403. colors?: Color4[];
  52404. }, scene?: Nullable<Scene>): Mesh;
  52405. }
  52406. }
  52407. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52408. import { Nullable } from "babylonjs/types";
  52409. import { Scene } from "babylonjs/scene";
  52410. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52411. import { Mesh } from "babylonjs/Meshes/mesh";
  52412. /**
  52413. * Class containing static functions to help procedurally build meshes
  52414. */
  52415. export class ShapeBuilder {
  52416. /**
  52417. * 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.
  52418. * * 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.
  52419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52420. * * 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.
  52421. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52422. * * 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
  52423. * * 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
  52424. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52429. * @param name defines the name of the mesh
  52430. * @param options defines the options used to create the mesh
  52431. * @param scene defines the hosting scene
  52432. * @returns the extruded shape mesh
  52433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52435. */
  52436. static ExtrudeShape(name: string, options: {
  52437. shape: Vector3[];
  52438. path: Vector3[];
  52439. scale?: number;
  52440. rotation?: number;
  52441. cap?: number;
  52442. updatable?: boolean;
  52443. sideOrientation?: number;
  52444. frontUVs?: Vector4;
  52445. backUVs?: Vector4;
  52446. instance?: Mesh;
  52447. invertUV?: boolean;
  52448. }, scene?: Nullable<Scene>): Mesh;
  52449. /**
  52450. * Creates an custom extruded shape mesh.
  52451. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52452. * * 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.
  52453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52454. * * 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
  52455. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52456. * * 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
  52457. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52458. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52459. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52460. * * 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
  52461. * * 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
  52462. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52467. * @param name defines the name of the mesh
  52468. * @param options defines the options used to create the mesh
  52469. * @param scene defines the hosting scene
  52470. * @returns the custom extruded shape mesh
  52471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52474. */
  52475. static ExtrudeShapeCustom(name: string, options: {
  52476. shape: Vector3[];
  52477. path: Vector3[];
  52478. scaleFunction?: any;
  52479. rotationFunction?: any;
  52480. ribbonCloseArray?: boolean;
  52481. ribbonClosePath?: boolean;
  52482. cap?: number;
  52483. updatable?: boolean;
  52484. sideOrientation?: number;
  52485. frontUVs?: Vector4;
  52486. backUVs?: Vector4;
  52487. instance?: Mesh;
  52488. invertUV?: boolean;
  52489. }, scene?: Nullable<Scene>): Mesh;
  52490. private static _ExtrudeShapeGeneric;
  52491. }
  52492. }
  52493. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52494. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52495. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52496. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52497. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52498. import { Nullable } from "babylonjs/types";
  52499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52500. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52501. /**
  52502. * AmmoJS Physics plugin
  52503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52504. * @see https://github.com/kripken/ammo.js/
  52505. */
  52506. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52507. private _useDeltaForWorldStep;
  52508. /**
  52509. * Reference to the Ammo library
  52510. */
  52511. bjsAMMO: any;
  52512. /**
  52513. * Created ammoJS world which physics bodies are added to
  52514. */
  52515. world: any;
  52516. /**
  52517. * Name of the plugin
  52518. */
  52519. name: string;
  52520. private _timeStep;
  52521. private _fixedTimeStep;
  52522. private _maxSteps;
  52523. private _tmpQuaternion;
  52524. private _tmpAmmoTransform;
  52525. private _tmpAmmoQuaternion;
  52526. private _tmpAmmoConcreteContactResultCallback;
  52527. private _collisionConfiguration;
  52528. private _dispatcher;
  52529. private _overlappingPairCache;
  52530. private _solver;
  52531. private _softBodySolver;
  52532. private _tmpAmmoVectorA;
  52533. private _tmpAmmoVectorB;
  52534. private _tmpAmmoVectorC;
  52535. private _tmpAmmoVectorD;
  52536. private _tmpContactCallbackResult;
  52537. private _tmpAmmoVectorRCA;
  52538. private _tmpAmmoVectorRCB;
  52539. private _raycastResult;
  52540. private static readonly DISABLE_COLLISION_FLAG;
  52541. private static readonly KINEMATIC_FLAG;
  52542. private static readonly DISABLE_DEACTIVATION_FLAG;
  52543. /**
  52544. * Initializes the ammoJS plugin
  52545. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52546. * @param ammoInjection can be used to inject your own ammo reference
  52547. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52548. */
  52549. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52550. /**
  52551. * Sets the gravity of the physics world (m/(s^2))
  52552. * @param gravity Gravity to set
  52553. */
  52554. setGravity(gravity: Vector3): void;
  52555. /**
  52556. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52557. * @param timeStep timestep to use in seconds
  52558. */
  52559. setTimeStep(timeStep: number): void;
  52560. /**
  52561. * 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)
  52562. * @param fixedTimeStep fixedTimeStep to use in seconds
  52563. */
  52564. setFixedTimeStep(fixedTimeStep: number): void;
  52565. /**
  52566. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52567. * @param maxSteps the maximum number of steps by the physics engine per frame
  52568. */
  52569. setMaxSteps(maxSteps: number): void;
  52570. /**
  52571. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52572. * @returns the current timestep in seconds
  52573. */
  52574. getTimeStep(): number;
  52575. private _isImpostorInContact;
  52576. private _isImpostorPairInContact;
  52577. private _stepSimulation;
  52578. /**
  52579. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52580. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52581. * After the step the babylon meshes are set to the position of the physics imposters
  52582. * @param delta amount of time to step forward
  52583. * @param impostors array of imposters to update before/after the step
  52584. */
  52585. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52586. /**
  52587. * Update babylon mesh to match physics world object
  52588. * @param impostor imposter to match
  52589. */
  52590. private _afterSoftStep;
  52591. /**
  52592. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52593. * @param impostor imposter to match
  52594. */
  52595. private _ropeStep;
  52596. /**
  52597. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52598. * @param impostor imposter to match
  52599. */
  52600. private _softbodyOrClothStep;
  52601. private _tmpVector;
  52602. private _tmpMatrix;
  52603. /**
  52604. * Applies an impulse on the imposter
  52605. * @param impostor imposter to apply impulse to
  52606. * @param force amount of force to be applied to the imposter
  52607. * @param contactPoint the location to apply the impulse on the imposter
  52608. */
  52609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52610. /**
  52611. * Applies a force on the imposter
  52612. * @param impostor imposter to apply force
  52613. * @param force amount of force to be applied to the imposter
  52614. * @param contactPoint the location to apply the force on the imposter
  52615. */
  52616. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52617. /**
  52618. * Creates a physics body using the plugin
  52619. * @param impostor the imposter to create the physics body on
  52620. */
  52621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52622. /**
  52623. * Removes the physics body from the imposter and disposes of the body's memory
  52624. * @param impostor imposter to remove the physics body from
  52625. */
  52626. removePhysicsBody(impostor: PhysicsImpostor): void;
  52627. /**
  52628. * Generates a joint
  52629. * @param impostorJoint the imposter joint to create the joint with
  52630. */
  52631. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52632. /**
  52633. * Removes a joint
  52634. * @param impostorJoint the imposter joint to remove the joint from
  52635. */
  52636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52637. private _addMeshVerts;
  52638. /**
  52639. * Initialise the soft body vertices to match its object's (mesh) vertices
  52640. * Softbody vertices (nodes) are in world space and to match this
  52641. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52642. * @param impostor to create the softbody for
  52643. */
  52644. private _softVertexData;
  52645. /**
  52646. * Create an impostor's soft body
  52647. * @param impostor to create the softbody for
  52648. */
  52649. private _createSoftbody;
  52650. /**
  52651. * Create cloth for an impostor
  52652. * @param impostor to create the softbody for
  52653. */
  52654. private _createCloth;
  52655. /**
  52656. * Create rope for an impostor
  52657. * @param impostor to create the softbody for
  52658. */
  52659. private _createRope;
  52660. private _addHullVerts;
  52661. private _createShape;
  52662. /**
  52663. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52664. * @param impostor imposter containing the physics body and babylon object
  52665. */
  52666. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52667. /**
  52668. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52669. * @param impostor imposter containing the physics body and babylon object
  52670. * @param newPosition new position
  52671. * @param newRotation new rotation
  52672. */
  52673. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52674. /**
  52675. * If this plugin is supported
  52676. * @returns true if its supported
  52677. */
  52678. isSupported(): boolean;
  52679. /**
  52680. * Sets the linear velocity of the physics body
  52681. * @param impostor imposter to set the velocity on
  52682. * @param velocity velocity to set
  52683. */
  52684. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52685. /**
  52686. * Sets the angular velocity of the physics body
  52687. * @param impostor imposter to set the velocity on
  52688. * @param velocity velocity to set
  52689. */
  52690. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52691. /**
  52692. * gets the linear velocity
  52693. * @param impostor imposter to get linear velocity from
  52694. * @returns linear velocity
  52695. */
  52696. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52697. /**
  52698. * gets the angular velocity
  52699. * @param impostor imposter to get angular velocity from
  52700. * @returns angular velocity
  52701. */
  52702. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52703. /**
  52704. * Sets the mass of physics body
  52705. * @param impostor imposter to set the mass on
  52706. * @param mass mass to set
  52707. */
  52708. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52709. /**
  52710. * Gets the mass of the physics body
  52711. * @param impostor imposter to get the mass from
  52712. * @returns mass
  52713. */
  52714. getBodyMass(impostor: PhysicsImpostor): number;
  52715. /**
  52716. * Gets friction of the impostor
  52717. * @param impostor impostor to get friction from
  52718. * @returns friction value
  52719. */
  52720. getBodyFriction(impostor: PhysicsImpostor): number;
  52721. /**
  52722. * Sets friction of the impostor
  52723. * @param impostor impostor to set friction on
  52724. * @param friction friction value
  52725. */
  52726. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52727. /**
  52728. * Gets restitution of the impostor
  52729. * @param impostor impostor to get restitution from
  52730. * @returns restitution value
  52731. */
  52732. getBodyRestitution(impostor: PhysicsImpostor): number;
  52733. /**
  52734. * Sets resitution of the impostor
  52735. * @param impostor impostor to set resitution on
  52736. * @param restitution resitution value
  52737. */
  52738. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52739. /**
  52740. * Gets pressure inside the impostor
  52741. * @param impostor impostor to get pressure from
  52742. * @returns pressure value
  52743. */
  52744. getBodyPressure(impostor: PhysicsImpostor): number;
  52745. /**
  52746. * Sets pressure inside a soft body impostor
  52747. * Cloth and rope must remain 0 pressure
  52748. * @param impostor impostor to set pressure on
  52749. * @param pressure pressure value
  52750. */
  52751. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52752. /**
  52753. * Gets stiffness of the impostor
  52754. * @param impostor impostor to get stiffness from
  52755. * @returns pressure value
  52756. */
  52757. getBodyStiffness(impostor: PhysicsImpostor): number;
  52758. /**
  52759. * Sets stiffness of the impostor
  52760. * @param impostor impostor to set stiffness on
  52761. * @param stiffness stiffness value from 0 to 1
  52762. */
  52763. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52764. /**
  52765. * Gets velocityIterations of the impostor
  52766. * @param impostor impostor to get velocity iterations from
  52767. * @returns velocityIterations value
  52768. */
  52769. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52770. /**
  52771. * Sets velocityIterations of the impostor
  52772. * @param impostor impostor to set velocity iterations on
  52773. * @param velocityIterations velocityIterations value
  52774. */
  52775. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52776. /**
  52777. * Gets positionIterations of the impostor
  52778. * @param impostor impostor to get position iterations from
  52779. * @returns positionIterations value
  52780. */
  52781. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52782. /**
  52783. * Sets positionIterations of the impostor
  52784. * @param impostor impostor to set position on
  52785. * @param positionIterations positionIterations value
  52786. */
  52787. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52788. /**
  52789. * Append an anchor to a cloth object
  52790. * @param impostor is the cloth impostor to add anchor to
  52791. * @param otherImpostor is the rigid impostor to anchor to
  52792. * @param width ratio across width from 0 to 1
  52793. * @param height ratio up height from 0 to 1
  52794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52795. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52796. */
  52797. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52798. /**
  52799. * Append an hook to a rope object
  52800. * @param impostor is the rope impostor to add hook to
  52801. * @param otherImpostor is the rigid impostor to hook to
  52802. * @param length ratio along the rope from 0 to 1
  52803. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52805. */
  52806. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52807. /**
  52808. * Sleeps the physics body and stops it from being active
  52809. * @param impostor impostor to sleep
  52810. */
  52811. sleepBody(impostor: PhysicsImpostor): void;
  52812. /**
  52813. * Activates the physics body
  52814. * @param impostor impostor to activate
  52815. */
  52816. wakeUpBody(impostor: PhysicsImpostor): void;
  52817. /**
  52818. * Updates the distance parameters of the joint
  52819. * @param joint joint to update
  52820. * @param maxDistance maximum distance of the joint
  52821. * @param minDistance minimum distance of the joint
  52822. */
  52823. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52824. /**
  52825. * Sets a motor on the joint
  52826. * @param joint joint to set motor on
  52827. * @param speed speed of the motor
  52828. * @param maxForce maximum force of the motor
  52829. * @param motorIndex index of the motor
  52830. */
  52831. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52832. /**
  52833. * Sets the motors limit
  52834. * @param joint joint to set limit on
  52835. * @param upperLimit upper limit
  52836. * @param lowerLimit lower limit
  52837. */
  52838. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52839. /**
  52840. * Syncs the position and rotation of a mesh with the impostor
  52841. * @param mesh mesh to sync
  52842. * @param impostor impostor to update the mesh with
  52843. */
  52844. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52845. /**
  52846. * Gets the radius of the impostor
  52847. * @param impostor impostor to get radius from
  52848. * @returns the radius
  52849. */
  52850. getRadius(impostor: PhysicsImpostor): number;
  52851. /**
  52852. * Gets the box size of the impostor
  52853. * @param impostor impostor to get box size from
  52854. * @param result the resulting box size
  52855. */
  52856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52857. /**
  52858. * Disposes of the impostor
  52859. */
  52860. dispose(): void;
  52861. /**
  52862. * Does a raycast in the physics world
  52863. * @param from when should the ray start?
  52864. * @param to when should the ray end?
  52865. * @returns PhysicsRaycastResult
  52866. */
  52867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52868. }
  52869. }
  52870. declare module "babylonjs/Probes/reflectionProbe" {
  52871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52872. import { Vector3 } from "babylonjs/Maths/math.vector";
  52873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52874. import { Nullable } from "babylonjs/types";
  52875. import { Scene } from "babylonjs/scene";
  52876. module "babylonjs/abstractScene" {
  52877. interface AbstractScene {
  52878. /**
  52879. * The list of reflection probes added to the scene
  52880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52881. */
  52882. reflectionProbes: Array<ReflectionProbe>;
  52883. /**
  52884. * Removes the given reflection probe from this scene.
  52885. * @param toRemove The reflection probe to remove
  52886. * @returns The index of the removed reflection probe
  52887. */
  52888. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52889. /**
  52890. * Adds the given reflection probe to this scene.
  52891. * @param newReflectionProbe The reflection probe to add
  52892. */
  52893. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52894. }
  52895. }
  52896. /**
  52897. * Class used to generate realtime reflection / refraction cube textures
  52898. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52899. */
  52900. export class ReflectionProbe {
  52901. /** defines the name of the probe */
  52902. name: string;
  52903. private _scene;
  52904. private _renderTargetTexture;
  52905. private _projectionMatrix;
  52906. private _viewMatrix;
  52907. private _target;
  52908. private _add;
  52909. private _attachedMesh;
  52910. private _invertYAxis;
  52911. /** Gets or sets probe position (center of the cube map) */
  52912. position: Vector3;
  52913. /**
  52914. * Creates a new reflection probe
  52915. * @param name defines the name of the probe
  52916. * @param size defines the texture resolution (for each face)
  52917. * @param scene defines the hosting scene
  52918. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52919. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52920. */
  52921. constructor(
  52922. /** defines the name of the probe */
  52923. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52924. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52925. samples: number;
  52926. /** Gets or sets the refresh rate to use (on every frame by default) */
  52927. refreshRate: number;
  52928. /**
  52929. * Gets the hosting scene
  52930. * @returns a Scene
  52931. */
  52932. getScene(): Scene;
  52933. /** Gets the internal CubeTexture used to render to */
  52934. readonly cubeTexture: RenderTargetTexture;
  52935. /** Gets the list of meshes to render */
  52936. readonly renderList: Nullable<AbstractMesh[]>;
  52937. /**
  52938. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52939. * @param mesh defines the mesh to attach to
  52940. */
  52941. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52942. /**
  52943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52944. * @param renderingGroupId The rendering group id corresponding to its index
  52945. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52946. */
  52947. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52948. /**
  52949. * Clean all associated resources
  52950. */
  52951. dispose(): void;
  52952. /**
  52953. * Converts the reflection probe information to a readable string for debug purpose.
  52954. * @param fullDetails Supports for multiple levels of logging within scene loading
  52955. * @returns the human readable reflection probe info
  52956. */
  52957. toString(fullDetails?: boolean): string;
  52958. /**
  52959. * Get the class name of the relfection probe.
  52960. * @returns "ReflectionProbe"
  52961. */
  52962. getClassName(): string;
  52963. /**
  52964. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52965. * @returns The JSON representation of the texture
  52966. */
  52967. serialize(): any;
  52968. /**
  52969. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52970. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52971. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52972. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52973. * @returns The parsed reflection probe if successful
  52974. */
  52975. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52976. }
  52977. }
  52978. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52979. /** @hidden */
  52980. export var _BabylonLoaderRegistered: boolean;
  52981. }
  52982. declare module "babylonjs/Loading/Plugins/index" {
  52983. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52984. }
  52985. declare module "babylonjs/Loading/index" {
  52986. export * from "babylonjs/Loading/loadingScreen";
  52987. export * from "babylonjs/Loading/Plugins/index";
  52988. export * from "babylonjs/Loading/sceneLoader";
  52989. export * from "babylonjs/Loading/sceneLoaderFlags";
  52990. }
  52991. declare module "babylonjs/Materials/Background/index" {
  52992. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52993. }
  52994. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52995. import { Scene } from "babylonjs/scene";
  52996. import { Color3 } from "babylonjs/Maths/math.color";
  52997. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52999. /**
  53000. * The Physically based simple base material of BJS.
  53001. *
  53002. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53003. * It is used as the base class for both the specGloss and metalRough conventions.
  53004. */
  53005. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53006. /**
  53007. * Number of Simultaneous lights allowed on the material.
  53008. */
  53009. maxSimultaneousLights: number;
  53010. /**
  53011. * If sets to true, disables all the lights affecting the material.
  53012. */
  53013. disableLighting: boolean;
  53014. /**
  53015. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53016. */
  53017. environmentTexture: BaseTexture;
  53018. /**
  53019. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53020. */
  53021. invertNormalMapX: boolean;
  53022. /**
  53023. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53024. */
  53025. invertNormalMapY: boolean;
  53026. /**
  53027. * Normal map used in the model.
  53028. */
  53029. normalTexture: BaseTexture;
  53030. /**
  53031. * Emissivie color used to self-illuminate the model.
  53032. */
  53033. emissiveColor: Color3;
  53034. /**
  53035. * Emissivie texture used to self-illuminate the model.
  53036. */
  53037. emissiveTexture: BaseTexture;
  53038. /**
  53039. * Occlusion Channel Strenght.
  53040. */
  53041. occlusionStrength: number;
  53042. /**
  53043. * Occlusion Texture of the material (adding extra occlusion effects).
  53044. */
  53045. occlusionTexture: BaseTexture;
  53046. /**
  53047. * Defines the alpha limits in alpha test mode.
  53048. */
  53049. alphaCutOff: number;
  53050. /**
  53051. * Gets the current double sided mode.
  53052. */
  53053. /**
  53054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53055. */
  53056. doubleSided: boolean;
  53057. /**
  53058. * Stores the pre-calculated light information of a mesh in a texture.
  53059. */
  53060. lightmapTexture: BaseTexture;
  53061. /**
  53062. * If true, the light map contains occlusion information instead of lighting info.
  53063. */
  53064. useLightmapAsShadowmap: boolean;
  53065. /**
  53066. * Instantiates a new PBRMaterial instance.
  53067. *
  53068. * @param name The material name
  53069. * @param scene The scene the material will be use in.
  53070. */
  53071. constructor(name: string, scene: Scene);
  53072. getClassName(): string;
  53073. }
  53074. }
  53075. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53076. import { Scene } from "babylonjs/scene";
  53077. import { Color3 } from "babylonjs/Maths/math.color";
  53078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53079. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53080. /**
  53081. * The PBR material of BJS following the metal roughness convention.
  53082. *
  53083. * This fits to the PBR convention in the GLTF definition:
  53084. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53085. */
  53086. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53087. /**
  53088. * The base color has two different interpretations depending on the value of metalness.
  53089. * When the material is a metal, the base color is the specific measured reflectance value
  53090. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53091. * of the material.
  53092. */
  53093. baseColor: Color3;
  53094. /**
  53095. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53096. * well as opacity information in the alpha channel.
  53097. */
  53098. baseTexture: BaseTexture;
  53099. /**
  53100. * Specifies the metallic scalar value of the material.
  53101. * Can also be used to scale the metalness values of the metallic texture.
  53102. */
  53103. metallic: number;
  53104. /**
  53105. * Specifies the roughness scalar value of the material.
  53106. * Can also be used to scale the roughness values of the metallic texture.
  53107. */
  53108. roughness: number;
  53109. /**
  53110. * Texture containing both the metallic value in the B channel and the
  53111. * roughness value in the G channel to keep better precision.
  53112. */
  53113. metallicRoughnessTexture: BaseTexture;
  53114. /**
  53115. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53116. *
  53117. * @param name The material name
  53118. * @param scene The scene the material will be use in.
  53119. */
  53120. constructor(name: string, scene: Scene);
  53121. /**
  53122. * Return the currrent class name of the material.
  53123. */
  53124. getClassName(): string;
  53125. /**
  53126. * Makes a duplicate of the current material.
  53127. * @param name - name to use for the new material.
  53128. */
  53129. clone(name: string): PBRMetallicRoughnessMaterial;
  53130. /**
  53131. * Serialize the material to a parsable JSON object.
  53132. */
  53133. serialize(): any;
  53134. /**
  53135. * Parses a JSON object correponding to the serialize function.
  53136. */
  53137. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53138. }
  53139. }
  53140. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53141. import { Scene } from "babylonjs/scene";
  53142. import { Color3 } from "babylonjs/Maths/math.color";
  53143. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53144. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53145. /**
  53146. * The PBR material of BJS following the specular glossiness convention.
  53147. *
  53148. * This fits to the PBR convention in the GLTF definition:
  53149. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53150. */
  53151. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53152. /**
  53153. * Specifies the diffuse color of the material.
  53154. */
  53155. diffuseColor: Color3;
  53156. /**
  53157. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53158. * channel.
  53159. */
  53160. diffuseTexture: BaseTexture;
  53161. /**
  53162. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53163. */
  53164. specularColor: Color3;
  53165. /**
  53166. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53167. */
  53168. glossiness: number;
  53169. /**
  53170. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53171. */
  53172. specularGlossinessTexture: BaseTexture;
  53173. /**
  53174. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53175. *
  53176. * @param name The material name
  53177. * @param scene The scene the material will be use in.
  53178. */
  53179. constructor(name: string, scene: Scene);
  53180. /**
  53181. * Return the currrent class name of the material.
  53182. */
  53183. getClassName(): string;
  53184. /**
  53185. * Makes a duplicate of the current material.
  53186. * @param name - name to use for the new material.
  53187. */
  53188. clone(name: string): PBRSpecularGlossinessMaterial;
  53189. /**
  53190. * Serialize the material to a parsable JSON object.
  53191. */
  53192. serialize(): any;
  53193. /**
  53194. * Parses a JSON object correponding to the serialize function.
  53195. */
  53196. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53197. }
  53198. }
  53199. declare module "babylonjs/Materials/PBR/index" {
  53200. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53201. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53202. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53203. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53204. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53205. }
  53206. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53207. import { Nullable } from "babylonjs/types";
  53208. import { Scene } from "babylonjs/scene";
  53209. import { Matrix } from "babylonjs/Maths/math.vector";
  53210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53211. /**
  53212. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53213. * It can help converting any input color in a desired output one. This can then be used to create effects
  53214. * from sepia, black and white to sixties or futuristic rendering...
  53215. *
  53216. * The only supported format is currently 3dl.
  53217. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53218. */
  53219. export class ColorGradingTexture extends BaseTexture {
  53220. /**
  53221. * The current texture matrix. (will always be identity in color grading texture)
  53222. */
  53223. private _textureMatrix;
  53224. /**
  53225. * The texture URL.
  53226. */
  53227. url: string;
  53228. /**
  53229. * Empty line regex stored for GC.
  53230. */
  53231. private static _noneEmptyLineRegex;
  53232. private _engine;
  53233. /**
  53234. * Instantiates a ColorGradingTexture from the following parameters.
  53235. *
  53236. * @param url The location of the color gradind data (currently only supporting 3dl)
  53237. * @param scene The scene the texture will be used in
  53238. */
  53239. constructor(url: string, scene: Scene);
  53240. /**
  53241. * Returns the texture matrix used in most of the material.
  53242. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53243. */
  53244. getTextureMatrix(): Matrix;
  53245. /**
  53246. * Occurs when the file being loaded is a .3dl LUT file.
  53247. */
  53248. private load3dlTexture;
  53249. /**
  53250. * Starts the loading process of the texture.
  53251. */
  53252. private loadTexture;
  53253. /**
  53254. * Clones the color gradind texture.
  53255. */
  53256. clone(): ColorGradingTexture;
  53257. /**
  53258. * Called during delayed load for textures.
  53259. */
  53260. delayLoad(): void;
  53261. /**
  53262. * Parses a color grading texture serialized by Babylon.
  53263. * @param parsedTexture The texture information being parsedTexture
  53264. * @param scene The scene to load the texture in
  53265. * @param rootUrl The root url of the data assets to load
  53266. * @return A color gradind texture
  53267. */
  53268. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53269. /**
  53270. * Serializes the LUT texture to json format.
  53271. */
  53272. serialize(): any;
  53273. }
  53274. }
  53275. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53277. import { Scene } from "babylonjs/scene";
  53278. import { Nullable } from "babylonjs/types";
  53279. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53280. /**
  53281. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53282. */
  53283. export class EquiRectangularCubeTexture extends BaseTexture {
  53284. /** The six faces of the cube. */
  53285. private static _FacesMapping;
  53286. private _noMipmap;
  53287. private _onLoad;
  53288. private _onError;
  53289. /** The size of the cubemap. */
  53290. private _size;
  53291. /** The buffer of the image. */
  53292. private _buffer;
  53293. /** The width of the input image. */
  53294. private _width;
  53295. /** The height of the input image. */
  53296. private _height;
  53297. /** The URL to the image. */
  53298. url: string;
  53299. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53300. coordinatesMode: number;
  53301. /**
  53302. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53303. * @param url The location of the image
  53304. * @param scene The scene the texture will be used in
  53305. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53306. * @param noMipmap Forces to not generate the mipmap if true
  53307. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53308. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53309. * @param onLoad — defines a callback called when texture is loaded
  53310. * @param onError — defines a callback called if there is an error
  53311. */
  53312. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53313. /**
  53314. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53315. */
  53316. private loadImage;
  53317. /**
  53318. * Convert the image buffer into a cubemap and create a CubeTexture.
  53319. */
  53320. private loadTexture;
  53321. /**
  53322. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53323. * @param buffer The ArrayBuffer that should be converted.
  53324. * @returns The buffer as Float32Array.
  53325. */
  53326. private getFloat32ArrayFromArrayBuffer;
  53327. /**
  53328. * Get the current class name of the texture useful for serialization or dynamic coding.
  53329. * @returns "EquiRectangularCubeTexture"
  53330. */
  53331. getClassName(): string;
  53332. /**
  53333. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53334. * @returns A clone of the current EquiRectangularCubeTexture.
  53335. */
  53336. clone(): EquiRectangularCubeTexture;
  53337. }
  53338. }
  53339. declare module "babylonjs/Misc/tga" {
  53340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53341. /**
  53342. * Based on jsTGALoader - Javascript loader for TGA file
  53343. * By Vincent Thibault
  53344. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53345. */
  53346. export class TGATools {
  53347. private static _TYPE_INDEXED;
  53348. private static _TYPE_RGB;
  53349. private static _TYPE_GREY;
  53350. private static _TYPE_RLE_INDEXED;
  53351. private static _TYPE_RLE_RGB;
  53352. private static _TYPE_RLE_GREY;
  53353. private static _ORIGIN_MASK;
  53354. private static _ORIGIN_SHIFT;
  53355. private static _ORIGIN_BL;
  53356. private static _ORIGIN_BR;
  53357. private static _ORIGIN_UL;
  53358. private static _ORIGIN_UR;
  53359. /**
  53360. * Gets the header of a TGA file
  53361. * @param data defines the TGA data
  53362. * @returns the header
  53363. */
  53364. static GetTGAHeader(data: Uint8Array): any;
  53365. /**
  53366. * Uploads TGA content to a Babylon Texture
  53367. * @hidden
  53368. */
  53369. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53370. /** @hidden */
  53371. 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;
  53372. /** @hidden */
  53373. 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;
  53374. /** @hidden */
  53375. 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;
  53376. /** @hidden */
  53377. 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;
  53378. /** @hidden */
  53379. 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;
  53380. /** @hidden */
  53381. 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;
  53382. }
  53383. }
  53384. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53385. import { Nullable } from "babylonjs/types";
  53386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53387. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53388. /**
  53389. * Implementation of the TGA Texture Loader.
  53390. * @hidden
  53391. */
  53392. export class _TGATextureLoader implements IInternalTextureLoader {
  53393. /**
  53394. * Defines wether the loader supports cascade loading the different faces.
  53395. */
  53396. readonly supportCascades: boolean;
  53397. /**
  53398. * This returns if the loader support the current file information.
  53399. * @param extension defines the file extension of the file being loaded
  53400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53401. * @param fallback defines the fallback internal texture if any
  53402. * @param isBase64 defines whether the texture is encoded as a base64
  53403. * @param isBuffer defines whether the texture data are stored as a buffer
  53404. * @returns true if the loader can load the specified file
  53405. */
  53406. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53407. /**
  53408. * Transform the url before loading if required.
  53409. * @param rootUrl the url of the texture
  53410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53411. * @returns the transformed texture
  53412. */
  53413. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53414. /**
  53415. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53416. * @param rootUrl the url of the texture
  53417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53418. * @returns the fallback texture
  53419. */
  53420. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53421. /**
  53422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53423. * @param data contains the texture data
  53424. * @param texture defines the BabylonJS internal texture
  53425. * @param createPolynomials will be true if polynomials have been requested
  53426. * @param onLoad defines the callback to trigger once the texture is ready
  53427. * @param onError defines the callback to trigger in case of error
  53428. */
  53429. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53430. /**
  53431. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53432. * @param data contains the texture data
  53433. * @param texture defines the BabylonJS internal texture
  53434. * @param callback defines the method to call once ready to upload
  53435. */
  53436. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53437. }
  53438. }
  53439. declare module "babylonjs/Misc/basis" {
  53440. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53441. /**
  53442. * Info about the .basis files
  53443. */
  53444. class BasisFileInfo {
  53445. /**
  53446. * If the file has alpha
  53447. */
  53448. hasAlpha: boolean;
  53449. /**
  53450. * Info about each image of the basis file
  53451. */
  53452. images: Array<{
  53453. levels: Array<{
  53454. width: number;
  53455. height: number;
  53456. transcodedPixels: ArrayBufferView;
  53457. }>;
  53458. }>;
  53459. }
  53460. /**
  53461. * Result of transcoding a basis file
  53462. */
  53463. class TranscodeResult {
  53464. /**
  53465. * Info about the .basis file
  53466. */
  53467. fileInfo: BasisFileInfo;
  53468. /**
  53469. * Format to use when loading the file
  53470. */
  53471. format: number;
  53472. }
  53473. /**
  53474. * Configuration options for the Basis transcoder
  53475. */
  53476. export class BasisTranscodeConfiguration {
  53477. /**
  53478. * Supported compression formats used to determine the supported output format of the transcoder
  53479. */
  53480. supportedCompressionFormats?: {
  53481. /**
  53482. * etc1 compression format
  53483. */
  53484. etc1?: boolean;
  53485. /**
  53486. * s3tc compression format
  53487. */
  53488. s3tc?: boolean;
  53489. /**
  53490. * pvrtc compression format
  53491. */
  53492. pvrtc?: boolean;
  53493. /**
  53494. * etc2 compression format
  53495. */
  53496. etc2?: boolean;
  53497. };
  53498. /**
  53499. * If mipmap levels should be loaded for transcoded images (Default: true)
  53500. */
  53501. loadMipmapLevels?: boolean;
  53502. /**
  53503. * Index of a single image to load (Default: all images)
  53504. */
  53505. loadSingleImage?: number;
  53506. }
  53507. /**
  53508. * Used to load .Basis files
  53509. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53510. */
  53511. export class BasisTools {
  53512. private static _IgnoreSupportedFormats;
  53513. /**
  53514. * URL to use when loading the basis transcoder
  53515. */
  53516. static JSModuleURL: string;
  53517. /**
  53518. * URL to use when loading the wasm module for the transcoder
  53519. */
  53520. static WasmModuleURL: string;
  53521. /**
  53522. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53523. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53524. * @returns internal format corresponding to the Basis format
  53525. */
  53526. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53527. private static _WorkerPromise;
  53528. private static _Worker;
  53529. private static _actionId;
  53530. private static _CreateWorkerAsync;
  53531. /**
  53532. * Transcodes a loaded image file to compressed pixel data
  53533. * @param imageData image data to transcode
  53534. * @param config configuration options for the transcoding
  53535. * @returns a promise resulting in the transcoded image
  53536. */
  53537. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53538. /**
  53539. * Loads a texture from the transcode result
  53540. * @param texture texture load to
  53541. * @param transcodeResult the result of transcoding the basis file to load from
  53542. */
  53543. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53544. }
  53545. }
  53546. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53547. import { Nullable } from "babylonjs/types";
  53548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53549. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53550. /**
  53551. * Loader for .basis file format
  53552. */
  53553. export class _BasisTextureLoader implements IInternalTextureLoader {
  53554. /**
  53555. * Defines whether the loader supports cascade loading the different faces.
  53556. */
  53557. readonly supportCascades: boolean;
  53558. /**
  53559. * This returns if the loader support the current file information.
  53560. * @param extension defines the file extension of the file being loaded
  53561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53562. * @param fallback defines the fallback internal texture if any
  53563. * @param isBase64 defines whether the texture is encoded as a base64
  53564. * @param isBuffer defines whether the texture data are stored as a buffer
  53565. * @returns true if the loader can load the specified file
  53566. */
  53567. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53568. /**
  53569. * Transform the url before loading if required.
  53570. * @param rootUrl the url of the texture
  53571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53572. * @returns the transformed texture
  53573. */
  53574. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53575. /**
  53576. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53577. * @param rootUrl the url of the texture
  53578. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53579. * @returns the fallback texture
  53580. */
  53581. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53582. /**
  53583. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53584. * @param data contains the texture data
  53585. * @param texture defines the BabylonJS internal texture
  53586. * @param createPolynomials will be true if polynomials have been requested
  53587. * @param onLoad defines the callback to trigger once the texture is ready
  53588. * @param onError defines the callback to trigger in case of error
  53589. */
  53590. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53591. /**
  53592. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53593. * @param data contains the texture data
  53594. * @param texture defines the BabylonJS internal texture
  53595. * @param callback defines the method to call once ready to upload
  53596. */
  53597. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53598. }
  53599. }
  53600. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53601. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53602. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53603. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53604. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53605. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53606. }
  53607. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53608. import { Scene } from "babylonjs/scene";
  53609. import { Texture } from "babylonjs/Materials/Textures/texture";
  53610. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53611. /**
  53612. * 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.
  53613. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53614. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53615. */
  53616. export class CustomProceduralTexture extends ProceduralTexture {
  53617. private _animate;
  53618. private _time;
  53619. private _config;
  53620. private _texturePath;
  53621. /**
  53622. * Instantiates a new Custom Procedural Texture.
  53623. * 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.
  53624. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53626. * @param name Define the name of the texture
  53627. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53628. * @param size Define the size of the texture to create
  53629. * @param scene Define the scene the texture belongs to
  53630. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53631. * @param generateMipMaps Define if the texture should creates mip maps or not
  53632. */
  53633. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53634. private _loadJson;
  53635. /**
  53636. * Is the texture ready to be used ? (rendered at least once)
  53637. * @returns true if ready, otherwise, false.
  53638. */
  53639. isReady(): boolean;
  53640. /**
  53641. * Render the texture to its associated render target.
  53642. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53643. */
  53644. render(useCameraPostProcess?: boolean): void;
  53645. /**
  53646. * Update the list of dependant textures samplers in the shader.
  53647. */
  53648. updateTextures(): void;
  53649. /**
  53650. * Update the uniform values of the procedural texture in the shader.
  53651. */
  53652. updateShaderUniforms(): void;
  53653. /**
  53654. * Define if the texture animates or not.
  53655. */
  53656. animate: boolean;
  53657. }
  53658. }
  53659. declare module "babylonjs/Shaders/noise.fragment" {
  53660. /** @hidden */
  53661. export var noisePixelShader: {
  53662. name: string;
  53663. shader: string;
  53664. };
  53665. }
  53666. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53667. import { Nullable } from "babylonjs/types";
  53668. import { Scene } from "babylonjs/scene";
  53669. import { Texture } from "babylonjs/Materials/Textures/texture";
  53670. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53671. import "babylonjs/Shaders/noise.fragment";
  53672. /**
  53673. * Class used to generate noise procedural textures
  53674. */
  53675. export class NoiseProceduralTexture extends ProceduralTexture {
  53676. private _time;
  53677. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53678. brightness: number;
  53679. /** Defines the number of octaves to process */
  53680. octaves: number;
  53681. /** Defines the level of persistence (0.8 by default) */
  53682. persistence: number;
  53683. /** Gets or sets animation speed factor (default is 1) */
  53684. animationSpeedFactor: number;
  53685. /**
  53686. * Creates a new NoiseProceduralTexture
  53687. * @param name defines the name fo the texture
  53688. * @param size defines the size of the texture (default is 256)
  53689. * @param scene defines the hosting scene
  53690. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53691. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53692. */
  53693. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53694. private _updateShaderUniforms;
  53695. protected _getDefines(): string;
  53696. /** Generate the current state of the procedural texture */
  53697. render(useCameraPostProcess?: boolean): void;
  53698. /**
  53699. * Serializes this noise procedural texture
  53700. * @returns a serialized noise procedural texture object
  53701. */
  53702. serialize(): any;
  53703. /**
  53704. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53705. * @param parsedTexture defines parsed texture data
  53706. * @param scene defines the current scene
  53707. * @param rootUrl defines the root URL containing noise procedural texture information
  53708. * @returns a parsed NoiseProceduralTexture
  53709. */
  53710. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53711. }
  53712. }
  53713. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53714. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53715. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53716. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53717. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53718. }
  53719. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53720. import { Nullable } from "babylonjs/types";
  53721. import { Scene } from "babylonjs/scene";
  53722. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53723. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53724. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53725. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53726. /**
  53727. * Raw cube texture where the raw buffers are passed in
  53728. */
  53729. export class RawCubeTexture extends CubeTexture {
  53730. /**
  53731. * Creates a cube texture where the raw buffers are passed in.
  53732. * @param scene defines the scene the texture is attached to
  53733. * @param data defines the array of data to use to create each face
  53734. * @param size defines the size of the textures
  53735. * @param format defines the format of the data
  53736. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53737. * @param generateMipMaps defines if the engine should generate the mip levels
  53738. * @param invertY defines if data must be stored with Y axis inverted
  53739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53740. * @param compression defines the compression used (null by default)
  53741. */
  53742. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53743. /**
  53744. * Updates the raw cube texture.
  53745. * @param data defines the data to store
  53746. * @param format defines the data format
  53747. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53748. * @param invertY defines if data must be stored with Y axis inverted
  53749. * @param compression defines the compression used (null by default)
  53750. * @param level defines which level of the texture to update
  53751. */
  53752. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53753. /**
  53754. * Updates a raw cube texture with RGBD encoded data.
  53755. * @param data defines the array of data [mipmap][face] to use to create each face
  53756. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53757. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53758. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53759. * @returns a promsie that resolves when the operation is complete
  53760. */
  53761. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53762. /**
  53763. * Clones the raw cube texture.
  53764. * @return a new cube texture
  53765. */
  53766. clone(): CubeTexture;
  53767. /** @hidden */
  53768. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53769. }
  53770. }
  53771. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53772. import { Scene } from "babylonjs/scene";
  53773. import { Texture } from "babylonjs/Materials/Textures/texture";
  53774. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53775. /**
  53776. * Class used to store 3D textures containing user data
  53777. */
  53778. export class RawTexture3D extends Texture {
  53779. /** Gets or sets the texture format to use */
  53780. format: number;
  53781. private _engine;
  53782. /**
  53783. * Create a new RawTexture3D
  53784. * @param data defines the data of the texture
  53785. * @param width defines the width of the texture
  53786. * @param height defines the height of the texture
  53787. * @param depth defines the depth of the texture
  53788. * @param format defines the texture format to use
  53789. * @param scene defines the hosting scene
  53790. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53791. * @param invertY defines if texture must be stored with Y axis inverted
  53792. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53793. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53794. */
  53795. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53796. /** Gets or sets the texture format to use */
  53797. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53798. /**
  53799. * Update the texture with new data
  53800. * @param data defines the data to store in the texture
  53801. */
  53802. update(data: ArrayBufferView): void;
  53803. }
  53804. }
  53805. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53806. import { Scene } from "babylonjs/scene";
  53807. import { Plane } from "babylonjs/Maths/math.plane";
  53808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53809. /**
  53810. * Creates a refraction texture used by refraction channel of the standard material.
  53811. * It is like a mirror but to see through a material.
  53812. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53813. */
  53814. export class RefractionTexture extends RenderTargetTexture {
  53815. /**
  53816. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53817. * 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.
  53818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53819. */
  53820. refractionPlane: Plane;
  53821. /**
  53822. * Define how deep under the surface we should see.
  53823. */
  53824. depth: number;
  53825. /**
  53826. * Creates a refraction texture used by refraction channel of the standard material.
  53827. * It is like a mirror but to see through a material.
  53828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53829. * @param name Define the texture name
  53830. * @param size Define the size of the underlying texture
  53831. * @param scene Define the scene the refraction belongs to
  53832. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53833. */
  53834. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53835. /**
  53836. * Clone the refraction texture.
  53837. * @returns the cloned texture
  53838. */
  53839. clone(): RefractionTexture;
  53840. /**
  53841. * Serialize the texture to a JSON representation you could use in Parse later on
  53842. * @returns the serialized JSON representation
  53843. */
  53844. serialize(): any;
  53845. }
  53846. }
  53847. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53848. import { Nullable } from "babylonjs/types";
  53849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53850. import { Matrix } from "babylonjs/Maths/math.vector";
  53851. import { Engine } from "babylonjs/Engines/engine";
  53852. import { Scene } from "babylonjs/scene";
  53853. /**
  53854. * Defines the options related to the creation of an HtmlElementTexture
  53855. */
  53856. export interface IHtmlElementTextureOptions {
  53857. /**
  53858. * Defines wether mip maps should be created or not.
  53859. */
  53860. generateMipMaps?: boolean;
  53861. /**
  53862. * Defines the sampling mode of the texture.
  53863. */
  53864. samplingMode?: number;
  53865. /**
  53866. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53867. */
  53868. engine: Nullable<Engine>;
  53869. /**
  53870. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53871. */
  53872. scene: Nullable<Scene>;
  53873. }
  53874. /**
  53875. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53876. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53877. * is automatically managed.
  53878. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53879. * in your application.
  53880. *
  53881. * As the update is not automatic, you need to call them manually.
  53882. */
  53883. export class HtmlElementTexture extends BaseTexture {
  53884. /**
  53885. * The texture URL.
  53886. */
  53887. element: HTMLVideoElement | HTMLCanvasElement;
  53888. private static readonly DefaultOptions;
  53889. private _textureMatrix;
  53890. private _engine;
  53891. private _isVideo;
  53892. private _generateMipMaps;
  53893. private _samplingMode;
  53894. /**
  53895. * Instantiates a HtmlElementTexture from the following parameters.
  53896. *
  53897. * @param name Defines the name of the texture
  53898. * @param element Defines the video or canvas the texture is filled with
  53899. * @param options Defines the other none mandatory texture creation options
  53900. */
  53901. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53902. private _createInternalTexture;
  53903. /**
  53904. * Returns the texture matrix used in most of the material.
  53905. */
  53906. getTextureMatrix(): Matrix;
  53907. /**
  53908. * Updates the content of the texture.
  53909. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53910. */
  53911. update(invertY?: Nullable<boolean>): void;
  53912. }
  53913. }
  53914. declare module "babylonjs/Materials/Textures/index" {
  53915. export * from "babylonjs/Materials/Textures/baseTexture";
  53916. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53917. export * from "babylonjs/Materials/Textures/cubeTexture";
  53918. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53919. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53920. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53921. export * from "babylonjs/Materials/Textures/internalTexture";
  53922. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53923. export * from "babylonjs/Materials/Textures/Loaders/index";
  53924. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53925. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53926. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53927. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53928. export * from "babylonjs/Materials/Textures/rawTexture";
  53929. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53930. export * from "babylonjs/Materials/Textures/refractionTexture";
  53931. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53932. export * from "babylonjs/Materials/Textures/texture";
  53933. export * from "babylonjs/Materials/Textures/videoTexture";
  53934. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53935. }
  53936. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53937. /**
  53938. * Enum used to define the target of a block
  53939. */
  53940. export enum NodeMaterialBlockTargets {
  53941. /** Vertex shader */
  53942. Vertex = 1,
  53943. /** Fragment shader */
  53944. Fragment = 2,
  53945. /** Neutral */
  53946. Neutral = 4,
  53947. /** Vertex and Fragment */
  53948. VertexAndFragment = 3
  53949. }
  53950. }
  53951. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53952. /**
  53953. * Defines the kind of connection point for node based material
  53954. */
  53955. export enum NodeMaterialBlockConnectionPointTypes {
  53956. /** Float */
  53957. Float = 1,
  53958. /** Int */
  53959. Int = 2,
  53960. /** Vector2 */
  53961. Vector2 = 4,
  53962. /** Vector3 */
  53963. Vector3 = 8,
  53964. /** Vector4 */
  53965. Vector4 = 16,
  53966. /** Color3 */
  53967. Color3 = 32,
  53968. /** Color4 */
  53969. Color4 = 64,
  53970. /** Matrix */
  53971. Matrix = 128,
  53972. /** Detect type based on connection */
  53973. AutoDetect = 1024,
  53974. /** Output type that will be defined by input type */
  53975. BasedOnInput = 2048
  53976. }
  53977. }
  53978. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53980. /**
  53981. * Root class for all node material optimizers
  53982. */
  53983. export class NodeMaterialOptimizer {
  53984. /**
  53985. * Function used to optimize a NodeMaterial graph
  53986. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53987. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53988. */
  53989. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53990. }
  53991. }
  53992. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53995. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53996. import { Scene } from "babylonjs/scene";
  53997. /**
  53998. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53999. */
  54000. export class TransformBlock extends NodeMaterialBlock {
  54001. /**
  54002. * Defines the value to use to complement W value to transform it to a Vector4
  54003. */
  54004. complementW: number;
  54005. /**
  54006. * Defines the value to use to complement z value to transform it to a Vector4
  54007. */
  54008. complementZ: number;
  54009. /**
  54010. * Creates a new TransformBlock
  54011. * @param name defines the block name
  54012. */
  54013. constructor(name: string);
  54014. /**
  54015. * Gets the current class name
  54016. * @returns the class name
  54017. */
  54018. getClassName(): string;
  54019. /**
  54020. * Gets the vector input
  54021. */
  54022. readonly vector: NodeMaterialConnectionPoint;
  54023. /**
  54024. * Gets the output component
  54025. */
  54026. readonly output: NodeMaterialConnectionPoint;
  54027. /**
  54028. * Gets the matrix transform input
  54029. */
  54030. readonly transform: NodeMaterialConnectionPoint;
  54031. protected _buildBlock(state: NodeMaterialBuildState): this;
  54032. serialize(): any;
  54033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54034. }
  54035. }
  54036. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54040. /**
  54041. * Block used to output the vertex position
  54042. */
  54043. export class VertexOutputBlock extends NodeMaterialBlock {
  54044. /**
  54045. * Creates a new VertexOutputBlock
  54046. * @param name defines the block name
  54047. */
  54048. constructor(name: string);
  54049. /**
  54050. * Gets the current class name
  54051. * @returns the class name
  54052. */
  54053. getClassName(): string;
  54054. /**
  54055. * Gets the vector input component
  54056. */
  54057. readonly vector: NodeMaterialConnectionPoint;
  54058. protected _buildBlock(state: NodeMaterialBuildState): this;
  54059. }
  54060. }
  54061. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54065. /**
  54066. * Block used to output the final color
  54067. */
  54068. export class FragmentOutputBlock extends NodeMaterialBlock {
  54069. /**
  54070. * Create a new FragmentOutputBlock
  54071. * @param name defines the block name
  54072. */
  54073. constructor(name: string);
  54074. /**
  54075. * Gets the current class name
  54076. * @returns the class name
  54077. */
  54078. getClassName(): string;
  54079. /**
  54080. * Gets the rgba input component
  54081. */
  54082. readonly rgba: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Gets the rgb input component
  54085. */
  54086. readonly rgb: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the a input component
  54089. */
  54090. readonly a: NodeMaterialConnectionPoint;
  54091. protected _buildBlock(state: NodeMaterialBuildState): this;
  54092. }
  54093. }
  54094. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54096. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54097. import { Scene } from "babylonjs/scene";
  54098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54099. import { Matrix } from "babylonjs/Maths/math.vector";
  54100. import { Mesh } from "babylonjs/Meshes/mesh";
  54101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54102. import { Observable } from "babylonjs/Misc/observable";
  54103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54104. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54105. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54106. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54107. import { Nullable } from "babylonjs/types";
  54108. /**
  54109. * Interface used to configure the node material editor
  54110. */
  54111. export interface INodeMaterialEditorOptions {
  54112. /** Define the URl to load node editor script */
  54113. editorURL?: string;
  54114. }
  54115. /** @hidden */
  54116. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54117. /** BONES */
  54118. NUM_BONE_INFLUENCERS: number;
  54119. BonesPerMesh: number;
  54120. BONETEXTURE: boolean;
  54121. /** MORPH TARGETS */
  54122. MORPHTARGETS: boolean;
  54123. MORPHTARGETS_NORMAL: boolean;
  54124. MORPHTARGETS_TANGENT: boolean;
  54125. MORPHTARGETS_UV: boolean;
  54126. NUM_MORPH_INFLUENCERS: number;
  54127. /** IMAGE PROCESSING */
  54128. IMAGEPROCESSING: boolean;
  54129. VIGNETTE: boolean;
  54130. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54131. VIGNETTEBLENDMODEOPAQUE: boolean;
  54132. TONEMAPPING: boolean;
  54133. TONEMAPPING_ACES: boolean;
  54134. CONTRAST: boolean;
  54135. EXPOSURE: boolean;
  54136. COLORCURVES: boolean;
  54137. COLORGRADING: boolean;
  54138. COLORGRADING3D: boolean;
  54139. SAMPLER3DGREENDEPTH: boolean;
  54140. SAMPLER3DBGRMAP: boolean;
  54141. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54142. constructor();
  54143. setValue(name: string, value: boolean): void;
  54144. }
  54145. /**
  54146. * Class used to configure NodeMaterial
  54147. */
  54148. export interface INodeMaterialOptions {
  54149. /**
  54150. * Defines if blocks should emit comments
  54151. */
  54152. emitComments: boolean;
  54153. }
  54154. /**
  54155. * Class used to create a node based material built by assembling shader blocks
  54156. */
  54157. export class NodeMaterial extends PushMaterial {
  54158. private static _BuildIdGenerator;
  54159. private _options;
  54160. private _vertexCompilationState;
  54161. private _fragmentCompilationState;
  54162. private _sharedData;
  54163. private _buildId;
  54164. private _buildWasSuccessful;
  54165. private _cachedWorldViewMatrix;
  54166. private _cachedWorldViewProjectionMatrix;
  54167. private _optimizers;
  54168. private _animationFrame;
  54169. /** Define the URl to load node editor script */
  54170. static EditorURL: string;
  54171. private BJSNODEMATERIALEDITOR;
  54172. /** Get the inspector from bundle or global */
  54173. private _getGlobalNodeMaterialEditor;
  54174. /**
  54175. * 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)
  54176. */
  54177. ignoreAlpha: boolean;
  54178. /**
  54179. * Defines the maximum number of lights that can be used in the material
  54180. */
  54181. maxSimultaneousLights: number;
  54182. /**
  54183. * Observable raised when the material is built
  54184. */
  54185. onBuildObservable: Observable<NodeMaterial>;
  54186. /**
  54187. * Gets or sets the root nodes of the material vertex shader
  54188. */
  54189. _vertexOutputNodes: NodeMaterialBlock[];
  54190. /**
  54191. * Gets or sets the root nodes of the material fragment (pixel) shader
  54192. */
  54193. _fragmentOutputNodes: NodeMaterialBlock[];
  54194. /** Gets or sets options to control the node material overall behavior */
  54195. options: INodeMaterialOptions;
  54196. /**
  54197. * Default configuration related to image processing available in the standard Material.
  54198. */
  54199. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54200. /**
  54201. * Gets the image processing configuration used either in this material.
  54202. */
  54203. /**
  54204. * Sets the Default image processing configuration used either in the this material.
  54205. *
  54206. * If sets to null, the scene one is in use.
  54207. */
  54208. imageProcessingConfiguration: ImageProcessingConfiguration;
  54209. /**
  54210. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54211. */
  54212. attachedBlocks: NodeMaterialBlock[];
  54213. /**
  54214. * Create a new node based material
  54215. * @param name defines the material name
  54216. * @param scene defines the hosting scene
  54217. * @param options defines creation option
  54218. */
  54219. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54220. /**
  54221. * Gets the current class name of the material e.g. "NodeMaterial"
  54222. * @returns the class name
  54223. */
  54224. getClassName(): string;
  54225. /**
  54226. * Keep track of the image processing observer to allow dispose and replace.
  54227. */
  54228. private _imageProcessingObserver;
  54229. /**
  54230. * Attaches a new image processing configuration to the Standard Material.
  54231. * @param configuration
  54232. */
  54233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54234. /**
  54235. * Adds a new optimizer to the list of optimizers
  54236. * @param optimizer defines the optimizers to add
  54237. * @returns the current material
  54238. */
  54239. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54240. /**
  54241. * Remove an optimizer from the list of optimizers
  54242. * @param optimizer defines the optimizers to remove
  54243. * @returns the current material
  54244. */
  54245. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54246. /**
  54247. * Add a new block to the list of output nodes
  54248. * @param node defines the node to add
  54249. * @returns the current material
  54250. */
  54251. addOutputNode(node: NodeMaterialBlock): this;
  54252. /**
  54253. * Remove a block from the list of root nodes
  54254. * @param node defines the node to remove
  54255. * @returns the current material
  54256. */
  54257. removeOutputNode(node: NodeMaterialBlock): this;
  54258. private _addVertexOutputNode;
  54259. private _removeVertexOutputNode;
  54260. private _addFragmentOutputNode;
  54261. private _removeFragmentOutputNode;
  54262. /**
  54263. * Specifies if the material will require alpha blending
  54264. * @returns a boolean specifying if alpha blending is needed
  54265. */
  54266. needAlphaBlending(): boolean;
  54267. /**
  54268. * Specifies if this material should be rendered in alpha test mode
  54269. * @returns a boolean specifying if an alpha test is needed.
  54270. */
  54271. needAlphaTesting(): boolean;
  54272. private _initializeBlock;
  54273. private _resetDualBlocks;
  54274. /**
  54275. * Build the material and generates the inner effect
  54276. * @param verbose defines if the build should log activity
  54277. */
  54278. build(verbose?: boolean): void;
  54279. /**
  54280. * Runs an otpimization phase to try to improve the shader code
  54281. */
  54282. optimize(): void;
  54283. private _prepareDefinesForAttributes;
  54284. /**
  54285. * Get if the submesh is ready to be used and all its information available.
  54286. * Child classes can use it to update shaders
  54287. * @param mesh defines the mesh to check
  54288. * @param subMesh defines which submesh to check
  54289. * @param useInstances specifies that instances should be used
  54290. * @returns a boolean indicating that the submesh is ready or not
  54291. */
  54292. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54293. /**
  54294. * Get a string representing the shaders built by the current node graph
  54295. */
  54296. readonly compiledShaders: string;
  54297. /**
  54298. * Binds the world matrix to the material
  54299. * @param world defines the world transformation matrix
  54300. */
  54301. bindOnlyWorldMatrix(world: Matrix): void;
  54302. /**
  54303. * Binds the submesh to this material by preparing the effect and shader to draw
  54304. * @param world defines the world transformation matrix
  54305. * @param mesh defines the mesh containing the submesh
  54306. * @param subMesh defines the submesh to bind the material to
  54307. */
  54308. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54309. /**
  54310. * Gets the active textures from the material
  54311. * @returns an array of textures
  54312. */
  54313. getActiveTextures(): BaseTexture[];
  54314. /**
  54315. * Specifies if the material uses a texture
  54316. * @param texture defines the texture to check against the material
  54317. * @returns a boolean specifying if the material uses the texture
  54318. */
  54319. hasTexture(texture: BaseTexture): boolean;
  54320. /**
  54321. * Disposes the material
  54322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54324. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54325. */
  54326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54327. /** Creates the node editor window. */
  54328. private _createNodeEditor;
  54329. /**
  54330. * Launch the node material editor
  54331. * @param config Define the configuration of the editor
  54332. * @return a promise fulfilled when the node editor is visible
  54333. */
  54334. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54335. /**
  54336. * Clear the current material
  54337. */
  54338. clear(): void;
  54339. /**
  54340. * Clear the current material and set it to a default state
  54341. */
  54342. setToDefault(): void;
  54343. private _gatherBlocks;
  54344. /**
  54345. * Serializes this material in a JSON representation
  54346. * @returns the serialized material object
  54347. */
  54348. serialize(): any;
  54349. /**
  54350. * Clear the current graph and load a new one from a serialization object
  54351. * @param source defines the JSON representation of the material
  54352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54353. */
  54354. loadFromSerialization(source: any, rootUrl?: string): void;
  54355. /**
  54356. * Creates a node material from parsed material data
  54357. * @param source defines the JSON representation of the material
  54358. * @param scene defines the hosting scene
  54359. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54360. * @returns a new node material
  54361. */
  54362. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54363. }
  54364. }
  54365. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54371. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54372. import { Effect } from "babylonjs/Materials/effect";
  54373. import { Mesh } from "babylonjs/Meshes/mesh";
  54374. import { Nullable } from "babylonjs/types";
  54375. import { Scene } from "babylonjs/scene";
  54376. /**
  54377. * Block used to read a texture from a sampler
  54378. */
  54379. export class TextureBlock extends NodeMaterialBlock {
  54380. private _defineName;
  54381. private _samplerName;
  54382. private _transformedUVName;
  54383. private _textureTransformName;
  54384. private _textureInfoName;
  54385. private _mainUVName;
  54386. private _mainUVDefineName;
  54387. /**
  54388. * Gets or sets the texture associated with the node
  54389. */
  54390. texture: Nullable<BaseTexture>;
  54391. /**
  54392. * Create a new TextureBlock
  54393. * @param name defines the block name
  54394. */
  54395. constructor(name: string);
  54396. /**
  54397. * Gets the current class name
  54398. * @returns the class name
  54399. */
  54400. getClassName(): string;
  54401. /**
  54402. * Gets the uv input component
  54403. */
  54404. readonly uv: NodeMaterialConnectionPoint;
  54405. /**
  54406. * Gets the rgba output component
  54407. */
  54408. readonly rgba: NodeMaterialConnectionPoint;
  54409. /**
  54410. * Gets the rgb output component
  54411. */
  54412. readonly rgb: NodeMaterialConnectionPoint;
  54413. /**
  54414. * Gets the r output component
  54415. */
  54416. readonly r: NodeMaterialConnectionPoint;
  54417. /**
  54418. * Gets the g output component
  54419. */
  54420. readonly g: NodeMaterialConnectionPoint;
  54421. /**
  54422. * Gets the b output component
  54423. */
  54424. readonly b: NodeMaterialConnectionPoint;
  54425. /**
  54426. * Gets the a output component
  54427. */
  54428. readonly a: NodeMaterialConnectionPoint;
  54429. autoConfigure(): void;
  54430. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54432. isReady(): boolean;
  54433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54434. private _injectVertexCode;
  54435. private _writeOutput;
  54436. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54437. serialize(): any;
  54438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54439. }
  54440. }
  54441. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54442. /**
  54443. * Enum used to define well known values e.g. values automatically provided by the system
  54444. */
  54445. export enum NodeMaterialWellKnownValues {
  54446. /** World */
  54447. World = 1,
  54448. /** View */
  54449. View = 2,
  54450. /** Projection */
  54451. Projection = 3,
  54452. /** ViewProjection */
  54453. ViewProjection = 4,
  54454. /** WorldView */
  54455. WorldView = 5,
  54456. /** WorldViewProjection */
  54457. WorldViewProjection = 6,
  54458. /** CameraPosition */
  54459. CameraPosition = 7,
  54460. /** Fog Color */
  54461. FogColor = 8
  54462. }
  54463. }
  54464. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54470. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54471. import { Effect } from "babylonjs/Materials/effect";
  54472. import { Mesh } from "babylonjs/Meshes/mesh";
  54473. import { Nullable } from "babylonjs/types";
  54474. import { Scene } from "babylonjs/scene";
  54475. /**
  54476. * Block used to read a reflection texture from a sampler
  54477. */
  54478. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54479. private _define3DName;
  54480. private _defineCubicName;
  54481. private _defineExplicitName;
  54482. private _defineProjectionName;
  54483. private _defineLocalCubicName;
  54484. private _defineSphericalName;
  54485. private _definePlanarName;
  54486. private _defineEquirectangularName;
  54487. private _defineMirroredEquirectangularFixedName;
  54488. private _defineEquirectangularFixedName;
  54489. private _defineSkyboxName;
  54490. private _cubeSamplerName;
  54491. private _2DSamplerName;
  54492. private _positionUVWName;
  54493. private _directionWName;
  54494. private _reflectionCoordsName;
  54495. private _reflection2DCoordsName;
  54496. private _reflectionColorName;
  54497. private _reflectionMatrixName;
  54498. /**
  54499. * Gets or sets the texture associated with the node
  54500. */
  54501. texture: Nullable<BaseTexture>;
  54502. /**
  54503. * Create a new TextureBlock
  54504. * @param name defines the block name
  54505. */
  54506. constructor(name: string);
  54507. /**
  54508. * Gets the current class name
  54509. * @returns the class name
  54510. */
  54511. getClassName(): string;
  54512. /**
  54513. * Gets the world position input component
  54514. */
  54515. readonly position: NodeMaterialConnectionPoint;
  54516. /**
  54517. * Gets the world position input component
  54518. */
  54519. readonly worldPosition: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the world normal input component
  54522. */
  54523. readonly worldNormal: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the world input component
  54526. */
  54527. readonly world: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the camera (or eye) position component
  54530. */
  54531. readonly cameraPosition: NodeMaterialConnectionPoint;
  54532. /**
  54533. * Gets the view input component
  54534. */
  54535. readonly view: NodeMaterialConnectionPoint;
  54536. /**
  54537. * Gets the rgb output component
  54538. */
  54539. readonly rgb: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Gets the r output component
  54542. */
  54543. readonly r: NodeMaterialConnectionPoint;
  54544. /**
  54545. * Gets the g output component
  54546. */
  54547. readonly g: NodeMaterialConnectionPoint;
  54548. /**
  54549. * Gets the b output component
  54550. */
  54551. readonly b: NodeMaterialConnectionPoint;
  54552. autoConfigure(): void;
  54553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54554. isReady(): boolean;
  54555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54556. private _injectVertexCode;
  54557. private _writeOutput;
  54558. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54559. serialize(): any;
  54560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54561. }
  54562. }
  54563. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54566. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54567. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54568. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54569. /**
  54570. * Class used to store shared data between 2 NodeMaterialBuildState
  54571. */
  54572. export class NodeMaterialBuildStateSharedData {
  54573. /**
  54574. * Gets the list of emitted varyings
  54575. */
  54576. varyings: string[];
  54577. /**
  54578. * Gets the varying declaration string
  54579. */
  54580. varyingDeclaration: string;
  54581. /**
  54582. * Input blocks
  54583. */
  54584. inputBlocks: InputBlock[];
  54585. /**
  54586. * Input blocks
  54587. */
  54588. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  54589. /**
  54590. * Bindable blocks (Blocks that need to set data to the effect)
  54591. */
  54592. bindableBlocks: NodeMaterialBlock[];
  54593. /**
  54594. * List of blocks that can provide a compilation fallback
  54595. */
  54596. blocksWithFallbacks: NodeMaterialBlock[];
  54597. /**
  54598. * List of blocks that can provide a define update
  54599. */
  54600. blocksWithDefines: NodeMaterialBlock[];
  54601. /**
  54602. * List of blocks that can provide a repeatable content
  54603. */
  54604. repeatableContentBlocks: NodeMaterialBlock[];
  54605. /**
  54606. * List of blocks that can provide a dynamic list of uniforms
  54607. */
  54608. dynamicUniformBlocks: NodeMaterialBlock[];
  54609. /**
  54610. * List of blocks that can block the isReady function for the material
  54611. */
  54612. blockingBlocks: NodeMaterialBlock[];
  54613. /**
  54614. * Gets the list of animated inputs
  54615. */
  54616. animatedInputs: InputBlock[];
  54617. /**
  54618. * Build Id used to avoid multiple recompilations
  54619. */
  54620. buildId: number;
  54621. /** List of emitted variables */
  54622. variableNames: {
  54623. [key: string]: number;
  54624. };
  54625. /** List of emitted defines */
  54626. defineNames: {
  54627. [key: string]: number;
  54628. };
  54629. /** Should emit comments? */
  54630. emitComments: boolean;
  54631. /** Emit build activity */
  54632. verbose: boolean;
  54633. /**
  54634. * Gets the compilation hints emitted at compilation time
  54635. */
  54636. hints: {
  54637. needWorldViewMatrix: boolean;
  54638. needWorldViewProjectionMatrix: boolean;
  54639. needAlphaBlending: boolean;
  54640. needAlphaTesting: boolean;
  54641. };
  54642. /**
  54643. * List of compilation checks
  54644. */
  54645. checks: {
  54646. emitVertex: boolean;
  54647. emitFragment: boolean;
  54648. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54649. };
  54650. /** Creates a new shared data */
  54651. constructor();
  54652. /**
  54653. * Emits console errors and exceptions if there is a failing check
  54654. */
  54655. emitErrors(): void;
  54656. }
  54657. }
  54658. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54659. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54660. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54661. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54662. /**
  54663. * Class used to store node based material build state
  54664. */
  54665. export class NodeMaterialBuildState {
  54666. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54667. supportUniformBuffers: boolean;
  54668. /**
  54669. * Gets the list of emitted attributes
  54670. */
  54671. attributes: string[];
  54672. /**
  54673. * Gets the list of emitted uniforms
  54674. */
  54675. uniforms: string[];
  54676. /**
  54677. * Gets the list of emitted uniform buffers
  54678. */
  54679. uniformBuffers: string[];
  54680. /**
  54681. * Gets the list of emitted samplers
  54682. */
  54683. samplers: string[];
  54684. /**
  54685. * Gets the list of emitted functions
  54686. */
  54687. functions: {
  54688. [key: string]: string;
  54689. };
  54690. /**
  54691. * Gets the target of the compilation state
  54692. */
  54693. target: NodeMaterialBlockTargets;
  54694. /**
  54695. * Gets the list of emitted counters
  54696. */
  54697. counters: {
  54698. [key: string]: number;
  54699. };
  54700. /**
  54701. * Shared data between multiple NodeMaterialBuildState instances
  54702. */
  54703. sharedData: NodeMaterialBuildStateSharedData;
  54704. /** @hidden */
  54705. _vertexState: NodeMaterialBuildState;
  54706. /** @hidden */
  54707. _attributeDeclaration: string;
  54708. /** @hidden */
  54709. _uniformDeclaration: string;
  54710. /** @hidden */
  54711. _samplerDeclaration: string;
  54712. /** @hidden */
  54713. _varyingTransfer: string;
  54714. private _repeatableContentAnchorIndex;
  54715. /** @hidden */
  54716. _builtCompilationString: string;
  54717. /**
  54718. * Gets the emitted compilation strings
  54719. */
  54720. compilationString: string;
  54721. /**
  54722. * Finalize the compilation strings
  54723. * @param state defines the current compilation state
  54724. */
  54725. finalize(state: NodeMaterialBuildState): void;
  54726. /** @hidden */
  54727. readonly _repeatableContentAnchor: string;
  54728. /** @hidden */
  54729. _getFreeVariableName(prefix: string): string;
  54730. /** @hidden */
  54731. _getFreeDefineName(prefix: string): string;
  54732. /** @hidden */
  54733. _excludeVariableName(name: string): void;
  54734. /** @hidden */
  54735. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54736. /** @hidden */
  54737. _emitFunction(name: string, code: string, comments: string): void;
  54738. /** @hidden */
  54739. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54740. replaceStrings?: {
  54741. search: RegExp;
  54742. replace: string;
  54743. }[];
  54744. repeatKey?: string;
  54745. }): string;
  54746. /** @hidden */
  54747. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54748. repeatKey?: string;
  54749. removeAttributes?: boolean;
  54750. removeUniforms?: boolean;
  54751. removeVaryings?: boolean;
  54752. removeIfDef?: boolean;
  54753. replaceStrings?: {
  54754. search: RegExp;
  54755. replace: string;
  54756. }[];
  54757. }, storeKey?: string): void;
  54758. /** @hidden */
  54759. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54760. /** @hidden */
  54761. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54762. }
  54763. }
  54764. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54765. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54767. import { Nullable } from "babylonjs/types";
  54768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54769. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54770. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54772. import { Mesh } from "babylonjs/Meshes/mesh";
  54773. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54774. import { Scene } from "babylonjs/scene";
  54775. /**
  54776. * Defines a block that can be used inside a node based material
  54777. */
  54778. export class NodeMaterialBlock {
  54779. private _buildId;
  54780. private _buildTarget;
  54781. private _target;
  54782. private _isFinalMerger;
  54783. private _isInput;
  54784. /** @hidden */
  54785. _inputs: NodeMaterialConnectionPoint[];
  54786. /** @hidden */
  54787. _outputs: NodeMaterialConnectionPoint[];
  54788. /**
  54789. * Gets or sets the name of the block
  54790. */
  54791. name: string;
  54792. /**
  54793. * Gets or sets the unique id of the node
  54794. */
  54795. uniqueId: number;
  54796. /**
  54797. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54798. */
  54799. readonly isFinalMerger: boolean;
  54800. /**
  54801. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54802. */
  54803. readonly isInput: boolean;
  54804. /**
  54805. * Gets or sets the build Id
  54806. */
  54807. buildId: number;
  54808. /**
  54809. * Gets or sets the target of the block
  54810. */
  54811. target: NodeMaterialBlockTargets;
  54812. /**
  54813. * Gets the list of input points
  54814. */
  54815. readonly inputs: NodeMaterialConnectionPoint[];
  54816. /** Gets the list of output points */
  54817. readonly outputs: NodeMaterialConnectionPoint[];
  54818. /**
  54819. * Find an input by its name
  54820. * @param name defines the name of the input to look for
  54821. * @returns the input or null if not found
  54822. */
  54823. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54824. /**
  54825. * Find an output by its name
  54826. * @param name defines the name of the outputto look for
  54827. * @returns the output or null if not found
  54828. */
  54829. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54830. /**
  54831. * Creates a new NodeMaterialBlock
  54832. * @param name defines the block name
  54833. * @param target defines the target of that block (Vertex by default)
  54834. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54835. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54836. */
  54837. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54838. /**
  54839. * Initialize the block and prepare the context for build
  54840. * @param state defines the state that will be used for the build
  54841. */
  54842. initialize(state: NodeMaterialBuildState): void;
  54843. /**
  54844. * Bind data to effect. Will only be called for blocks with isBindable === true
  54845. * @param effect defines the effect to bind data to
  54846. * @param nodeMaterial defines the hosting NodeMaterial
  54847. * @param mesh defines the mesh that will be rendered
  54848. */
  54849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54850. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54851. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54852. protected _writeFloat(value: number): string;
  54853. /**
  54854. * Gets the current class name e.g. "NodeMaterialBlock"
  54855. * @returns the class name
  54856. */
  54857. getClassName(): string;
  54858. /**
  54859. * Register a new input. Must be called inside a block constructor
  54860. * @param name defines the connection point name
  54861. * @param type defines the connection point type
  54862. * @param isOptional defines a boolean indicating that this input can be omitted
  54863. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54864. * @returns the current block
  54865. */
  54866. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54867. /**
  54868. * Register a new output. Must be called inside a block constructor
  54869. * @param name defines the connection point name
  54870. * @param type defines the connection point type
  54871. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54872. * @returns the current block
  54873. */
  54874. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54875. /**
  54876. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54877. * @param forOutput defines an optional connection point to check compatibility with
  54878. * @returns the first available input or null
  54879. */
  54880. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54881. /**
  54882. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54883. * @param forBlock defines an optional block to check compatibility with
  54884. * @returns the first available input or null
  54885. */
  54886. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54887. /**
  54888. * Gets the sibling of the given output
  54889. * @param current defines the current output
  54890. * @returns the next output in the list or null
  54891. */
  54892. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54893. /**
  54894. * Connect current block with another block
  54895. * @param other defines the block to connect with
  54896. * @param options define the various options to help pick the right connections
  54897. * @returns the current block
  54898. */
  54899. connectTo(other: NodeMaterialBlock, options?: {
  54900. input?: string;
  54901. output?: string;
  54902. outputSwizzle?: string;
  54903. }): this | undefined;
  54904. protected _buildBlock(state: NodeMaterialBuildState): void;
  54905. /**
  54906. * Add uniforms, samplers and uniform buffers at compilation time
  54907. * @param state defines the state to update
  54908. * @param nodeMaterial defines the node material requesting the update
  54909. * @param defines defines the material defines to update
  54910. */
  54911. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54912. /**
  54913. * Add potential fallbacks if shader compilation fails
  54914. * @param mesh defines the mesh to be rendered
  54915. * @param fallbacks defines the current prioritized list of fallbacks
  54916. */
  54917. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54918. /**
  54919. * Update defines for shader compilation
  54920. * @param mesh defines the mesh to be rendered
  54921. * @param nodeMaterial defines the node material requesting the update
  54922. * @param defines defines the material defines to update
  54923. * @param useInstances specifies that instances should be used
  54924. */
  54925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54926. /**
  54927. * Initialize defines for shader compilation
  54928. * @param mesh defines the mesh to be rendered
  54929. * @param nodeMaterial defines the node material requesting the update
  54930. * @param defines defines the material defines to be prepared
  54931. * @param useInstances specifies that instances should be used
  54932. */
  54933. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54934. /**
  54935. * Lets the block try to connect some inputs automatically
  54936. */
  54937. autoConfigure(): void;
  54938. /**
  54939. * Function called when a block is declared as repeatable content generator
  54940. * @param vertexShaderState defines the current compilation state for the vertex shader
  54941. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54942. * @param mesh defines the mesh to be rendered
  54943. * @param defines defines the material defines to update
  54944. */
  54945. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54946. /**
  54947. * Checks if the block is ready
  54948. * @param mesh defines the mesh to be rendered
  54949. * @param nodeMaterial defines the node material requesting the update
  54950. * @param defines defines the material defines to update
  54951. * @param useInstances specifies that instances should be used
  54952. * @returns true if the block is ready
  54953. */
  54954. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54955. private _processBuild;
  54956. /**
  54957. * Compile the current node and generate the shader code
  54958. * @param state defines the current compilation state (uniforms, samplers, current string)
  54959. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54960. * @returns true if already built
  54961. */
  54962. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54963. /**
  54964. * Clone the current block to a new identical block
  54965. * @param scene defines the hosting scene
  54966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54967. * @returns a copy of the current block
  54968. */
  54969. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54970. /**
  54971. * Serializes this block in a JSON representation
  54972. * @returns the serialized block object
  54973. */
  54974. serialize(): any;
  54975. /** @hidden */
  54976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54977. }
  54978. }
  54979. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54980. /**
  54981. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54982. */
  54983. export enum NodeMaterialBlockConnectionPointMode {
  54984. /** Value is an uniform */
  54985. Uniform = 0,
  54986. /** Value is a mesh attribute */
  54987. Attribute = 1,
  54988. /** Value is a varying between vertex and fragment shaders */
  54989. Varying = 2,
  54990. /** Mode is undefined */
  54991. Undefined = 3
  54992. }
  54993. }
  54994. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  54995. /**
  54996. * Enum defining the type of animations supported by InputBlock
  54997. */
  54998. export enum AnimatedInputBlockTypes {
  54999. /** No animation */
  55000. None = 0,
  55001. /** Time based animation. Will only work for floats */
  55002. Time = 1
  55003. }
  55004. }
  55005. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55007. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55008. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55009. import { Nullable } from "babylonjs/types";
  55010. import { Effect } from "babylonjs/Materials/effect";
  55011. import { Matrix } from "babylonjs/Maths/math.vector";
  55012. import { Scene } from "babylonjs/scene";
  55013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55016. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55017. /**
  55018. * Block used to expose an input value
  55019. */
  55020. export class InputBlock extends NodeMaterialBlock {
  55021. private _mode;
  55022. private _associatedVariableName;
  55023. private _storedValue;
  55024. private _valueCallback;
  55025. private _type;
  55026. private _animationType;
  55027. /** @hidden */
  55028. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55029. /**
  55030. * Gets or sets the connection point type (default is float)
  55031. */
  55032. readonly type: NodeMaterialBlockConnectionPointTypes;
  55033. /**
  55034. * Creates a new InputBlock
  55035. * @param name defines the block name
  55036. * @param target defines the target of that block (Vertex by default)
  55037. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55038. */
  55039. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55040. /**
  55041. * Gets the output component
  55042. */
  55043. readonly output: NodeMaterialConnectionPoint;
  55044. /**
  55045. * Set the source of this connection point to a vertex attribute
  55046. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55047. * @returns the current connection point
  55048. */
  55049. setAsAttribute(attributeName?: string): InputBlock;
  55050. /**
  55051. * Set the source of this connection point to a well known value
  55052. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55053. * @returns the current connection point
  55054. */
  55055. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55056. /**
  55057. * Gets or sets the value of that point.
  55058. * Please note that this value will be ignored if valueCallback is defined
  55059. */
  55060. value: any;
  55061. /**
  55062. * Gets or sets a callback used to get the value of that point.
  55063. * Please note that setting this value will force the connection point to ignore the value property
  55064. */
  55065. valueCallback: () => any;
  55066. /**
  55067. * Gets or sets the associated variable name in the shader
  55068. */
  55069. associatedVariableName: string;
  55070. /** Gets or sets the type of animation applied to the input */
  55071. animationType: AnimatedInputBlockTypes;
  55072. /**
  55073. * Gets a boolean indicating that this connection point not defined yet
  55074. */
  55075. readonly isUndefined: boolean;
  55076. /**
  55077. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55078. * In this case the connection point name must be the name of the uniform to use.
  55079. * Can only be set on inputs
  55080. */
  55081. isUniform: boolean;
  55082. /**
  55083. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55084. * In this case the connection point name must be the name of the attribute to use
  55085. * Can only be set on inputs
  55086. */
  55087. isAttribute: boolean;
  55088. /**
  55089. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55090. * Can only be set on exit points
  55091. */
  55092. isVarying: boolean;
  55093. /**
  55094. * Gets a boolean indicating that the current connection point is a well known value
  55095. */
  55096. readonly isWellKnownValue: boolean;
  55097. /**
  55098. * Gets or sets the current well known value or null if not defined as well know value
  55099. */
  55100. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55101. /**
  55102. * Gets the current class name
  55103. * @returns the class name
  55104. */
  55105. getClassName(): string;
  55106. /**
  55107. * Animate the input if animationType !== None
  55108. * @param scene defines the rendering scene
  55109. */
  55110. animate(scene: Scene): void;
  55111. private _emitDefine;
  55112. /**
  55113. * Set the input block to its default value (based on its type)
  55114. */
  55115. setDefaultValue(): void;
  55116. private _emit;
  55117. /** @hidden */
  55118. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55119. /** @hidden */
  55120. _transmit(effect: Effect, scene: Scene): void;
  55121. protected _buildBlock(state: NodeMaterialBuildState): void;
  55122. serialize(): any;
  55123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55124. }
  55125. }
  55126. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55127. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55128. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55129. import { Nullable } from "babylonjs/types";
  55130. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55132. /**
  55133. * Defines a connection point for a block
  55134. */
  55135. export class NodeMaterialConnectionPoint {
  55136. /** @hidden */
  55137. _ownerBlock: NodeMaterialBlock;
  55138. /** @hidden */
  55139. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55140. private _endpoints;
  55141. private _associatedVariableName;
  55142. /** @hidden */
  55143. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55144. private _type;
  55145. /** @hidden */
  55146. _enforceAssociatedVariableName: boolean;
  55147. /**
  55148. * Gets or sets the additional types supported byt this connection point
  55149. */
  55150. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55151. /**
  55152. * Gets or sets the associated variable name in the shader
  55153. */
  55154. associatedVariableName: string;
  55155. /**
  55156. * Gets or sets the connection point type (default is float)
  55157. */
  55158. type: NodeMaterialBlockConnectionPointTypes;
  55159. /**
  55160. * Gets or sets the connection point name
  55161. */
  55162. name: string;
  55163. /**
  55164. * Gets or sets a boolean indicating that this connection point can be omitted
  55165. */
  55166. isOptional: boolean;
  55167. /**
  55168. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55169. */
  55170. define: string;
  55171. /** Gets or sets the target of that connection point */
  55172. target: NodeMaterialBlockTargets;
  55173. /**
  55174. * Gets a boolean indicating that the current point is connected
  55175. */
  55176. readonly isConnected: boolean;
  55177. /**
  55178. * Gets a boolean indicating that the current point is connected to an input block
  55179. */
  55180. readonly isConnectedToInput: boolean;
  55181. /**
  55182. * Gets a the connected input block (if any)
  55183. */
  55184. readonly connectInputBlock: Nullable<InputBlock>;
  55185. /** Get the other side of the connection (if any) */
  55186. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55187. /** Get the block that owns this connection point */
  55188. readonly ownerBlock: NodeMaterialBlock;
  55189. /** Get the block connected on the other side of this connection (if any) */
  55190. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55191. /** Get the block connected on the endpoints of this connection (if any) */
  55192. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55193. /** Gets the list of connected endpoints */
  55194. readonly endpoints: NodeMaterialConnectionPoint[];
  55195. /**
  55196. * Creates a new connection point
  55197. * @param name defines the connection point name
  55198. * @param ownerBlock defines the block hosting this connection point
  55199. */
  55200. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55201. /**
  55202. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55203. * @returns the class name
  55204. */
  55205. getClassName(): string;
  55206. /**
  55207. * Gets an boolean indicating if the current point can be connected to another point
  55208. * @param connectionPoint defines the other connection point
  55209. * @returns true if the connection is possible
  55210. */
  55211. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55212. /**
  55213. * Connect this point to another connection point
  55214. * @param connectionPoint defines the other connection point
  55215. * @returns the current connection point
  55216. */
  55217. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55218. /**
  55219. * Disconnect this point from one of his endpoint
  55220. * @param endpoint defines the other connection point
  55221. * @returns the current connection point
  55222. */
  55223. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55224. /**
  55225. * Serializes this point in a JSON representation
  55226. * @returns the serialized point object
  55227. */
  55228. serialize(): any;
  55229. }
  55230. }
  55231. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55235. import { Mesh } from "babylonjs/Meshes/mesh";
  55236. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55238. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55239. /**
  55240. * Block used to add support for vertex skinning (bones)
  55241. */
  55242. export class BonesBlock extends NodeMaterialBlock {
  55243. /**
  55244. * Creates a new BonesBlock
  55245. * @param name defines the block name
  55246. */
  55247. constructor(name: string);
  55248. /**
  55249. * Initialize the block and prepare the context for build
  55250. * @param state defines the state that will be used for the build
  55251. */
  55252. initialize(state: NodeMaterialBuildState): void;
  55253. /**
  55254. * Gets the current class name
  55255. * @returns the class name
  55256. */
  55257. getClassName(): string;
  55258. /**
  55259. * Gets the matrix indices input component
  55260. */
  55261. readonly matricesIndices: NodeMaterialConnectionPoint;
  55262. /**
  55263. * Gets the matrix weights input component
  55264. */
  55265. readonly matricesWeights: NodeMaterialConnectionPoint;
  55266. /**
  55267. * Gets the extra matrix indices input component
  55268. */
  55269. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55270. /**
  55271. * Gets the extra matrix weights input component
  55272. */
  55273. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55274. /**
  55275. * Gets the world input component
  55276. */
  55277. readonly world: NodeMaterialConnectionPoint;
  55278. /**
  55279. * Gets the output component
  55280. */
  55281. readonly output: NodeMaterialConnectionPoint;
  55282. autoConfigure(): void;
  55283. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55286. protected _buildBlock(state: NodeMaterialBuildState): this;
  55287. }
  55288. }
  55289. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55294. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55295. /**
  55296. * Block used to add support for instances
  55297. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55298. */
  55299. export class InstancesBlock extends NodeMaterialBlock {
  55300. /**
  55301. * Creates a new InstancesBlock
  55302. * @param name defines the block name
  55303. */
  55304. constructor(name: string);
  55305. /**
  55306. * Gets the current class name
  55307. * @returns the class name
  55308. */
  55309. getClassName(): string;
  55310. /**
  55311. * Gets the first world row input component
  55312. */
  55313. readonly world0: NodeMaterialConnectionPoint;
  55314. /**
  55315. * Gets the second world row input component
  55316. */
  55317. readonly world1: NodeMaterialConnectionPoint;
  55318. /**
  55319. * Gets the third world row input component
  55320. */
  55321. readonly world2: NodeMaterialConnectionPoint;
  55322. /**
  55323. * Gets the forth world row input component
  55324. */
  55325. readonly world3: NodeMaterialConnectionPoint;
  55326. /**
  55327. * Gets the world input component
  55328. */
  55329. readonly world: NodeMaterialConnectionPoint;
  55330. /**
  55331. * Gets the output component
  55332. */
  55333. readonly output: NodeMaterialConnectionPoint;
  55334. autoConfigure(): void;
  55335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55336. protected _buildBlock(state: NodeMaterialBuildState): this;
  55337. }
  55338. }
  55339. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55340. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55341. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55344. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55345. import { Effect } from "babylonjs/Materials/effect";
  55346. import { Mesh } from "babylonjs/Meshes/mesh";
  55347. /**
  55348. * Block used to add morph targets support to vertex shader
  55349. */
  55350. export class MorphTargetsBlock extends NodeMaterialBlock {
  55351. private _repeatableContentAnchor;
  55352. private _repeatebleContentGenerated;
  55353. /**
  55354. * Create a new MorphTargetsBlock
  55355. * @param name defines the block name
  55356. */
  55357. constructor(name: string);
  55358. /**
  55359. * Gets the current class name
  55360. * @returns the class name
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Gets the position input component
  55365. */
  55366. readonly position: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the normal input component
  55369. */
  55370. readonly normal: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the tangent input component
  55373. */
  55374. readonly tangent: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the tangent input component
  55377. */
  55378. readonly uv: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the position output component
  55381. */
  55382. readonly positionOutput: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the normal output component
  55385. */
  55386. readonly normalOutput: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the tangent output component
  55389. */
  55390. readonly tangentOutput: NodeMaterialConnectionPoint;
  55391. /**
  55392. * Gets the tangent output component
  55393. */
  55394. readonly uvOutput: NodeMaterialConnectionPoint;
  55395. initialize(state: NodeMaterialBuildState): void;
  55396. autoConfigure(): void;
  55397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55399. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55400. protected _buildBlock(state: NodeMaterialBuildState): this;
  55401. }
  55402. }
  55403. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55404. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55405. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55406. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55407. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55408. }
  55409. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55413. /**
  55414. * Block used to add an alpha test in the fragment shader
  55415. */
  55416. export class AlphaTestBlock extends NodeMaterialBlock {
  55417. /**
  55418. * Gets or sets the alpha value where alpha testing happens
  55419. */
  55420. alphaCutOff: number;
  55421. /**
  55422. * Create a new AlphaTestBlock
  55423. * @param name defines the block name
  55424. */
  55425. constructor(name: string);
  55426. /**
  55427. * Gets the current class name
  55428. * @returns the class name
  55429. */
  55430. getClassName(): string;
  55431. /**
  55432. * Gets the color input component
  55433. */
  55434. readonly color: NodeMaterialConnectionPoint;
  55435. /**
  55436. * Gets the alpha input component
  55437. */
  55438. readonly alpha: NodeMaterialConnectionPoint;
  55439. protected _buildBlock(state: NodeMaterialBuildState): this;
  55440. }
  55441. }
  55442. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  55443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55446. /**
  55447. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55448. */
  55449. export class ColorMergerBlock extends NodeMaterialBlock {
  55450. /**
  55451. * Create a new ColorMergerBlock
  55452. * @param name defines the block name
  55453. */
  55454. constructor(name: string);
  55455. /**
  55456. * Gets the current class name
  55457. * @returns the class name
  55458. */
  55459. getClassName(): string;
  55460. /**
  55461. * Gets the r component (input)
  55462. */
  55463. readonly r: NodeMaterialConnectionPoint;
  55464. /**
  55465. * Gets the g component (input)
  55466. */
  55467. readonly g: NodeMaterialConnectionPoint;
  55468. /**
  55469. * Gets the b component (input)
  55470. */
  55471. readonly b: NodeMaterialConnectionPoint;
  55472. /**
  55473. * Gets the a component (input)
  55474. */
  55475. readonly a: NodeMaterialConnectionPoint;
  55476. /**
  55477. * Gets the rgba component (output)
  55478. */
  55479. readonly rgba: NodeMaterialConnectionPoint;
  55480. /**
  55481. * Gets the rgb component (output)
  55482. */
  55483. readonly rgb: NodeMaterialConnectionPoint;
  55484. protected _buildBlock(state: NodeMaterialBuildState): this;
  55485. }
  55486. }
  55487. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55491. /**
  55492. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55493. */
  55494. export class VectorMergerBlock extends NodeMaterialBlock {
  55495. /**
  55496. * Create a new VectorMergerBlock
  55497. * @param name defines the block name
  55498. */
  55499. constructor(name: string);
  55500. /**
  55501. * Gets the current class name
  55502. * @returns the class name
  55503. */
  55504. getClassName(): string;
  55505. /**
  55506. * Gets the x component (input)
  55507. */
  55508. readonly x: NodeMaterialConnectionPoint;
  55509. /**
  55510. * Gets the y component (input)
  55511. */
  55512. readonly y: NodeMaterialConnectionPoint;
  55513. /**
  55514. * Gets the z component (input)
  55515. */
  55516. readonly z: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the w component (input)
  55519. */
  55520. readonly w: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Gets the xyzw component (output)
  55523. */
  55524. readonly xyzw: NodeMaterialConnectionPoint;
  55525. /**
  55526. * Gets the xyz component (output)
  55527. */
  55528. readonly xyz: NodeMaterialConnectionPoint;
  55529. /**
  55530. * Gets the xy component (output)
  55531. */
  55532. readonly xy: NodeMaterialConnectionPoint;
  55533. protected _buildBlock(state: NodeMaterialBuildState): this;
  55534. }
  55535. }
  55536. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55540. /**
  55541. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55542. */
  55543. export class ColorSplitterBlock extends NodeMaterialBlock {
  55544. /**
  55545. * Create a new ColorSplitterBlock
  55546. * @param name defines the block name
  55547. */
  55548. constructor(name: string);
  55549. /**
  55550. * Gets the current class name
  55551. * @returns the class name
  55552. */
  55553. getClassName(): string;
  55554. /**
  55555. * Gets the rgba component (input)
  55556. */
  55557. readonly rgba: NodeMaterialConnectionPoint;
  55558. /**
  55559. * Gets the rgb component (input)
  55560. */
  55561. readonly rgbIn: NodeMaterialConnectionPoint;
  55562. /**
  55563. * Gets the rgb component (output)
  55564. */
  55565. readonly rgbOut: NodeMaterialConnectionPoint;
  55566. /**
  55567. * Gets the r component (output)
  55568. */
  55569. readonly r: NodeMaterialConnectionPoint;
  55570. /**
  55571. * Gets the g component (output)
  55572. */
  55573. readonly g: NodeMaterialConnectionPoint;
  55574. /**
  55575. * Gets the b component (output)
  55576. */
  55577. readonly b: NodeMaterialConnectionPoint;
  55578. /**
  55579. * Gets the a component (output)
  55580. */
  55581. readonly a: NodeMaterialConnectionPoint;
  55582. protected _buildBlock(state: NodeMaterialBuildState): this;
  55583. }
  55584. }
  55585. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55589. /**
  55590. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55591. */
  55592. export class VectorSplitterBlock extends NodeMaterialBlock {
  55593. /**
  55594. * Create a new VectorSplitterBlock
  55595. * @param name defines the block name
  55596. */
  55597. constructor(name: string);
  55598. /**
  55599. * Gets the current class name
  55600. * @returns the class name
  55601. */
  55602. getClassName(): string;
  55603. /**
  55604. * Gets the xyzw component (input)
  55605. */
  55606. readonly xyzw: NodeMaterialConnectionPoint;
  55607. /**
  55608. * Gets the xyz component (input)
  55609. */
  55610. readonly xyzIn: NodeMaterialConnectionPoint;
  55611. /**
  55612. * Gets the xy component (input)
  55613. */
  55614. readonly xyIn: NodeMaterialConnectionPoint;
  55615. /**
  55616. * Gets the xyz component (output)
  55617. */
  55618. readonly xyzOut: NodeMaterialConnectionPoint;
  55619. /**
  55620. * Gets the xy component (output)
  55621. */
  55622. readonly xyOut: NodeMaterialConnectionPoint;
  55623. /**
  55624. * Gets the x component (output)
  55625. */
  55626. readonly x: NodeMaterialConnectionPoint;
  55627. /**
  55628. * Gets the y component (output)
  55629. */
  55630. readonly y: NodeMaterialConnectionPoint;
  55631. /**
  55632. * Gets the z component (output)
  55633. */
  55634. readonly z: NodeMaterialConnectionPoint;
  55635. /**
  55636. * Gets the w component (output)
  55637. */
  55638. readonly w: NodeMaterialConnectionPoint;
  55639. protected _buildBlock(state: NodeMaterialBuildState): this;
  55640. }
  55641. }
  55642. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55648. import { Effect } from "babylonjs/Materials/effect";
  55649. import { Mesh } from "babylonjs/Meshes/mesh";
  55650. /**
  55651. * Block used to add image processing support to fragment shader
  55652. */
  55653. export class ImageProcessingBlock extends NodeMaterialBlock {
  55654. /**
  55655. * Create a new ImageProcessingBlock
  55656. * @param name defines the block name
  55657. */
  55658. constructor(name: string);
  55659. /**
  55660. * Gets the current class name
  55661. * @returns the class name
  55662. */
  55663. getClassName(): string;
  55664. /**
  55665. * Gets the color input component
  55666. */
  55667. readonly color: NodeMaterialConnectionPoint;
  55668. /**
  55669. * Gets the output component
  55670. */
  55671. readonly output: NodeMaterialConnectionPoint;
  55672. /**
  55673. * Initialize the block and prepare the context for build
  55674. * @param state defines the state that will be used for the build
  55675. */
  55676. initialize(state: NodeMaterialBuildState): void;
  55677. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55680. protected _buildBlock(state: NodeMaterialBuildState): this;
  55681. }
  55682. }
  55683. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55684. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55685. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55686. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55687. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55688. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55689. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55690. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55691. }
  55692. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55695. import { Mesh } from "babylonjs/Meshes/mesh";
  55696. import { Effect } from "babylonjs/Materials/effect";
  55697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55699. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55700. /**
  55701. * Block used to add support for scene fog
  55702. */
  55703. export class FogBlock extends NodeMaterialBlock {
  55704. private _fogDistanceName;
  55705. private _fogParameters;
  55706. /**
  55707. * Create a new FogBlock
  55708. * @param name defines the block name
  55709. */
  55710. constructor(name: string);
  55711. /**
  55712. * Gets the current class name
  55713. * @returns the class name
  55714. */
  55715. getClassName(): string;
  55716. /**
  55717. * Gets the world position input component
  55718. */
  55719. readonly worldPosition: NodeMaterialConnectionPoint;
  55720. /**
  55721. * Gets the view input component
  55722. */
  55723. readonly view: NodeMaterialConnectionPoint;
  55724. /**
  55725. * Gets the color input component
  55726. */
  55727. readonly color: NodeMaterialConnectionPoint;
  55728. /**
  55729. * Gets the fog color input component
  55730. */
  55731. readonly fogColor: NodeMaterialConnectionPoint;
  55732. /**
  55733. * Gets the output component
  55734. */
  55735. readonly output: NodeMaterialConnectionPoint;
  55736. autoConfigure(): void;
  55737. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55739. protected _buildBlock(state: NodeMaterialBuildState): this;
  55740. }
  55741. }
  55742. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55747. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55748. import { Effect } from "babylonjs/Materials/effect";
  55749. import { Mesh } from "babylonjs/Meshes/mesh";
  55750. import { Light } from "babylonjs/Lights/light";
  55751. import { Nullable } from "babylonjs/types";
  55752. import { Scene } from "babylonjs/scene";
  55753. /**
  55754. * Block used to add light in the fragment shader
  55755. */
  55756. export class LightBlock extends NodeMaterialBlock {
  55757. private _lightId;
  55758. /**
  55759. * Gets or sets the light associated with this block
  55760. */
  55761. light: Nullable<Light>;
  55762. /**
  55763. * Create a new LightBlock
  55764. * @param name defines the block name
  55765. */
  55766. constructor(name: string);
  55767. /**
  55768. * Gets the current class name
  55769. * @returns the class name
  55770. */
  55771. getClassName(): string;
  55772. /**
  55773. * Gets the world position input component
  55774. */
  55775. readonly worldPosition: NodeMaterialConnectionPoint;
  55776. /**
  55777. * Gets the world normal input component
  55778. */
  55779. readonly worldNormal: NodeMaterialConnectionPoint;
  55780. /**
  55781. * Gets the camera (or eye) position component
  55782. */
  55783. readonly cameraPosition: NodeMaterialConnectionPoint;
  55784. /**
  55785. * Gets the diffuse output component
  55786. */
  55787. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55788. /**
  55789. * Gets the specular output component
  55790. */
  55791. readonly specularOutput: NodeMaterialConnectionPoint;
  55792. autoConfigure(): void;
  55793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55794. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55795. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55796. private _injectVertexCode;
  55797. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55798. serialize(): any;
  55799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55800. }
  55801. }
  55802. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55803. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55804. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55805. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55806. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55807. }
  55808. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55809. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55810. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55811. }
  55812. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55816. /**
  55817. * Block used to multiply 2 values
  55818. */
  55819. export class MultiplyBlock extends NodeMaterialBlock {
  55820. /**
  55821. * Creates a new MultiplyBlock
  55822. * @param name defines the block name
  55823. */
  55824. constructor(name: string);
  55825. /**
  55826. * Gets the current class name
  55827. * @returns the class name
  55828. */
  55829. getClassName(): string;
  55830. /**
  55831. * Gets the left operand input component
  55832. */
  55833. readonly left: NodeMaterialConnectionPoint;
  55834. /**
  55835. * Gets the right operand input component
  55836. */
  55837. readonly right: NodeMaterialConnectionPoint;
  55838. /**
  55839. * Gets the output component
  55840. */
  55841. readonly output: NodeMaterialConnectionPoint;
  55842. protected _buildBlock(state: NodeMaterialBuildState): this;
  55843. }
  55844. }
  55845. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55849. /**
  55850. * Block used to add 2 vectors
  55851. */
  55852. export class AddBlock extends NodeMaterialBlock {
  55853. /**
  55854. * Creates a new AddBlock
  55855. * @param name defines the block name
  55856. */
  55857. constructor(name: string);
  55858. /**
  55859. * Gets the current class name
  55860. * @returns the class name
  55861. */
  55862. getClassName(): string;
  55863. /**
  55864. * Gets the left operand input component
  55865. */
  55866. readonly left: NodeMaterialConnectionPoint;
  55867. /**
  55868. * Gets the right operand input component
  55869. */
  55870. readonly right: NodeMaterialConnectionPoint;
  55871. /**
  55872. * Gets the output component
  55873. */
  55874. readonly output: NodeMaterialConnectionPoint;
  55875. protected _buildBlock(state: NodeMaterialBuildState): this;
  55876. }
  55877. }
  55878. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55882. /**
  55883. * Block used to scale a vector by a float
  55884. */
  55885. export class ScaleBlock extends NodeMaterialBlock {
  55886. /**
  55887. * Creates a new ScaleBlock
  55888. * @param name defines the block name
  55889. */
  55890. constructor(name: string);
  55891. /**
  55892. * Gets the current class name
  55893. * @returns the class name
  55894. */
  55895. getClassName(): string;
  55896. /**
  55897. * Gets the input component
  55898. */
  55899. readonly input: NodeMaterialConnectionPoint;
  55900. /**
  55901. * Gets the factor input component
  55902. */
  55903. readonly factor: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the output component
  55906. */
  55907. readonly output: NodeMaterialConnectionPoint;
  55908. protected _buildBlock(state: NodeMaterialBuildState): this;
  55909. }
  55910. }
  55911. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55915. /**
  55916. * Block used to clamp a float
  55917. */
  55918. export class ClampBlock extends NodeMaterialBlock {
  55919. /** Gets or sets the minimum range */
  55920. minimum: number;
  55921. /** Gets or sets the maximum range */
  55922. maximum: number;
  55923. /**
  55924. * Creates a new ClampBlock
  55925. * @param name defines the block name
  55926. */
  55927. constructor(name: string);
  55928. /**
  55929. * Gets the current class name
  55930. * @returns the class name
  55931. */
  55932. getClassName(): string;
  55933. /**
  55934. * Gets the value input component
  55935. */
  55936. readonly value: NodeMaterialConnectionPoint;
  55937. /**
  55938. * Gets the output component
  55939. */
  55940. readonly output: NodeMaterialConnectionPoint;
  55941. protected _buildBlock(state: NodeMaterialBuildState): this;
  55942. }
  55943. }
  55944. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55948. /**
  55949. * Block used to apply a cross product between 2 vectors
  55950. */
  55951. export class CrossBlock extends NodeMaterialBlock {
  55952. /**
  55953. * Creates a new CrossBlock
  55954. * @param name defines the block name
  55955. */
  55956. constructor(name: string);
  55957. /**
  55958. * Gets the current class name
  55959. * @returns the class name
  55960. */
  55961. getClassName(): string;
  55962. /**
  55963. * Gets the left operand input component
  55964. */
  55965. readonly left: NodeMaterialConnectionPoint;
  55966. /**
  55967. * Gets the right operand input component
  55968. */
  55969. readonly right: NodeMaterialConnectionPoint;
  55970. /**
  55971. * Gets the output component
  55972. */
  55973. readonly output: NodeMaterialConnectionPoint;
  55974. protected _buildBlock(state: NodeMaterialBuildState): this;
  55975. }
  55976. }
  55977. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55981. /**
  55982. * Block used to apply a dot product between 2 vectors
  55983. */
  55984. export class DotBlock extends NodeMaterialBlock {
  55985. /**
  55986. * Creates a new DotBlock
  55987. * @param name defines the block name
  55988. */
  55989. constructor(name: string);
  55990. /**
  55991. * Gets the current class name
  55992. * @returns the class name
  55993. */
  55994. getClassName(): string;
  55995. /**
  55996. * Gets the left operand input component
  55997. */
  55998. readonly left: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the right operand input component
  56001. */
  56002. readonly right: NodeMaterialConnectionPoint;
  56003. /**
  56004. * Gets the output component
  56005. */
  56006. readonly output: NodeMaterialConnectionPoint;
  56007. protected _buildBlock(state: NodeMaterialBuildState): this;
  56008. }
  56009. }
  56010. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56014. import { Vector2 } from "babylonjs/Maths/math.vector";
  56015. /**
  56016. * Block used to remap a float from a range to a new one
  56017. */
  56018. export class RemapBlock extends NodeMaterialBlock {
  56019. /**
  56020. * Gets or sets the source range
  56021. */
  56022. sourceRange: Vector2;
  56023. /**
  56024. * Gets or sets the target range
  56025. */
  56026. targetRange: Vector2;
  56027. /**
  56028. * Creates a new RemapBlock
  56029. * @param name defines the block name
  56030. */
  56031. constructor(name: string);
  56032. /**
  56033. * Gets the current class name
  56034. * @returns the class name
  56035. */
  56036. getClassName(): string;
  56037. /**
  56038. * Gets the input component
  56039. */
  56040. readonly input: NodeMaterialConnectionPoint;
  56041. /**
  56042. * Gets the output component
  56043. */
  56044. readonly output: NodeMaterialConnectionPoint;
  56045. protected _buildBlock(state: NodeMaterialBuildState): this;
  56046. }
  56047. }
  56048. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56052. /**
  56053. * Block used to normalize a vector
  56054. */
  56055. export class NormalizeBlock extends NodeMaterialBlock {
  56056. /**
  56057. * Creates a new NormalizeBlock
  56058. * @param name defines the block name
  56059. */
  56060. constructor(name: string);
  56061. /**
  56062. * Gets the current class name
  56063. * @returns the class name
  56064. */
  56065. getClassName(): string;
  56066. /**
  56067. * Gets the input component
  56068. */
  56069. readonly input: NodeMaterialConnectionPoint;
  56070. /**
  56071. * Gets the output component
  56072. */
  56073. readonly output: NodeMaterialConnectionPoint;
  56074. protected _buildBlock(state: NodeMaterialBuildState): this;
  56075. }
  56076. }
  56077. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56081. /**
  56082. * Operations supported by the Trigonometry block
  56083. */
  56084. export enum TrigonometryBlockOperations {
  56085. /** Cos */
  56086. Cos = 0,
  56087. /** Sin */
  56088. Sin = 1,
  56089. /** Abs */
  56090. Abs = 2
  56091. }
  56092. /**
  56093. * Block used to apply trigonometry operation to floats
  56094. */
  56095. export class TrigonometryBlock extends NodeMaterialBlock {
  56096. /**
  56097. * Gets or sets the operation applied by the block
  56098. */
  56099. operation: TrigonometryBlockOperations;
  56100. /**
  56101. * Creates a new TrigonometryBlock
  56102. * @param name defines the block name
  56103. */
  56104. constructor(name: string);
  56105. /**
  56106. * Gets the current class name
  56107. * @returns the class name
  56108. */
  56109. getClassName(): string;
  56110. /**
  56111. * Gets the input component
  56112. */
  56113. readonly input: NodeMaterialConnectionPoint;
  56114. /**
  56115. * Gets the output component
  56116. */
  56117. readonly output: NodeMaterialConnectionPoint;
  56118. protected _buildBlock(state: NodeMaterialBuildState): this;
  56119. }
  56120. }
  56121. declare module "babylonjs/Materials/Node/Blocks/index" {
  56122. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56123. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56124. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56125. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56126. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56127. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56128. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56129. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56130. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56131. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56132. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56133. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56134. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56135. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56136. }
  56137. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56138. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56139. }
  56140. declare module "babylonjs/Materials/Node/index" {
  56141. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56142. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56143. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56144. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56145. export * from "babylonjs/Materials/Node/nodeMaterial";
  56146. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56147. export * from "babylonjs/Materials/Node/Blocks/index";
  56148. export * from "babylonjs/Materials/Node/Optimizers/index";
  56149. }
  56150. declare module "babylonjs/Materials/effectRenderer" {
  56151. import { Nullable } from "babylonjs/types";
  56152. import { Texture } from "babylonjs/Materials/Textures/texture";
  56153. import { Engine } from "babylonjs/Engines/engine";
  56154. import { Viewport } from "babylonjs/Maths/math.viewport";
  56155. import { Observable } from "babylonjs/Misc/observable";
  56156. import { Effect } from "babylonjs/Materials/effect";
  56157. import "babylonjs/Shaders/postprocess.vertex";
  56158. /**
  56159. * Effect Render Options
  56160. */
  56161. export interface IEffectRendererOptions {
  56162. /**
  56163. * Defines the vertices positions.
  56164. */
  56165. positions?: number[];
  56166. /**
  56167. * Defines the indices.
  56168. */
  56169. indices?: number[];
  56170. }
  56171. /**
  56172. * Helper class to render one or more effects
  56173. */
  56174. export class EffectRenderer {
  56175. private engine;
  56176. private static _DefaultOptions;
  56177. private _vertexBuffers;
  56178. private _indexBuffer;
  56179. private _ringBufferIndex;
  56180. private _ringScreenBuffer;
  56181. private _fullscreenViewport;
  56182. private _getNextFrameBuffer;
  56183. /**
  56184. * Creates an effect renderer
  56185. * @param engine the engine to use for rendering
  56186. * @param options defines the options of the effect renderer
  56187. */
  56188. constructor(engine: Engine, options?: IEffectRendererOptions);
  56189. /**
  56190. * Sets the current viewport in normalized coordinates 0-1
  56191. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56192. */
  56193. setViewport(viewport?: Viewport): void;
  56194. /**
  56195. * Sets the current effect wrapper to use during draw.
  56196. * The effect needs to be ready before calling this api.
  56197. * This also sets the default full screen position attribute.
  56198. * @param effectWrapper Defines the effect to draw with
  56199. */
  56200. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56201. /**
  56202. * Draws a full screen quad.
  56203. */
  56204. draw(): void;
  56205. /**
  56206. * renders one or more effects to a specified texture
  56207. * @param effectWrappers list of effects to renderer
  56208. * @param outputTexture texture to draw to, if null it will render to the screen
  56209. */
  56210. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56211. /**
  56212. * Disposes of the effect renderer
  56213. */
  56214. dispose(): void;
  56215. }
  56216. /**
  56217. * Options to create an EffectWrapper
  56218. */
  56219. interface EffectWrapperCreationOptions {
  56220. /**
  56221. * Engine to use to create the effect
  56222. */
  56223. engine: Engine;
  56224. /**
  56225. * Fragment shader for the effect
  56226. */
  56227. fragmentShader: string;
  56228. /**
  56229. * Vertex shader for the effect
  56230. */
  56231. vertexShader?: string;
  56232. /**
  56233. * Attributes to use in the shader
  56234. */
  56235. attributeNames?: Array<string>;
  56236. /**
  56237. * Uniforms to use in the shader
  56238. */
  56239. uniformNames?: Array<string>;
  56240. /**
  56241. * Texture sampler names to use in the shader
  56242. */
  56243. samplerNames?: Array<string>;
  56244. /**
  56245. * The friendly name of the effect displayed in Spector.
  56246. */
  56247. name?: string;
  56248. }
  56249. /**
  56250. * Wraps an effect to be used for rendering
  56251. */
  56252. export class EffectWrapper {
  56253. /**
  56254. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56255. */
  56256. onApplyObservable: Observable<{}>;
  56257. /**
  56258. * The underlying effect
  56259. */
  56260. effect: Effect;
  56261. /**
  56262. * Creates an effect to be renderer
  56263. * @param creationOptions options to create the effect
  56264. */
  56265. constructor(creationOptions: EffectWrapperCreationOptions);
  56266. /**
  56267. * Disposes of the effect wrapper
  56268. */
  56269. dispose(): void;
  56270. }
  56271. }
  56272. declare module "babylonjs/Materials/index" {
  56273. export * from "babylonjs/Materials/Background/index";
  56274. export * from "babylonjs/Materials/colorCurves";
  56275. export * from "babylonjs/Materials/effect";
  56276. export * from "babylonjs/Materials/fresnelParameters";
  56277. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56278. export * from "babylonjs/Materials/material";
  56279. export * from "babylonjs/Materials/materialDefines";
  56280. export * from "babylonjs/Materials/materialHelper";
  56281. export * from "babylonjs/Materials/multiMaterial";
  56282. export * from "babylonjs/Materials/PBR/index";
  56283. export * from "babylonjs/Materials/pushMaterial";
  56284. export * from "babylonjs/Materials/shaderMaterial";
  56285. export * from "babylonjs/Materials/standardMaterial";
  56286. export * from "babylonjs/Materials/Textures/index";
  56287. export * from "babylonjs/Materials/uniformBuffer";
  56288. export * from "babylonjs/Materials/materialFlags";
  56289. export * from "babylonjs/Materials/Node/index";
  56290. export * from "babylonjs/Materials/effectRenderer";
  56291. }
  56292. declare module "babylonjs/Maths/index" {
  56293. export * from "babylonjs/Maths/math.scalar";
  56294. export * from "babylonjs/Maths/math";
  56295. export * from "babylonjs/Maths/sphericalPolynomial";
  56296. }
  56297. declare module "babylonjs/Misc/workerPool" {
  56298. import { IDisposable } from "babylonjs/scene";
  56299. /**
  56300. * Helper class to push actions to a pool of workers.
  56301. */
  56302. export class WorkerPool implements IDisposable {
  56303. private _workerInfos;
  56304. private _pendingActions;
  56305. /**
  56306. * Constructor
  56307. * @param workers Array of workers to use for actions
  56308. */
  56309. constructor(workers: Array<Worker>);
  56310. /**
  56311. * Terminates all workers and clears any pending actions.
  56312. */
  56313. dispose(): void;
  56314. /**
  56315. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56316. * pended until a worker has completed its action.
  56317. * @param action The action to perform. Call onComplete when the action is complete.
  56318. */
  56319. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56320. private _execute;
  56321. }
  56322. }
  56323. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56324. import { IDisposable } from "babylonjs/scene";
  56325. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56326. /**
  56327. * Configuration for Draco compression
  56328. */
  56329. export interface IDracoCompressionConfiguration {
  56330. /**
  56331. * Configuration for the decoder.
  56332. */
  56333. decoder: {
  56334. /**
  56335. * The url to the WebAssembly module.
  56336. */
  56337. wasmUrl?: string;
  56338. /**
  56339. * The url to the WebAssembly binary.
  56340. */
  56341. wasmBinaryUrl?: string;
  56342. /**
  56343. * The url to the fallback JavaScript module.
  56344. */
  56345. fallbackUrl?: string;
  56346. };
  56347. }
  56348. /**
  56349. * Draco compression (https://google.github.io/draco/)
  56350. *
  56351. * This class wraps the Draco module.
  56352. *
  56353. * **Encoder**
  56354. *
  56355. * The encoder is not currently implemented.
  56356. *
  56357. * **Decoder**
  56358. *
  56359. * 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.
  56360. *
  56361. * To update the configuration, use the following code:
  56362. * ```javascript
  56363. * DracoCompression.Configuration = {
  56364. * decoder: {
  56365. * wasmUrl: "<url to the WebAssembly library>",
  56366. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56367. * fallbackUrl: "<url to the fallback JavaScript library>",
  56368. * }
  56369. * };
  56370. * ```
  56371. *
  56372. * 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.
  56373. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56374. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56375. *
  56376. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56377. * ```javascript
  56378. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56379. * ```
  56380. *
  56381. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56382. */
  56383. export class DracoCompression implements IDisposable {
  56384. private _workerPoolPromise?;
  56385. private _decoderModulePromise?;
  56386. /**
  56387. * The configuration. Defaults to the following urls:
  56388. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56389. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56390. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56391. */
  56392. static Configuration: IDracoCompressionConfiguration;
  56393. /**
  56394. * Returns true if the decoder configuration is available.
  56395. */
  56396. static readonly DecoderAvailable: boolean;
  56397. /**
  56398. * Default number of workers to create when creating the draco compression object.
  56399. */
  56400. static DefaultNumWorkers: number;
  56401. private static GetDefaultNumWorkers;
  56402. private static _Default;
  56403. /**
  56404. * Default instance for the draco compression object.
  56405. */
  56406. static readonly Default: DracoCompression;
  56407. /**
  56408. * Constructor
  56409. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56410. */
  56411. constructor(numWorkers?: number);
  56412. /**
  56413. * Stop all async operations and release resources.
  56414. */
  56415. dispose(): void;
  56416. /**
  56417. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56418. * @returns a promise that resolves when ready
  56419. */
  56420. whenReadyAsync(): Promise<void>;
  56421. /**
  56422. * Decode Draco compressed mesh data to vertex data.
  56423. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56424. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56425. * @returns A promise that resolves with the decoded vertex data
  56426. */
  56427. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56428. [kind: string]: number;
  56429. }): Promise<VertexData>;
  56430. }
  56431. }
  56432. declare module "babylonjs/Meshes/Compression/index" {
  56433. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56434. }
  56435. declare module "babylonjs/Meshes/csg" {
  56436. import { Nullable } from "babylonjs/types";
  56437. import { Scene } from "babylonjs/scene";
  56438. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56439. import { Mesh } from "babylonjs/Meshes/mesh";
  56440. import { Material } from "babylonjs/Materials/material";
  56441. /**
  56442. * Class for building Constructive Solid Geometry
  56443. */
  56444. export class CSG {
  56445. private polygons;
  56446. /**
  56447. * The world matrix
  56448. */
  56449. matrix: Matrix;
  56450. /**
  56451. * Stores the position
  56452. */
  56453. position: Vector3;
  56454. /**
  56455. * Stores the rotation
  56456. */
  56457. rotation: Vector3;
  56458. /**
  56459. * Stores the rotation quaternion
  56460. */
  56461. rotationQuaternion: Nullable<Quaternion>;
  56462. /**
  56463. * Stores the scaling vector
  56464. */
  56465. scaling: Vector3;
  56466. /**
  56467. * Convert the Mesh to CSG
  56468. * @param mesh The Mesh to convert to CSG
  56469. * @returns A new CSG from the Mesh
  56470. */
  56471. static FromMesh(mesh: Mesh): CSG;
  56472. /**
  56473. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56474. * @param polygons Polygons used to construct a CSG solid
  56475. */
  56476. private static FromPolygons;
  56477. /**
  56478. * Clones, or makes a deep copy, of the CSG
  56479. * @returns A new CSG
  56480. */
  56481. clone(): CSG;
  56482. /**
  56483. * Unions this CSG with another CSG
  56484. * @param csg The CSG to union against this CSG
  56485. * @returns The unioned CSG
  56486. */
  56487. union(csg: CSG): CSG;
  56488. /**
  56489. * Unions this CSG with another CSG in place
  56490. * @param csg The CSG to union against this CSG
  56491. */
  56492. unionInPlace(csg: CSG): void;
  56493. /**
  56494. * Subtracts this CSG with another CSG
  56495. * @param csg The CSG to subtract against this CSG
  56496. * @returns A new CSG
  56497. */
  56498. subtract(csg: CSG): CSG;
  56499. /**
  56500. * Subtracts this CSG with another CSG in place
  56501. * @param csg The CSG to subtact against this CSG
  56502. */
  56503. subtractInPlace(csg: CSG): void;
  56504. /**
  56505. * Intersect this CSG with another CSG
  56506. * @param csg The CSG to intersect against this CSG
  56507. * @returns A new CSG
  56508. */
  56509. intersect(csg: CSG): CSG;
  56510. /**
  56511. * Intersects this CSG with another CSG in place
  56512. * @param csg The CSG to intersect against this CSG
  56513. */
  56514. intersectInPlace(csg: CSG): void;
  56515. /**
  56516. * Return a new CSG solid with solid and empty space switched. This solid is
  56517. * not modified.
  56518. * @returns A new CSG solid with solid and empty space switched
  56519. */
  56520. inverse(): CSG;
  56521. /**
  56522. * Inverses the CSG in place
  56523. */
  56524. inverseInPlace(): void;
  56525. /**
  56526. * This is used to keep meshes transformations so they can be restored
  56527. * when we build back a Babylon Mesh
  56528. * NB : All CSG operations are performed in world coordinates
  56529. * @param csg The CSG to copy the transform attributes from
  56530. * @returns This CSG
  56531. */
  56532. copyTransformAttributes(csg: CSG): CSG;
  56533. /**
  56534. * Build Raw mesh from CSG
  56535. * Coordinates here are in world space
  56536. * @param name The name of the mesh geometry
  56537. * @param scene The Scene
  56538. * @param keepSubMeshes Specifies if the submeshes should be kept
  56539. * @returns A new Mesh
  56540. */
  56541. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56542. /**
  56543. * Build Mesh from CSG taking material and transforms into account
  56544. * @param name The name of the Mesh
  56545. * @param material The material of the Mesh
  56546. * @param scene The Scene
  56547. * @param keepSubMeshes Specifies if submeshes should be kept
  56548. * @returns The new Mesh
  56549. */
  56550. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56551. }
  56552. }
  56553. declare module "babylonjs/Meshes/trailMesh" {
  56554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56555. import { Mesh } from "babylonjs/Meshes/mesh";
  56556. import { Scene } from "babylonjs/scene";
  56557. /**
  56558. * Class used to create a trail following a mesh
  56559. */
  56560. export class TrailMesh extends Mesh {
  56561. private _generator;
  56562. private _autoStart;
  56563. private _running;
  56564. private _diameter;
  56565. private _length;
  56566. private _sectionPolygonPointsCount;
  56567. private _sectionVectors;
  56568. private _sectionNormalVectors;
  56569. private _beforeRenderObserver;
  56570. /**
  56571. * @constructor
  56572. * @param name The value used by scene.getMeshByName() to do a lookup.
  56573. * @param generator The mesh to generate a trail.
  56574. * @param scene The scene to add this mesh to.
  56575. * @param diameter Diameter of trailing mesh. Default is 1.
  56576. * @param length Length of trailing mesh. Default is 60.
  56577. * @param autoStart Automatically start trailing mesh. Default true.
  56578. */
  56579. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56580. /**
  56581. * "TrailMesh"
  56582. * @returns "TrailMesh"
  56583. */
  56584. getClassName(): string;
  56585. private _createMesh;
  56586. /**
  56587. * Start trailing mesh.
  56588. */
  56589. start(): void;
  56590. /**
  56591. * Stop trailing mesh.
  56592. */
  56593. stop(): void;
  56594. /**
  56595. * Update trailing mesh geometry.
  56596. */
  56597. update(): void;
  56598. /**
  56599. * Returns a new TrailMesh object.
  56600. * @param name is a string, the name given to the new mesh
  56601. * @param newGenerator use new generator object for cloned trail mesh
  56602. * @returns a new mesh
  56603. */
  56604. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56605. /**
  56606. * Serializes this trail mesh
  56607. * @param serializationObject object to write serialization to
  56608. */
  56609. serialize(serializationObject: any): void;
  56610. /**
  56611. * Parses a serialized trail mesh
  56612. * @param parsedMesh the serialized mesh
  56613. * @param scene the scene to create the trail mesh in
  56614. * @returns the created trail mesh
  56615. */
  56616. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56617. }
  56618. }
  56619. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56620. import { Nullable } from "babylonjs/types";
  56621. import { Scene } from "babylonjs/scene";
  56622. import { Vector4 } from "babylonjs/Maths/math.vector";
  56623. import { Color4 } from "babylonjs/Maths/math.color";
  56624. import { Mesh } from "babylonjs/Meshes/mesh";
  56625. /**
  56626. * Class containing static functions to help procedurally build meshes
  56627. */
  56628. export class TiledBoxBuilder {
  56629. /**
  56630. * Creates a box mesh
  56631. * 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)
  56632. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56636. * @param name defines the name of the mesh
  56637. * @param options defines the options used to create the mesh
  56638. * @param scene defines the hosting scene
  56639. * @returns the box mesh
  56640. */
  56641. static CreateTiledBox(name: string, options: {
  56642. pattern?: number;
  56643. width?: number;
  56644. height?: number;
  56645. depth?: number;
  56646. tileSize?: number;
  56647. tileWidth?: number;
  56648. tileHeight?: number;
  56649. alignHorizontal?: number;
  56650. alignVertical?: number;
  56651. faceUV?: Vector4[];
  56652. faceColors?: Color4[];
  56653. sideOrientation?: number;
  56654. updatable?: boolean;
  56655. }, scene?: Nullable<Scene>): Mesh;
  56656. }
  56657. }
  56658. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56659. import { Vector4 } from "babylonjs/Maths/math.vector";
  56660. import { Mesh } from "babylonjs/Meshes/mesh";
  56661. /**
  56662. * Class containing static functions to help procedurally build meshes
  56663. */
  56664. export class TorusKnotBuilder {
  56665. /**
  56666. * Creates a torus knot mesh
  56667. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56668. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56669. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56670. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56674. * @param name defines the name of the mesh
  56675. * @param options defines the options used to create the mesh
  56676. * @param scene defines the hosting scene
  56677. * @returns the torus knot mesh
  56678. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56679. */
  56680. static CreateTorusKnot(name: string, options: {
  56681. radius?: number;
  56682. tube?: number;
  56683. radialSegments?: number;
  56684. tubularSegments?: number;
  56685. p?: number;
  56686. q?: number;
  56687. updatable?: boolean;
  56688. sideOrientation?: number;
  56689. frontUVs?: Vector4;
  56690. backUVs?: Vector4;
  56691. }, scene: any): Mesh;
  56692. }
  56693. }
  56694. declare module "babylonjs/Meshes/polygonMesh" {
  56695. import { Scene } from "babylonjs/scene";
  56696. import { Vector2 } from "babylonjs/Maths/math.vector";
  56697. import { Mesh } from "babylonjs/Meshes/mesh";
  56698. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56699. import { Path2 } from "babylonjs/Maths/math.path";
  56700. /**
  56701. * Polygon
  56702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56703. */
  56704. export class Polygon {
  56705. /**
  56706. * Creates a rectangle
  56707. * @param xmin bottom X coord
  56708. * @param ymin bottom Y coord
  56709. * @param xmax top X coord
  56710. * @param ymax top Y coord
  56711. * @returns points that make the resulting rectation
  56712. */
  56713. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56714. /**
  56715. * Creates a circle
  56716. * @param radius radius of circle
  56717. * @param cx scale in x
  56718. * @param cy scale in y
  56719. * @param numberOfSides number of sides that make up the circle
  56720. * @returns points that make the resulting circle
  56721. */
  56722. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56723. /**
  56724. * Creates a polygon from input string
  56725. * @param input Input polygon data
  56726. * @returns the parsed points
  56727. */
  56728. static Parse(input: string): Vector2[];
  56729. /**
  56730. * Starts building a polygon from x and y coordinates
  56731. * @param x x coordinate
  56732. * @param y y coordinate
  56733. * @returns the started path2
  56734. */
  56735. static StartingAt(x: number, y: number): Path2;
  56736. }
  56737. /**
  56738. * Builds a polygon
  56739. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56740. */
  56741. export class PolygonMeshBuilder {
  56742. private _points;
  56743. private _outlinepoints;
  56744. private _holes;
  56745. private _name;
  56746. private _scene;
  56747. private _epoints;
  56748. private _eholes;
  56749. private _addToepoint;
  56750. /**
  56751. * Babylon reference to the earcut plugin.
  56752. */
  56753. bjsEarcut: any;
  56754. /**
  56755. * Creates a PolygonMeshBuilder
  56756. * @param name name of the builder
  56757. * @param contours Path of the polygon
  56758. * @param scene scene to add to when creating the mesh
  56759. * @param earcutInjection can be used to inject your own earcut reference
  56760. */
  56761. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56762. /**
  56763. * Adds a whole within the polygon
  56764. * @param hole Array of points defining the hole
  56765. * @returns this
  56766. */
  56767. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56768. /**
  56769. * Creates the polygon
  56770. * @param updatable If the mesh should be updatable
  56771. * @param depth The depth of the mesh created
  56772. * @returns the created mesh
  56773. */
  56774. build(updatable?: boolean, depth?: number): Mesh;
  56775. /**
  56776. * Creates the polygon
  56777. * @param depth The depth of the mesh created
  56778. * @returns the created VertexData
  56779. */
  56780. buildVertexData(depth?: number): VertexData;
  56781. /**
  56782. * Adds a side to the polygon
  56783. * @param positions points that make the polygon
  56784. * @param normals normals of the polygon
  56785. * @param uvs uvs of the polygon
  56786. * @param indices indices of the polygon
  56787. * @param bounds bounds of the polygon
  56788. * @param points points of the polygon
  56789. * @param depth depth of the polygon
  56790. * @param flip flip of the polygon
  56791. */
  56792. private addSide;
  56793. }
  56794. }
  56795. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56796. import { Scene } from "babylonjs/scene";
  56797. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56798. import { Color4 } from "babylonjs/Maths/math.color";
  56799. import { Mesh } from "babylonjs/Meshes/mesh";
  56800. import { Nullable } from "babylonjs/types";
  56801. /**
  56802. * Class containing static functions to help procedurally build meshes
  56803. */
  56804. export class PolygonBuilder {
  56805. /**
  56806. * Creates a polygon mesh
  56807. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56808. * * 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
  56809. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56812. * * Remember you can only change the shape positions, not their number when updating a polygon
  56813. * @param name defines the name of the mesh
  56814. * @param options defines the options used to create the mesh
  56815. * @param scene defines the hosting scene
  56816. * @param earcutInjection can be used to inject your own earcut reference
  56817. * @returns the polygon mesh
  56818. */
  56819. static CreatePolygon(name: string, options: {
  56820. shape: Vector3[];
  56821. holes?: Vector3[][];
  56822. depth?: number;
  56823. faceUV?: Vector4[];
  56824. faceColors?: Color4[];
  56825. updatable?: boolean;
  56826. sideOrientation?: number;
  56827. frontUVs?: Vector4;
  56828. backUVs?: Vector4;
  56829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56830. /**
  56831. * Creates an extruded polygon mesh, with depth in the Y direction.
  56832. * * 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)
  56833. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56834. * @param name defines the name of the mesh
  56835. * @param options defines the options used to create the mesh
  56836. * @param scene defines the hosting scene
  56837. * @param earcutInjection can be used to inject your own earcut reference
  56838. * @returns the polygon mesh
  56839. */
  56840. static ExtrudePolygon(name: string, options: {
  56841. shape: Vector3[];
  56842. holes?: Vector3[][];
  56843. depth?: number;
  56844. faceUV?: Vector4[];
  56845. faceColors?: Color4[];
  56846. updatable?: boolean;
  56847. sideOrientation?: number;
  56848. frontUVs?: Vector4;
  56849. backUVs?: Vector4;
  56850. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56851. }
  56852. }
  56853. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56854. import { Scene } from "babylonjs/scene";
  56855. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56856. import { Mesh } from "babylonjs/Meshes/mesh";
  56857. import { Nullable } from "babylonjs/types";
  56858. /**
  56859. * Class containing static functions to help procedurally build meshes
  56860. */
  56861. export class LatheBuilder {
  56862. /**
  56863. * Creates lathe mesh.
  56864. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56865. * * 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
  56866. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56867. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56868. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56869. * * 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
  56870. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56871. * * 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
  56872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56876. * @param name defines the name of the mesh
  56877. * @param options defines the options used to create the mesh
  56878. * @param scene defines the hosting scene
  56879. * @returns the lathe mesh
  56880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56881. */
  56882. static CreateLathe(name: string, options: {
  56883. shape: Vector3[];
  56884. radius?: number;
  56885. tessellation?: number;
  56886. clip?: number;
  56887. arc?: number;
  56888. closed?: boolean;
  56889. updatable?: boolean;
  56890. sideOrientation?: number;
  56891. frontUVs?: Vector4;
  56892. backUVs?: Vector4;
  56893. cap?: number;
  56894. invertUV?: boolean;
  56895. }, scene?: Nullable<Scene>): Mesh;
  56896. }
  56897. }
  56898. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56899. import { Nullable } from "babylonjs/types";
  56900. import { Scene } from "babylonjs/scene";
  56901. import { Vector4 } from "babylonjs/Maths/math.vector";
  56902. import { Mesh } from "babylonjs/Meshes/mesh";
  56903. /**
  56904. * Class containing static functions to help procedurally build meshes
  56905. */
  56906. export class TiledPlaneBuilder {
  56907. /**
  56908. * Creates a tiled plane mesh
  56909. * * The parameter `pattern` will, depending on value, do nothing or
  56910. * * * flip (reflect about central vertical) alternate tiles across and up
  56911. * * * flip every tile on alternate rows
  56912. * * * rotate (180 degs) alternate tiles across and up
  56913. * * * rotate every tile on alternate rows
  56914. * * * flip and rotate alternate tiles across and up
  56915. * * * flip and rotate every tile on alternate rows
  56916. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56917. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56919. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56920. * * 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)
  56921. * * 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)
  56922. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56923. * @param name defines the name of the mesh
  56924. * @param options defines the options used to create the mesh
  56925. * @param scene defines the hosting scene
  56926. * @returns the box mesh
  56927. */
  56928. static CreateTiledPlane(name: string, options: {
  56929. pattern?: number;
  56930. tileSize?: number;
  56931. tileWidth?: number;
  56932. tileHeight?: number;
  56933. size?: number;
  56934. width?: number;
  56935. height?: number;
  56936. alignHorizontal?: number;
  56937. alignVertical?: number;
  56938. sideOrientation?: number;
  56939. frontUVs?: Vector4;
  56940. backUVs?: Vector4;
  56941. updatable?: boolean;
  56942. }, scene?: Nullable<Scene>): Mesh;
  56943. }
  56944. }
  56945. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56946. import { Nullable } from "babylonjs/types";
  56947. import { Scene } from "babylonjs/scene";
  56948. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56949. import { Mesh } from "babylonjs/Meshes/mesh";
  56950. /**
  56951. * Class containing static functions to help procedurally build meshes
  56952. */
  56953. export class TubeBuilder {
  56954. /**
  56955. * Creates a tube mesh.
  56956. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56957. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56958. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56959. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56960. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56961. * * 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)
  56962. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56963. * * 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
  56964. * * 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
  56965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56969. * @param name defines the name of the mesh
  56970. * @param options defines the options used to create the mesh
  56971. * @param scene defines the hosting scene
  56972. * @returns the tube mesh
  56973. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56974. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56975. */
  56976. static CreateTube(name: string, options: {
  56977. path: Vector3[];
  56978. radius?: number;
  56979. tessellation?: number;
  56980. radiusFunction?: {
  56981. (i: number, distance: number): number;
  56982. };
  56983. cap?: number;
  56984. arc?: number;
  56985. updatable?: boolean;
  56986. sideOrientation?: number;
  56987. frontUVs?: Vector4;
  56988. backUVs?: Vector4;
  56989. instance?: Mesh;
  56990. invertUV?: boolean;
  56991. }, scene?: Nullable<Scene>): Mesh;
  56992. }
  56993. }
  56994. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56995. import { Scene } from "babylonjs/scene";
  56996. import { Vector4 } from "babylonjs/Maths/math.vector";
  56997. import { Mesh } from "babylonjs/Meshes/mesh";
  56998. import { Nullable } from "babylonjs/types";
  56999. /**
  57000. * Class containing static functions to help procedurally build meshes
  57001. */
  57002. export class IcoSphereBuilder {
  57003. /**
  57004. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57005. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57006. * * 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`)
  57007. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57008. * * 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
  57009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57012. * @param name defines the name of the mesh
  57013. * @param options defines the options used to create the mesh
  57014. * @param scene defines the hosting scene
  57015. * @returns the icosahedron mesh
  57016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57017. */
  57018. static CreateIcoSphere(name: string, options: {
  57019. radius?: number;
  57020. radiusX?: number;
  57021. radiusY?: number;
  57022. radiusZ?: number;
  57023. flat?: boolean;
  57024. subdivisions?: number;
  57025. sideOrientation?: number;
  57026. frontUVs?: Vector4;
  57027. backUVs?: Vector4;
  57028. updatable?: boolean;
  57029. }, scene?: Nullable<Scene>): Mesh;
  57030. }
  57031. }
  57032. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57033. import { Vector3 } from "babylonjs/Maths/math.vector";
  57034. import { Mesh } from "babylonjs/Meshes/mesh";
  57035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57036. /**
  57037. * Class containing static functions to help procedurally build meshes
  57038. */
  57039. export class DecalBuilder {
  57040. /**
  57041. * Creates a decal mesh.
  57042. * 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
  57043. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57044. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57045. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57046. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57047. * @param name defines the name of the mesh
  57048. * @param sourceMesh defines the mesh where the decal must be applied
  57049. * @param options defines the options used to create the mesh
  57050. * @param scene defines the hosting scene
  57051. * @returns the decal mesh
  57052. * @see https://doc.babylonjs.com/how_to/decals
  57053. */
  57054. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57055. position?: Vector3;
  57056. normal?: Vector3;
  57057. size?: Vector3;
  57058. angle?: number;
  57059. }): Mesh;
  57060. }
  57061. }
  57062. declare module "babylonjs/Meshes/meshBuilder" {
  57063. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57064. import { Nullable } from "babylonjs/types";
  57065. import { Scene } from "babylonjs/scene";
  57066. import { Mesh } from "babylonjs/Meshes/mesh";
  57067. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57068. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57070. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57071. import { Plane } from "babylonjs/Maths/math.plane";
  57072. /**
  57073. * Class containing static functions to help procedurally build meshes
  57074. */
  57075. export class MeshBuilder {
  57076. /**
  57077. * Creates a box mesh
  57078. * * The parameter `size` sets the size (float) of each box side (default 1)
  57079. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57080. * * 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)
  57081. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57085. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57086. * @param name defines the name of the mesh
  57087. * @param options defines the options used to create the mesh
  57088. * @param scene defines the hosting scene
  57089. * @returns the box mesh
  57090. */
  57091. static CreateBox(name: string, options: {
  57092. size?: number;
  57093. width?: number;
  57094. height?: number;
  57095. depth?: number;
  57096. faceUV?: Vector4[];
  57097. faceColors?: Color4[];
  57098. sideOrientation?: number;
  57099. frontUVs?: Vector4;
  57100. backUVs?: Vector4;
  57101. updatable?: boolean;
  57102. }, scene?: Nullable<Scene>): Mesh;
  57103. /**
  57104. * Creates a tiled box mesh
  57105. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57107. * @param name defines the name of the mesh
  57108. * @param options defines the options used to create the mesh
  57109. * @param scene defines the hosting scene
  57110. * @returns the tiled box mesh
  57111. */
  57112. static CreateTiledBox(name: string, options: {
  57113. pattern?: number;
  57114. size?: number;
  57115. width?: number;
  57116. height?: number;
  57117. depth: number;
  57118. tileSize?: number;
  57119. tileWidth?: number;
  57120. tileHeight?: number;
  57121. faceUV?: Vector4[];
  57122. faceColors?: Color4[];
  57123. alignHorizontal?: number;
  57124. alignVertical?: number;
  57125. sideOrientation?: number;
  57126. updatable?: boolean;
  57127. }, scene?: Nullable<Scene>): Mesh;
  57128. /**
  57129. * Creates a sphere mesh
  57130. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57131. * * 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`)
  57132. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57133. * * 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
  57134. * * 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)
  57135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57138. * @param name defines the name of the mesh
  57139. * @param options defines the options used to create the mesh
  57140. * @param scene defines the hosting scene
  57141. * @returns the sphere mesh
  57142. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57143. */
  57144. static CreateSphere(name: string, options: {
  57145. segments?: number;
  57146. diameter?: number;
  57147. diameterX?: number;
  57148. diameterY?: number;
  57149. diameterZ?: number;
  57150. arc?: number;
  57151. slice?: number;
  57152. sideOrientation?: number;
  57153. frontUVs?: Vector4;
  57154. backUVs?: Vector4;
  57155. updatable?: boolean;
  57156. }, scene?: Nullable<Scene>): Mesh;
  57157. /**
  57158. * Creates a plane polygonal mesh. By default, this is a disc
  57159. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57160. * * 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
  57161. * * 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
  57162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57165. * @param name defines the name of the mesh
  57166. * @param options defines the options used to create the mesh
  57167. * @param scene defines the hosting scene
  57168. * @returns the plane polygonal mesh
  57169. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57170. */
  57171. static CreateDisc(name: string, options: {
  57172. radius?: number;
  57173. tessellation?: number;
  57174. arc?: number;
  57175. updatable?: boolean;
  57176. sideOrientation?: number;
  57177. frontUVs?: Vector4;
  57178. backUVs?: Vector4;
  57179. }, scene?: Nullable<Scene>): Mesh;
  57180. /**
  57181. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57182. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57183. * * 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`)
  57184. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57185. * * 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
  57186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57189. * @param name defines the name of the mesh
  57190. * @param options defines the options used to create the mesh
  57191. * @param scene defines the hosting scene
  57192. * @returns the icosahedron mesh
  57193. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57194. */
  57195. static CreateIcoSphere(name: string, options: {
  57196. radius?: number;
  57197. radiusX?: number;
  57198. radiusY?: number;
  57199. radiusZ?: number;
  57200. flat?: boolean;
  57201. subdivisions?: number;
  57202. sideOrientation?: number;
  57203. frontUVs?: Vector4;
  57204. backUVs?: Vector4;
  57205. updatable?: boolean;
  57206. }, scene?: Nullable<Scene>): Mesh;
  57207. /**
  57208. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57209. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57210. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57211. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57212. * * 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
  57213. * * 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
  57214. * * 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
  57215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57218. * * 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
  57219. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57220. * * 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
  57221. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57223. * @param name defines the name of the mesh
  57224. * @param options defines the options used to create the mesh
  57225. * @param scene defines the hosting scene
  57226. * @returns the ribbon mesh
  57227. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57229. */
  57230. static CreateRibbon(name: string, options: {
  57231. pathArray: Vector3[][];
  57232. closeArray?: boolean;
  57233. closePath?: boolean;
  57234. offset?: number;
  57235. updatable?: boolean;
  57236. sideOrientation?: number;
  57237. frontUVs?: Vector4;
  57238. backUVs?: Vector4;
  57239. instance?: Mesh;
  57240. invertUV?: boolean;
  57241. uvs?: Vector2[];
  57242. colors?: Color4[];
  57243. }, scene?: Nullable<Scene>): Mesh;
  57244. /**
  57245. * Creates a cylinder or a cone mesh
  57246. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57247. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57248. * * 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.
  57249. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57250. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57251. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57252. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57253. * * 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).
  57254. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57255. * * 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).
  57256. * * 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
  57257. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57258. * * 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
  57259. * * 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.
  57260. * * If `enclose` is false, a ring surface is one element.
  57261. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57262. * * 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
  57263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57266. * @param name defines the name of the mesh
  57267. * @param options defines the options used to create the mesh
  57268. * @param scene defines the hosting scene
  57269. * @returns the cylinder mesh
  57270. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57271. */
  57272. static CreateCylinder(name: string, options: {
  57273. height?: number;
  57274. diameterTop?: number;
  57275. diameterBottom?: number;
  57276. diameter?: number;
  57277. tessellation?: number;
  57278. subdivisions?: number;
  57279. arc?: number;
  57280. faceColors?: Color4[];
  57281. faceUV?: Vector4[];
  57282. updatable?: boolean;
  57283. hasRings?: boolean;
  57284. enclose?: boolean;
  57285. cap?: number;
  57286. sideOrientation?: number;
  57287. frontUVs?: Vector4;
  57288. backUVs?: Vector4;
  57289. }, scene?: Nullable<Scene>): Mesh;
  57290. /**
  57291. * Creates a torus mesh
  57292. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57293. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57294. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57298. * @param name defines the name of the mesh
  57299. * @param options defines the options used to create the mesh
  57300. * @param scene defines the hosting scene
  57301. * @returns the torus mesh
  57302. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57303. */
  57304. static CreateTorus(name: string, options: {
  57305. diameter?: number;
  57306. thickness?: number;
  57307. tessellation?: number;
  57308. updatable?: boolean;
  57309. sideOrientation?: number;
  57310. frontUVs?: Vector4;
  57311. backUVs?: Vector4;
  57312. }, scene?: Nullable<Scene>): Mesh;
  57313. /**
  57314. * Creates a torus knot mesh
  57315. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57316. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57317. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57318. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57322. * @param name defines the name of the mesh
  57323. * @param options defines the options used to create the mesh
  57324. * @param scene defines the hosting scene
  57325. * @returns the torus knot mesh
  57326. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57327. */
  57328. static CreateTorusKnot(name: string, options: {
  57329. radius?: number;
  57330. tube?: number;
  57331. radialSegments?: number;
  57332. tubularSegments?: number;
  57333. p?: number;
  57334. q?: number;
  57335. updatable?: boolean;
  57336. sideOrientation?: number;
  57337. frontUVs?: Vector4;
  57338. backUVs?: Vector4;
  57339. }, scene?: Nullable<Scene>): Mesh;
  57340. /**
  57341. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57342. * * 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
  57343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57344. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57345. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57346. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57348. * * 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
  57349. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57352. * @param name defines the name of the new line system
  57353. * @param options defines the options used to create the line system
  57354. * @param scene defines the hosting scene
  57355. * @returns a new line system mesh
  57356. */
  57357. static CreateLineSystem(name: string, options: {
  57358. lines: Vector3[][];
  57359. updatable?: boolean;
  57360. instance?: Nullable<LinesMesh>;
  57361. colors?: Nullable<Color4[][]>;
  57362. useVertexAlpha?: boolean;
  57363. }, scene: Nullable<Scene>): LinesMesh;
  57364. /**
  57365. * Creates a line mesh
  57366. * 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
  57367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57368. * * The parameter `points` is an array successive Vector3
  57369. * * 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
  57370. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57372. * * When updating an instance, remember that only point positions can change, not the number of points
  57373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57375. * @param name defines the name of the new line system
  57376. * @param options defines the options used to create the line system
  57377. * @param scene defines the hosting scene
  57378. * @returns a new line mesh
  57379. */
  57380. static CreateLines(name: string, options: {
  57381. points: Vector3[];
  57382. updatable?: boolean;
  57383. instance?: Nullable<LinesMesh>;
  57384. colors?: Color4[];
  57385. useVertexAlpha?: boolean;
  57386. }, scene?: Nullable<Scene>): LinesMesh;
  57387. /**
  57388. * Creates a dashed line mesh
  57389. * * 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
  57390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57391. * * The parameter `points` is an array successive Vector3
  57392. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57393. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57394. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57395. * * 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
  57396. * * When updating an instance, remember that only point positions can change, not the number of points
  57397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57398. * @param name defines the name of the mesh
  57399. * @param options defines the options used to create the mesh
  57400. * @param scene defines the hosting scene
  57401. * @returns the dashed line mesh
  57402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57403. */
  57404. static CreateDashedLines(name: string, options: {
  57405. points: Vector3[];
  57406. dashSize?: number;
  57407. gapSize?: number;
  57408. dashNb?: number;
  57409. updatable?: boolean;
  57410. instance?: LinesMesh;
  57411. }, scene?: Nullable<Scene>): LinesMesh;
  57412. /**
  57413. * 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.
  57414. * * 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.
  57415. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57416. * * 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.
  57417. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57418. * * 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
  57419. * * 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
  57420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57425. * @param name defines the name of the mesh
  57426. * @param options defines the options used to create the mesh
  57427. * @param scene defines the hosting scene
  57428. * @returns the extruded shape mesh
  57429. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57431. */
  57432. static ExtrudeShape(name: string, options: {
  57433. shape: Vector3[];
  57434. path: Vector3[];
  57435. scale?: number;
  57436. rotation?: number;
  57437. cap?: number;
  57438. updatable?: boolean;
  57439. sideOrientation?: number;
  57440. frontUVs?: Vector4;
  57441. backUVs?: Vector4;
  57442. instance?: Mesh;
  57443. invertUV?: boolean;
  57444. }, scene?: Nullable<Scene>): Mesh;
  57445. /**
  57446. * Creates an custom extruded shape mesh.
  57447. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57448. * * 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.
  57449. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57450. * * 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
  57451. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57452. * * 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
  57453. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57454. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57455. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57456. * * 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
  57457. * * 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
  57458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57463. * @param name defines the name of the mesh
  57464. * @param options defines the options used to create the mesh
  57465. * @param scene defines the hosting scene
  57466. * @returns the custom extruded shape mesh
  57467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57468. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57470. */
  57471. static ExtrudeShapeCustom(name: string, options: {
  57472. shape: Vector3[];
  57473. path: Vector3[];
  57474. scaleFunction?: any;
  57475. rotationFunction?: any;
  57476. ribbonCloseArray?: boolean;
  57477. ribbonClosePath?: boolean;
  57478. cap?: number;
  57479. updatable?: boolean;
  57480. sideOrientation?: number;
  57481. frontUVs?: Vector4;
  57482. backUVs?: Vector4;
  57483. instance?: Mesh;
  57484. invertUV?: boolean;
  57485. }, scene?: Nullable<Scene>): Mesh;
  57486. /**
  57487. * Creates lathe mesh.
  57488. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57489. * * 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
  57490. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57491. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57492. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57493. * * 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
  57494. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57495. * * 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
  57496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57500. * @param name defines the name of the mesh
  57501. * @param options defines the options used to create the mesh
  57502. * @param scene defines the hosting scene
  57503. * @returns the lathe mesh
  57504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57505. */
  57506. static CreateLathe(name: string, options: {
  57507. shape: Vector3[];
  57508. radius?: number;
  57509. tessellation?: number;
  57510. clip?: number;
  57511. arc?: number;
  57512. closed?: boolean;
  57513. updatable?: boolean;
  57514. sideOrientation?: number;
  57515. frontUVs?: Vector4;
  57516. backUVs?: Vector4;
  57517. cap?: number;
  57518. invertUV?: boolean;
  57519. }, scene?: Nullable<Scene>): Mesh;
  57520. /**
  57521. * Creates a tiled plane mesh
  57522. * * You can set a limited pattern arrangement with the tiles
  57523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57526. * @param name defines the name of the mesh
  57527. * @param options defines the options used to create the mesh
  57528. * @param scene defines the hosting scene
  57529. * @returns the plane mesh
  57530. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57531. */
  57532. static CreateTiledPlane(name: string, options: {
  57533. pattern?: number;
  57534. tileSize?: number;
  57535. tileWidth?: number;
  57536. tileHeight?: number;
  57537. size?: number;
  57538. width?: number;
  57539. height?: number;
  57540. alignHorizontal?: number;
  57541. alignVertical?: number;
  57542. sideOrientation?: number;
  57543. frontUVs?: Vector4;
  57544. backUVs?: Vector4;
  57545. updatable?: boolean;
  57546. }, scene?: Nullable<Scene>): Mesh;
  57547. /**
  57548. * Creates a plane mesh
  57549. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57550. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57551. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57555. * @param name defines the name of the mesh
  57556. * @param options defines the options used to create the mesh
  57557. * @param scene defines the hosting scene
  57558. * @returns the plane mesh
  57559. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57560. */
  57561. static CreatePlane(name: string, options: {
  57562. size?: number;
  57563. width?: number;
  57564. height?: number;
  57565. sideOrientation?: number;
  57566. frontUVs?: Vector4;
  57567. backUVs?: Vector4;
  57568. updatable?: boolean;
  57569. sourcePlane?: Plane;
  57570. }, scene?: Nullable<Scene>): Mesh;
  57571. /**
  57572. * Creates a ground mesh
  57573. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57574. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57576. * @param name defines the name of the mesh
  57577. * @param options defines the options used to create the mesh
  57578. * @param scene defines the hosting scene
  57579. * @returns the ground mesh
  57580. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57581. */
  57582. static CreateGround(name: string, options: {
  57583. width?: number;
  57584. height?: number;
  57585. subdivisions?: number;
  57586. subdivisionsX?: number;
  57587. subdivisionsY?: number;
  57588. updatable?: boolean;
  57589. }, scene?: Nullable<Scene>): Mesh;
  57590. /**
  57591. * Creates a tiled ground mesh
  57592. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57593. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57594. * * 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
  57595. * * 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
  57596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57597. * @param name defines the name of the mesh
  57598. * @param options defines the options used to create the mesh
  57599. * @param scene defines the hosting scene
  57600. * @returns the tiled ground mesh
  57601. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57602. */
  57603. static CreateTiledGround(name: string, options: {
  57604. xmin: number;
  57605. zmin: number;
  57606. xmax: number;
  57607. zmax: number;
  57608. subdivisions?: {
  57609. w: number;
  57610. h: number;
  57611. };
  57612. precision?: {
  57613. w: number;
  57614. h: number;
  57615. };
  57616. updatable?: boolean;
  57617. }, scene?: Nullable<Scene>): Mesh;
  57618. /**
  57619. * Creates a ground mesh from a height map
  57620. * * The parameter `url` sets the URL of the height map image resource.
  57621. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57622. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57623. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57624. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57625. * * 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.
  57626. * * 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).
  57627. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57629. * @param name defines the name of the mesh
  57630. * @param url defines the url to the height map
  57631. * @param options defines the options used to create the mesh
  57632. * @param scene defines the hosting scene
  57633. * @returns the ground mesh
  57634. * @see https://doc.babylonjs.com/babylon101/height_map
  57635. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57636. */
  57637. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57638. width?: number;
  57639. height?: number;
  57640. subdivisions?: number;
  57641. minHeight?: number;
  57642. maxHeight?: number;
  57643. colorFilter?: Color3;
  57644. alphaFilter?: number;
  57645. updatable?: boolean;
  57646. onReady?: (mesh: GroundMesh) => void;
  57647. }, scene?: Nullable<Scene>): GroundMesh;
  57648. /**
  57649. * Creates a polygon mesh
  57650. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57651. * * 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
  57652. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57655. * * Remember you can only change the shape positions, not their number when updating a polygon
  57656. * @param name defines the name of the mesh
  57657. * @param options defines the options used to create the mesh
  57658. * @param scene defines the hosting scene
  57659. * @param earcutInjection can be used to inject your own earcut reference
  57660. * @returns the polygon mesh
  57661. */
  57662. static CreatePolygon(name: string, options: {
  57663. shape: Vector3[];
  57664. holes?: Vector3[][];
  57665. depth?: number;
  57666. faceUV?: Vector4[];
  57667. faceColors?: Color4[];
  57668. updatable?: boolean;
  57669. sideOrientation?: number;
  57670. frontUVs?: Vector4;
  57671. backUVs?: Vector4;
  57672. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57673. /**
  57674. * Creates an extruded polygon mesh, with depth in the Y direction.
  57675. * * 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)
  57676. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57677. * @param name defines the name of the mesh
  57678. * @param options defines the options used to create the mesh
  57679. * @param scene defines the hosting scene
  57680. * @param earcutInjection can be used to inject your own earcut reference
  57681. * @returns the polygon mesh
  57682. */
  57683. static ExtrudePolygon(name: string, options: {
  57684. shape: Vector3[];
  57685. holes?: Vector3[][];
  57686. depth?: number;
  57687. faceUV?: Vector4[];
  57688. faceColors?: Color4[];
  57689. updatable?: boolean;
  57690. sideOrientation?: number;
  57691. frontUVs?: Vector4;
  57692. backUVs?: Vector4;
  57693. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57694. /**
  57695. * Creates a tube mesh.
  57696. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57697. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57698. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57699. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57700. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57701. * * 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)
  57702. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57703. * * 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
  57704. * * 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
  57705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57709. * @param name defines the name of the mesh
  57710. * @param options defines the options used to create the mesh
  57711. * @param scene defines the hosting scene
  57712. * @returns the tube mesh
  57713. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57714. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57715. */
  57716. static CreateTube(name: string, options: {
  57717. path: Vector3[];
  57718. radius?: number;
  57719. tessellation?: number;
  57720. radiusFunction?: {
  57721. (i: number, distance: number): number;
  57722. };
  57723. cap?: number;
  57724. arc?: number;
  57725. updatable?: boolean;
  57726. sideOrientation?: number;
  57727. frontUVs?: Vector4;
  57728. backUVs?: Vector4;
  57729. instance?: Mesh;
  57730. invertUV?: boolean;
  57731. }, scene?: Nullable<Scene>): Mesh;
  57732. /**
  57733. * Creates a polyhedron mesh
  57734. * * 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
  57735. * * The parameter `size` (positive float, default 1) sets the polygon size
  57736. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57737. * * 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`
  57738. * * 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
  57739. * * 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)`)
  57740. * * 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
  57741. * * 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
  57742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57745. * @param name defines the name of the mesh
  57746. * @param options defines the options used to create the mesh
  57747. * @param scene defines the hosting scene
  57748. * @returns the polyhedron mesh
  57749. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57750. */
  57751. static CreatePolyhedron(name: string, options: {
  57752. type?: number;
  57753. size?: number;
  57754. sizeX?: number;
  57755. sizeY?: number;
  57756. sizeZ?: number;
  57757. custom?: any;
  57758. faceUV?: Vector4[];
  57759. faceColors?: Color4[];
  57760. flat?: boolean;
  57761. updatable?: boolean;
  57762. sideOrientation?: number;
  57763. frontUVs?: Vector4;
  57764. backUVs?: Vector4;
  57765. }, scene?: Nullable<Scene>): Mesh;
  57766. /**
  57767. * Creates a decal mesh.
  57768. * 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
  57769. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57770. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57771. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57772. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57773. * @param name defines the name of the mesh
  57774. * @param sourceMesh defines the mesh where the decal must be applied
  57775. * @param options defines the options used to create the mesh
  57776. * @param scene defines the hosting scene
  57777. * @returns the decal mesh
  57778. * @see https://doc.babylonjs.com/how_to/decals
  57779. */
  57780. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57781. position?: Vector3;
  57782. normal?: Vector3;
  57783. size?: Vector3;
  57784. angle?: number;
  57785. }): Mesh;
  57786. }
  57787. }
  57788. declare module "babylonjs/Meshes/meshSimplification" {
  57789. import { Mesh } from "babylonjs/Meshes/mesh";
  57790. /**
  57791. * A simplifier interface for future simplification implementations
  57792. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57793. */
  57794. export interface ISimplifier {
  57795. /**
  57796. * Simplification of a given mesh according to the given settings.
  57797. * Since this requires computation, it is assumed that the function runs async.
  57798. * @param settings The settings of the simplification, including quality and distance
  57799. * @param successCallback A callback that will be called after the mesh was simplified.
  57800. * @param errorCallback in case of an error, this callback will be called. optional.
  57801. */
  57802. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57803. }
  57804. /**
  57805. * Expected simplification settings.
  57806. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57807. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57808. */
  57809. export interface ISimplificationSettings {
  57810. /**
  57811. * Gets or sets the expected quality
  57812. */
  57813. quality: number;
  57814. /**
  57815. * Gets or sets the distance when this optimized version should be used
  57816. */
  57817. distance: number;
  57818. /**
  57819. * Gets an already optimized mesh
  57820. */
  57821. optimizeMesh?: boolean;
  57822. }
  57823. /**
  57824. * Class used to specify simplification options
  57825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57826. */
  57827. export class SimplificationSettings implements ISimplificationSettings {
  57828. /** expected quality */
  57829. quality: number;
  57830. /** distance when this optimized version should be used */
  57831. distance: number;
  57832. /** already optimized mesh */
  57833. optimizeMesh?: boolean | undefined;
  57834. /**
  57835. * Creates a SimplificationSettings
  57836. * @param quality expected quality
  57837. * @param distance distance when this optimized version should be used
  57838. * @param optimizeMesh already optimized mesh
  57839. */
  57840. constructor(
  57841. /** expected quality */
  57842. quality: number,
  57843. /** distance when this optimized version should be used */
  57844. distance: number,
  57845. /** already optimized mesh */
  57846. optimizeMesh?: boolean | undefined);
  57847. }
  57848. /**
  57849. * Interface used to define a simplification task
  57850. */
  57851. export interface ISimplificationTask {
  57852. /**
  57853. * Array of settings
  57854. */
  57855. settings: Array<ISimplificationSettings>;
  57856. /**
  57857. * Simplification type
  57858. */
  57859. simplificationType: SimplificationType;
  57860. /**
  57861. * Mesh to simplify
  57862. */
  57863. mesh: Mesh;
  57864. /**
  57865. * Callback called on success
  57866. */
  57867. successCallback?: () => void;
  57868. /**
  57869. * Defines if parallel processing can be used
  57870. */
  57871. parallelProcessing: boolean;
  57872. }
  57873. /**
  57874. * Queue used to order the simplification tasks
  57875. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57876. */
  57877. export class SimplificationQueue {
  57878. private _simplificationArray;
  57879. /**
  57880. * Gets a boolean indicating that the process is still running
  57881. */
  57882. running: boolean;
  57883. /**
  57884. * Creates a new queue
  57885. */
  57886. constructor();
  57887. /**
  57888. * Adds a new simplification task
  57889. * @param task defines a task to add
  57890. */
  57891. addTask(task: ISimplificationTask): void;
  57892. /**
  57893. * Execute next task
  57894. */
  57895. executeNext(): void;
  57896. /**
  57897. * Execute a simplification task
  57898. * @param task defines the task to run
  57899. */
  57900. runSimplification(task: ISimplificationTask): void;
  57901. private getSimplifier;
  57902. }
  57903. /**
  57904. * The implemented types of simplification
  57905. * At the moment only Quadratic Error Decimation is implemented
  57906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57907. */
  57908. export enum SimplificationType {
  57909. /** Quadratic error decimation */
  57910. QUADRATIC = 0
  57911. }
  57912. }
  57913. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57914. import { Scene } from "babylonjs/scene";
  57915. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57916. import { ISceneComponent } from "babylonjs/sceneComponent";
  57917. module "babylonjs/scene" {
  57918. interface Scene {
  57919. /** @hidden (Backing field) */
  57920. _simplificationQueue: SimplificationQueue;
  57921. /**
  57922. * Gets or sets the simplification queue attached to the scene
  57923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57924. */
  57925. simplificationQueue: SimplificationQueue;
  57926. }
  57927. }
  57928. module "babylonjs/Meshes/mesh" {
  57929. interface Mesh {
  57930. /**
  57931. * Simplify the mesh according to the given array of settings.
  57932. * Function will return immediately and will simplify async
  57933. * @param settings a collection of simplification settings
  57934. * @param parallelProcessing should all levels calculate parallel or one after the other
  57935. * @param simplificationType the type of simplification to run
  57936. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57937. * @returns the current mesh
  57938. */
  57939. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57940. }
  57941. }
  57942. /**
  57943. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57944. * created in a scene
  57945. */
  57946. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57947. /**
  57948. * The component name helpfull to identify the component in the list of scene components.
  57949. */
  57950. readonly name: string;
  57951. /**
  57952. * The scene the component belongs to.
  57953. */
  57954. scene: Scene;
  57955. /**
  57956. * Creates a new instance of the component for the given scene
  57957. * @param scene Defines the scene to register the component in
  57958. */
  57959. constructor(scene: Scene);
  57960. /**
  57961. * Registers the component in a given scene
  57962. */
  57963. register(): void;
  57964. /**
  57965. * Rebuilds the elements related to this component in case of
  57966. * context lost for instance.
  57967. */
  57968. rebuild(): void;
  57969. /**
  57970. * Disposes the component and the associated ressources
  57971. */
  57972. dispose(): void;
  57973. private _beforeCameraUpdate;
  57974. }
  57975. }
  57976. declare module "babylonjs/Meshes/Builders/index" {
  57977. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57978. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57979. export * from "babylonjs/Meshes/Builders/discBuilder";
  57980. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57981. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57982. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57983. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57984. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57985. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57986. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57987. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57988. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57989. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57990. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57991. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57992. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57993. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57994. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57995. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57996. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57997. }
  57998. declare module "babylonjs/Meshes/index" {
  57999. export * from "babylonjs/Meshes/abstractMesh";
  58000. export * from "babylonjs/Meshes/buffer";
  58001. export * from "babylonjs/Meshes/Compression/index";
  58002. export * from "babylonjs/Meshes/csg";
  58003. export * from "babylonjs/Meshes/geometry";
  58004. export * from "babylonjs/Meshes/groundMesh";
  58005. export * from "babylonjs/Meshes/trailMesh";
  58006. export * from "babylonjs/Meshes/instancedMesh";
  58007. export * from "babylonjs/Meshes/linesMesh";
  58008. export * from "babylonjs/Meshes/mesh";
  58009. export * from "babylonjs/Meshes/mesh.vertexData";
  58010. export * from "babylonjs/Meshes/meshBuilder";
  58011. export * from "babylonjs/Meshes/meshSimplification";
  58012. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58013. export * from "babylonjs/Meshes/polygonMesh";
  58014. export * from "babylonjs/Meshes/subMesh";
  58015. export * from "babylonjs/Meshes/meshLODLevel";
  58016. export * from "babylonjs/Meshes/transformNode";
  58017. export * from "babylonjs/Meshes/Builders/index";
  58018. export * from "babylonjs/Meshes/dataBuffer";
  58019. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58020. }
  58021. declare module "babylonjs/Morph/index" {
  58022. export * from "babylonjs/Morph/morphTarget";
  58023. export * from "babylonjs/Morph/morphTargetManager";
  58024. }
  58025. declare module "babylonjs/Navigation/INavigationEngine" {
  58026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58027. import { Vector3 } from "babylonjs/Maths/math";
  58028. import { Mesh } from "babylonjs/Meshes/mesh";
  58029. import { Scene } from "babylonjs/scene";
  58030. /**
  58031. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58032. */
  58033. export interface INavigationEnginePlugin {
  58034. /**
  58035. * plugin name
  58036. */
  58037. name: string;
  58038. /**
  58039. * Creates a navigation mesh
  58040. * @param meshes array of all the geometry used to compute the navigatio mesh
  58041. * @param parameters bunch of parameters used to filter geometry
  58042. */
  58043. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58044. /**
  58045. * Create a navigation mesh debug mesh
  58046. * @param scene is where the mesh will be added
  58047. * @returns debug display mesh
  58048. */
  58049. createDebugNavMesh(scene: Scene): Mesh;
  58050. /**
  58051. * Get a navigation mesh constrained position, closest to the parameter position
  58052. * @param position world position
  58053. * @returns the closest point to position constrained by the navigation mesh
  58054. */
  58055. getClosestPoint(position: Vector3): Vector3;
  58056. /**
  58057. * Get a navigation mesh constrained position, within a particular radius
  58058. * @param position world position
  58059. * @param maxRadius the maximum distance to the constrained world position
  58060. * @returns the closest point to position constrained by the navigation mesh
  58061. */
  58062. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58063. /**
  58064. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58065. * @param start world position
  58066. * @param end world position
  58067. * @returns array containing world position composing the path
  58068. */
  58069. computePath(start: Vector3, end: Vector3): Vector3[];
  58070. /**
  58071. * If this plugin is supported
  58072. * @returns true if plugin is supported
  58073. */
  58074. isSupported(): boolean;
  58075. /**
  58076. * Create a new Crowd so you can add agents
  58077. * @param maxAgents the maximum agent count in the crowd
  58078. * @param maxAgentRadius the maximum radius an agent can have
  58079. * @param scene to attach the crowd to
  58080. * @returns the crowd you can add agents to
  58081. */
  58082. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58083. /**
  58084. * Release all resources
  58085. */
  58086. dispose(): void;
  58087. }
  58088. /**
  58089. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58090. */
  58091. export interface ICrowd {
  58092. /**
  58093. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58094. * You can attach anything to that node. The node position is updated in the scene update tick.
  58095. * @param pos world position that will be constrained by the navigation mesh
  58096. * @param parameters agent parameters
  58097. * @param transform hooked to the agent that will be update by the scene
  58098. * @returns agent index
  58099. */
  58100. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58101. /**
  58102. * Returns the agent position in world space
  58103. * @param index agent index returned by addAgent
  58104. * @returns world space position
  58105. */
  58106. getAgentPosition(index: number): Vector3;
  58107. /**
  58108. * Gets the agent velocity in world space
  58109. * @param index agent index returned by addAgent
  58110. * @returns world space velocity
  58111. */
  58112. getAgentVelocity(index: number): Vector3;
  58113. /**
  58114. * remove a particular agent previously created
  58115. * @param index agent index returned by addAgent
  58116. */
  58117. removeAgent(index: number): void;
  58118. /**
  58119. * get the list of all agents attached to this crowd
  58120. * @returns list of agent indices
  58121. */
  58122. getAgents(): number[];
  58123. /**
  58124. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58125. * @param deltaTime in seconds
  58126. */
  58127. update(deltaTime: number): void;
  58128. /**
  58129. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58130. * @param index agent index returned by addAgent
  58131. * @param destination targeted world position
  58132. */
  58133. agentGoto(index: number, destination: Vector3): void;
  58134. /**
  58135. * Release all resources
  58136. */
  58137. dispose(): void;
  58138. }
  58139. /**
  58140. * Configures an agent
  58141. */
  58142. export interface IAgentParameters {
  58143. /**
  58144. * Agent radius. [Limit: >= 0]
  58145. */
  58146. radius: number;
  58147. /**
  58148. * Agent height. [Limit: > 0]
  58149. */
  58150. height: number;
  58151. /**
  58152. * Maximum allowed acceleration. [Limit: >= 0]
  58153. */
  58154. maxAcceleration: number;
  58155. /**
  58156. * Maximum allowed speed. [Limit: >= 0]
  58157. */
  58158. maxSpeed: number;
  58159. /**
  58160. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58161. */
  58162. collisionQueryRange: number;
  58163. /**
  58164. * The path visibility optimization range. [Limit: > 0]
  58165. */
  58166. pathOptimizationRange: number;
  58167. /**
  58168. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58169. */
  58170. separationWeight: number;
  58171. }
  58172. /**
  58173. * Configures the navigation mesh creation
  58174. */
  58175. export interface INavMeshParameters {
  58176. /**
  58177. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58178. */
  58179. cs: number;
  58180. /**
  58181. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58182. */
  58183. ch: number;
  58184. /**
  58185. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58186. */
  58187. walkableSlopeAngle: number;
  58188. /**
  58189. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58190. * be considered walkable. [Limit: >= 3] [Units: vx]
  58191. */
  58192. walkableHeight: number;
  58193. /**
  58194. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58195. */
  58196. walkableClimb: number;
  58197. /**
  58198. * The distance to erode/shrink the walkable area of the heightfield away from
  58199. * obstructions. [Limit: >=0] [Units: vx]
  58200. */
  58201. walkableRadius: number;
  58202. /**
  58203. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58204. */
  58205. maxEdgeLen: number;
  58206. /**
  58207. * The maximum distance a simplfied contour's border edges should deviate
  58208. * the original raw contour. [Limit: >=0] [Units: vx]
  58209. */
  58210. maxSimplificationError: number;
  58211. /**
  58212. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58213. */
  58214. minRegionArea: number;
  58215. /**
  58216. * Any regions with a span count smaller than this value will, if possible,
  58217. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58218. */
  58219. mergeRegionArea: number;
  58220. /**
  58221. * The maximum number of vertices allowed for polygons generated during the
  58222. * contour to polygon conversion process. [Limit: >= 3]
  58223. */
  58224. maxVertsPerPoly: number;
  58225. /**
  58226. * Sets the sampling distance to use when generating the detail mesh.
  58227. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58228. */
  58229. detailSampleDist: number;
  58230. /**
  58231. * The maximum distance the detail mesh surface should deviate from heightfield
  58232. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58233. */
  58234. detailSampleMaxError: number;
  58235. }
  58236. }
  58237. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58238. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58239. import { Mesh } from "babylonjs/Meshes/mesh";
  58240. import { Scene } from "babylonjs/scene";
  58241. import { Vector3 } from "babylonjs/Maths/math";
  58242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58243. /**
  58244. * RecastJS navigation plugin
  58245. */
  58246. export class RecastJSPlugin implements INavigationEnginePlugin {
  58247. /**
  58248. * Reference to the Recast library
  58249. */
  58250. bjsRECAST: any;
  58251. /**
  58252. * plugin name
  58253. */
  58254. name: string;
  58255. /**
  58256. * the first navmesh created. We might extend this to support multiple navmeshes
  58257. */
  58258. navMesh: any;
  58259. /**
  58260. * Initializes the recastJS plugin
  58261. * @param recastInjection can be used to inject your own recast reference
  58262. */
  58263. constructor(recastInjection?: any);
  58264. /**
  58265. * Creates a navigation mesh
  58266. * @param meshes array of all the geometry used to compute the navigatio mesh
  58267. * @param parameters bunch of parameters used to filter geometry
  58268. */
  58269. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58270. /**
  58271. * Create a navigation mesh debug mesh
  58272. * @param scene is where the mesh will be added
  58273. * @returns debug display mesh
  58274. */
  58275. createDebugNavMesh(scene: Scene): Mesh;
  58276. /**
  58277. * Get a navigation mesh constrained position, closest to the parameter position
  58278. * @param position world position
  58279. * @returns the closest point to position constrained by the navigation mesh
  58280. */
  58281. getClosestPoint(position: Vector3): Vector3;
  58282. /**
  58283. * Get a navigation mesh constrained position, within a particular radius
  58284. * @param position world position
  58285. * @param maxRadius the maximum distance to the constrained world position
  58286. * @returns the closest point to position constrained by the navigation mesh
  58287. */
  58288. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58289. /**
  58290. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58291. * @param start world position
  58292. * @param end world position
  58293. * @returns array containing world position composing the path
  58294. */
  58295. computePath(start: Vector3, end: Vector3): Vector3[];
  58296. /**
  58297. * Create a new Crowd so you can add agents
  58298. * @param maxAgents the maximum agent count in the crowd
  58299. * @param maxAgentRadius the maximum radius an agent can have
  58300. * @param scene to attach the crowd to
  58301. * @returns the crowd you can add agents to
  58302. */
  58303. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58304. /**
  58305. * Disposes
  58306. */
  58307. dispose(): void;
  58308. /**
  58309. * If this plugin is supported
  58310. * @returns true if plugin is supported
  58311. */
  58312. isSupported(): boolean;
  58313. }
  58314. /**
  58315. * Recast detour crowd implementation
  58316. */
  58317. export class RecastJSCrowd implements ICrowd {
  58318. /**
  58319. * Recast/detour plugin
  58320. */
  58321. bjsRECASTPlugin: RecastJSPlugin;
  58322. /**
  58323. * Link to the detour crowd
  58324. */
  58325. recastCrowd: any;
  58326. /**
  58327. * One transform per agent
  58328. */
  58329. transforms: TransformNode[];
  58330. /**
  58331. * All agents created
  58332. */
  58333. agents: number[];
  58334. /**
  58335. * Link to the scene is kept to unregister the crowd from the scene
  58336. */
  58337. private _scene;
  58338. /**
  58339. * Observer for crowd updates
  58340. */
  58341. private _onBeforeAnimationsObserver;
  58342. /**
  58343. * Constructor
  58344. * @param plugin recastJS plugin
  58345. * @param maxAgents the maximum agent count in the crowd
  58346. * @param maxAgentRadius the maximum radius an agent can have
  58347. * @param scene to attach the crowd to
  58348. * @returns the crowd you can add agents to
  58349. */
  58350. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58351. /**
  58352. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58353. * You can attach anything to that node. The node position is updated in the scene update tick.
  58354. * @param pos world position that will be constrained by the navigation mesh
  58355. * @param parameters agent parameters
  58356. * @param transform hooked to the agent that will be update by the scene
  58357. * @returns agent index
  58358. */
  58359. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58360. /**
  58361. * Returns the agent position in world space
  58362. * @param index agent index returned by addAgent
  58363. * @returns world space position
  58364. */
  58365. getAgentPosition(index: number): Vector3;
  58366. /**
  58367. * Returns the agent velocity in world space
  58368. * @param index agent index returned by addAgent
  58369. * @returns world space velocity
  58370. */
  58371. getAgentVelocity(index: number): Vector3;
  58372. /**
  58373. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58374. * @param index agent index returned by addAgent
  58375. * @param destination targeted world position
  58376. */
  58377. agentGoto(index: number, destination: Vector3): void;
  58378. /**
  58379. * remove a particular agent previously created
  58380. * @param index agent index returned by addAgent
  58381. */
  58382. removeAgent(index: number): void;
  58383. /**
  58384. * get the list of all agents attached to this crowd
  58385. * @returns list of agent indices
  58386. */
  58387. getAgents(): number[];
  58388. /**
  58389. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58390. * @param deltaTime in seconds
  58391. */
  58392. update(deltaTime: number): void;
  58393. /**
  58394. * Release all resources
  58395. */
  58396. dispose(): void;
  58397. }
  58398. }
  58399. declare module "babylonjs/Navigation/Plugins/index" {
  58400. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58401. }
  58402. declare module "babylonjs/Navigation/index" {
  58403. export * from "babylonjs/Navigation/INavigationEngine";
  58404. export * from "babylonjs/Navigation/Plugins/index";
  58405. }
  58406. declare module "babylonjs/Offline/database" {
  58407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58408. /**
  58409. * Class used to enable access to IndexedDB
  58410. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58411. */
  58412. export class Database implements IOfflineProvider {
  58413. private _callbackManifestChecked;
  58414. private _currentSceneUrl;
  58415. private _db;
  58416. private _enableSceneOffline;
  58417. private _enableTexturesOffline;
  58418. private _manifestVersionFound;
  58419. private _mustUpdateRessources;
  58420. private _hasReachedQuota;
  58421. private _isSupported;
  58422. private _idbFactory;
  58423. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58424. private static IsUASupportingBlobStorage;
  58425. /**
  58426. * Gets a boolean indicating if Database storate is enabled (off by default)
  58427. */
  58428. static IDBStorageEnabled: boolean;
  58429. /**
  58430. * Gets a boolean indicating if scene must be saved in the database
  58431. */
  58432. readonly enableSceneOffline: boolean;
  58433. /**
  58434. * Gets a boolean indicating if textures must be saved in the database
  58435. */
  58436. readonly enableTexturesOffline: boolean;
  58437. /**
  58438. * Creates a new Database
  58439. * @param urlToScene defines the url to load the scene
  58440. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58441. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58442. */
  58443. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58444. private static _ParseURL;
  58445. private static _ReturnFullUrlLocation;
  58446. private _checkManifestFile;
  58447. /**
  58448. * Open the database and make it available
  58449. * @param successCallback defines the callback to call on success
  58450. * @param errorCallback defines the callback to call on error
  58451. */
  58452. open(successCallback: () => void, errorCallback: () => void): void;
  58453. /**
  58454. * Loads an image from the database
  58455. * @param url defines the url to load from
  58456. * @param image defines the target DOM image
  58457. */
  58458. loadImage(url: string, image: HTMLImageElement): void;
  58459. private _loadImageFromDBAsync;
  58460. private _saveImageIntoDBAsync;
  58461. private _checkVersionFromDB;
  58462. private _loadVersionFromDBAsync;
  58463. private _saveVersionIntoDBAsync;
  58464. /**
  58465. * Loads a file from database
  58466. * @param url defines the URL to load from
  58467. * @param sceneLoaded defines a callback to call on success
  58468. * @param progressCallBack defines a callback to call when progress changed
  58469. * @param errorCallback defines a callback to call on error
  58470. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58471. */
  58472. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58473. private _loadFileAsync;
  58474. private _saveFileAsync;
  58475. /**
  58476. * Validates if xhr data is correct
  58477. * @param xhr defines the request to validate
  58478. * @param dataType defines the expected data type
  58479. * @returns true if data is correct
  58480. */
  58481. private static _ValidateXHRData;
  58482. }
  58483. }
  58484. declare module "babylonjs/Offline/index" {
  58485. export * from "babylonjs/Offline/database";
  58486. export * from "babylonjs/Offline/IOfflineProvider";
  58487. }
  58488. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58489. /** @hidden */
  58490. export var gpuUpdateParticlesPixelShader: {
  58491. name: string;
  58492. shader: string;
  58493. };
  58494. }
  58495. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58496. /** @hidden */
  58497. export var gpuUpdateParticlesVertexShader: {
  58498. name: string;
  58499. shader: string;
  58500. };
  58501. }
  58502. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58503. /** @hidden */
  58504. export var clipPlaneFragmentDeclaration2: {
  58505. name: string;
  58506. shader: string;
  58507. };
  58508. }
  58509. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58511. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58512. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58513. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58514. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58515. /** @hidden */
  58516. export var gpuRenderParticlesPixelShader: {
  58517. name: string;
  58518. shader: string;
  58519. };
  58520. }
  58521. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58522. /** @hidden */
  58523. export var clipPlaneVertexDeclaration2: {
  58524. name: string;
  58525. shader: string;
  58526. };
  58527. }
  58528. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58529. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58531. /** @hidden */
  58532. export var gpuRenderParticlesVertexShader: {
  58533. name: string;
  58534. shader: string;
  58535. };
  58536. }
  58537. declare module "babylonjs/Particles/gpuParticleSystem" {
  58538. import { Nullable } from "babylonjs/types";
  58539. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58540. import { Observable } from "babylonjs/Misc/observable";
  58541. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58542. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58543. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58544. import { Scene, IDisposable } from "babylonjs/scene";
  58545. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58546. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58547. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58548. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58549. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58550. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58551. /**
  58552. * This represents a GPU particle system in Babylon
  58553. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58554. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58555. */
  58556. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58557. /**
  58558. * The layer mask we are rendering the particles through.
  58559. */
  58560. layerMask: number;
  58561. private _capacity;
  58562. private _activeCount;
  58563. private _currentActiveCount;
  58564. private _accumulatedCount;
  58565. private _renderEffect;
  58566. private _updateEffect;
  58567. private _buffer0;
  58568. private _buffer1;
  58569. private _spriteBuffer;
  58570. private _updateVAO;
  58571. private _renderVAO;
  58572. private _targetIndex;
  58573. private _sourceBuffer;
  58574. private _targetBuffer;
  58575. private _engine;
  58576. private _currentRenderId;
  58577. private _started;
  58578. private _stopped;
  58579. private _timeDelta;
  58580. private _randomTexture;
  58581. private _randomTexture2;
  58582. private _attributesStrideSize;
  58583. private _updateEffectOptions;
  58584. private _randomTextureSize;
  58585. private _actualFrame;
  58586. private readonly _rawTextureWidth;
  58587. /**
  58588. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58589. */
  58590. static readonly IsSupported: boolean;
  58591. /**
  58592. * An event triggered when the system is disposed.
  58593. */
  58594. onDisposeObservable: Observable<GPUParticleSystem>;
  58595. /**
  58596. * Gets the maximum number of particles active at the same time.
  58597. * @returns The max number of active particles.
  58598. */
  58599. getCapacity(): number;
  58600. /**
  58601. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58602. * to override the particles.
  58603. */
  58604. forceDepthWrite: boolean;
  58605. /**
  58606. * Gets or set the number of active particles
  58607. */
  58608. activeParticleCount: number;
  58609. private _preWarmDone;
  58610. /**
  58611. * Is this system ready to be used/rendered
  58612. * @return true if the system is ready
  58613. */
  58614. isReady(): boolean;
  58615. /**
  58616. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58617. * @returns True if it has been started, otherwise false.
  58618. */
  58619. isStarted(): boolean;
  58620. /**
  58621. * Starts the particle system and begins to emit
  58622. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58623. */
  58624. start(delay?: number): void;
  58625. /**
  58626. * Stops the particle system.
  58627. */
  58628. stop(): void;
  58629. /**
  58630. * Remove all active particles
  58631. */
  58632. reset(): void;
  58633. /**
  58634. * Returns the string "GPUParticleSystem"
  58635. * @returns a string containing the class name
  58636. */
  58637. getClassName(): string;
  58638. private _colorGradientsTexture;
  58639. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58640. /**
  58641. * Adds a new color gradient
  58642. * @param gradient defines the gradient to use (between 0 and 1)
  58643. * @param color1 defines the color to affect to the specified gradient
  58644. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58645. * @returns the current particle system
  58646. */
  58647. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58648. /**
  58649. * Remove a specific color gradient
  58650. * @param gradient defines the gradient to remove
  58651. * @returns the current particle system
  58652. */
  58653. removeColorGradient(gradient: number): GPUParticleSystem;
  58654. private _angularSpeedGradientsTexture;
  58655. private _sizeGradientsTexture;
  58656. private _velocityGradientsTexture;
  58657. private _limitVelocityGradientsTexture;
  58658. private _dragGradientsTexture;
  58659. private _addFactorGradient;
  58660. /**
  58661. * Adds a new size gradient
  58662. * @param gradient defines the gradient to use (between 0 and 1)
  58663. * @param factor defines the size factor to affect to the specified gradient
  58664. * @returns the current particle system
  58665. */
  58666. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58667. /**
  58668. * Remove a specific size gradient
  58669. * @param gradient defines the gradient to remove
  58670. * @returns the current particle system
  58671. */
  58672. removeSizeGradient(gradient: number): GPUParticleSystem;
  58673. /**
  58674. * Adds a new angular speed gradient
  58675. * @param gradient defines the gradient to use (between 0 and 1)
  58676. * @param factor defines the angular speed to affect to the specified gradient
  58677. * @returns the current particle system
  58678. */
  58679. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58680. /**
  58681. * Remove a specific angular speed gradient
  58682. * @param gradient defines the gradient to remove
  58683. * @returns the current particle system
  58684. */
  58685. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58686. /**
  58687. * Adds a new velocity gradient
  58688. * @param gradient defines the gradient to use (between 0 and 1)
  58689. * @param factor defines the velocity to affect to the specified gradient
  58690. * @returns the current particle system
  58691. */
  58692. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58693. /**
  58694. * Remove a specific velocity gradient
  58695. * @param gradient defines the gradient to remove
  58696. * @returns the current particle system
  58697. */
  58698. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58699. /**
  58700. * Adds a new limit velocity gradient
  58701. * @param gradient defines the gradient to use (between 0 and 1)
  58702. * @param factor defines the limit velocity value to affect to the specified gradient
  58703. * @returns the current particle system
  58704. */
  58705. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58706. /**
  58707. * Remove a specific limit velocity gradient
  58708. * @param gradient defines the gradient to remove
  58709. * @returns the current particle system
  58710. */
  58711. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58712. /**
  58713. * Adds a new drag gradient
  58714. * @param gradient defines the gradient to use (between 0 and 1)
  58715. * @param factor defines the drag value to affect to the specified gradient
  58716. * @returns the current particle system
  58717. */
  58718. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58719. /**
  58720. * Remove a specific drag gradient
  58721. * @param gradient defines the gradient to remove
  58722. * @returns the current particle system
  58723. */
  58724. removeDragGradient(gradient: number): GPUParticleSystem;
  58725. /**
  58726. * Not supported by GPUParticleSystem
  58727. * @param gradient defines the gradient to use (between 0 and 1)
  58728. * @param factor defines the emit rate value to affect to the specified gradient
  58729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58730. * @returns the current particle system
  58731. */
  58732. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58733. /**
  58734. * Not supported by GPUParticleSystem
  58735. * @param gradient defines the gradient to remove
  58736. * @returns the current particle system
  58737. */
  58738. removeEmitRateGradient(gradient: number): IParticleSystem;
  58739. /**
  58740. * Not supported by GPUParticleSystem
  58741. * @param gradient defines the gradient to use (between 0 and 1)
  58742. * @param factor defines the start size value to affect to the specified gradient
  58743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58744. * @returns the current particle system
  58745. */
  58746. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58747. /**
  58748. * Not supported by GPUParticleSystem
  58749. * @param gradient defines the gradient to remove
  58750. * @returns the current particle system
  58751. */
  58752. removeStartSizeGradient(gradient: number): IParticleSystem;
  58753. /**
  58754. * Not supported by GPUParticleSystem
  58755. * @param gradient defines the gradient to use (between 0 and 1)
  58756. * @param min defines the color remap minimal range
  58757. * @param max defines the color remap maximal range
  58758. * @returns the current particle system
  58759. */
  58760. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58761. /**
  58762. * Not supported by GPUParticleSystem
  58763. * @param gradient defines the gradient to remove
  58764. * @returns the current particle system
  58765. */
  58766. removeColorRemapGradient(): IParticleSystem;
  58767. /**
  58768. * Not supported by GPUParticleSystem
  58769. * @param gradient defines the gradient to use (between 0 and 1)
  58770. * @param min defines the alpha remap minimal range
  58771. * @param max defines the alpha remap maximal range
  58772. * @returns the current particle system
  58773. */
  58774. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58775. /**
  58776. * Not supported by GPUParticleSystem
  58777. * @param gradient defines the gradient to remove
  58778. * @returns the current particle system
  58779. */
  58780. removeAlphaRemapGradient(): IParticleSystem;
  58781. /**
  58782. * Not supported by GPUParticleSystem
  58783. * @param gradient defines the gradient to use (between 0 and 1)
  58784. * @param color defines the color to affect to the specified gradient
  58785. * @returns the current particle system
  58786. */
  58787. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58788. /**
  58789. * Not supported by GPUParticleSystem
  58790. * @param gradient defines the gradient to remove
  58791. * @returns the current particle system
  58792. */
  58793. removeRampGradient(): IParticleSystem;
  58794. /**
  58795. * Not supported by GPUParticleSystem
  58796. * @returns the list of ramp gradients
  58797. */
  58798. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58799. /**
  58800. * Not supported by GPUParticleSystem
  58801. * Gets or sets a boolean indicating that ramp gradients must be used
  58802. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58803. */
  58804. useRampGradients: boolean;
  58805. /**
  58806. * Not supported by GPUParticleSystem
  58807. * @param gradient defines the gradient to use (between 0 and 1)
  58808. * @param factor defines the life time factor to affect to the specified gradient
  58809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58810. * @returns the current particle system
  58811. */
  58812. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58813. /**
  58814. * Not supported by GPUParticleSystem
  58815. * @param gradient defines the gradient to remove
  58816. * @returns the current particle system
  58817. */
  58818. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58819. /**
  58820. * Instantiates a GPU particle system.
  58821. * 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.
  58822. * @param name The name of the particle system
  58823. * @param options The options used to create the system
  58824. * @param scene The scene the particle system belongs to
  58825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58826. */
  58827. constructor(name: string, options: Partial<{
  58828. capacity: number;
  58829. randomTextureSize: number;
  58830. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58831. protected _reset(): void;
  58832. private _createUpdateVAO;
  58833. private _createRenderVAO;
  58834. private _initialize;
  58835. /** @hidden */
  58836. _recreateUpdateEffect(): void;
  58837. /** @hidden */
  58838. _recreateRenderEffect(): void;
  58839. /**
  58840. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58841. * @param preWarm defines if we are in the pre-warmimg phase
  58842. */
  58843. animate(preWarm?: boolean): void;
  58844. private _createFactorGradientTexture;
  58845. private _createSizeGradientTexture;
  58846. private _createAngularSpeedGradientTexture;
  58847. private _createVelocityGradientTexture;
  58848. private _createLimitVelocityGradientTexture;
  58849. private _createDragGradientTexture;
  58850. private _createColorGradientTexture;
  58851. /**
  58852. * Renders the particle system in its current state
  58853. * @param preWarm defines if the system should only update the particles but not render them
  58854. * @returns the current number of particles
  58855. */
  58856. render(preWarm?: boolean): number;
  58857. /**
  58858. * Rebuilds the particle system
  58859. */
  58860. rebuild(): void;
  58861. private _releaseBuffers;
  58862. private _releaseVAOs;
  58863. /**
  58864. * Disposes the particle system and free the associated resources
  58865. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58866. */
  58867. dispose(disposeTexture?: boolean): void;
  58868. /**
  58869. * Clones the particle system.
  58870. * @param name The name of the cloned object
  58871. * @param newEmitter The new emitter to use
  58872. * @returns the cloned particle system
  58873. */
  58874. clone(name: string, newEmitter: any): GPUParticleSystem;
  58875. /**
  58876. * Serializes the particle system to a JSON object.
  58877. * @returns the JSON object
  58878. */
  58879. serialize(): any;
  58880. /**
  58881. * Parses a JSON object to create a GPU particle system.
  58882. * @param parsedParticleSystem The JSON object to parse
  58883. * @param scene The scene to create the particle system in
  58884. * @param rootUrl The root url to use to load external dependencies like texture
  58885. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58886. * @returns the parsed GPU particle system
  58887. */
  58888. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58889. }
  58890. }
  58891. declare module "babylonjs/Particles/particleSystemSet" {
  58892. import { Nullable } from "babylonjs/types";
  58893. import { Color3 } from "babylonjs/Maths/math.color";
  58894. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58896. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58897. import { Scene, IDisposable } from "babylonjs/scene";
  58898. /**
  58899. * Represents a set of particle systems working together to create a specific effect
  58900. */
  58901. export class ParticleSystemSet implements IDisposable {
  58902. private _emitterCreationOptions;
  58903. private _emitterNode;
  58904. /**
  58905. * Gets the particle system list
  58906. */
  58907. systems: IParticleSystem[];
  58908. /**
  58909. * Gets the emitter node used with this set
  58910. */
  58911. readonly emitterNode: Nullable<TransformNode>;
  58912. /**
  58913. * Creates a new emitter mesh as a sphere
  58914. * @param options defines the options used to create the sphere
  58915. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58916. * @param scene defines the hosting scene
  58917. */
  58918. setEmitterAsSphere(options: {
  58919. diameter: number;
  58920. segments: number;
  58921. color: Color3;
  58922. }, renderingGroupId: number, scene: Scene): void;
  58923. /**
  58924. * Starts all particle systems of the set
  58925. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58926. */
  58927. start(emitter?: AbstractMesh): void;
  58928. /**
  58929. * Release all associated resources
  58930. */
  58931. dispose(): void;
  58932. /**
  58933. * Serialize the set into a JSON compatible object
  58934. * @returns a JSON compatible representation of the set
  58935. */
  58936. serialize(): any;
  58937. /**
  58938. * Parse a new ParticleSystemSet from a serialized source
  58939. * @param data defines a JSON compatible representation of the set
  58940. * @param scene defines the hosting scene
  58941. * @param gpu defines if we want GPU particles or CPU particles
  58942. * @returns a new ParticleSystemSet
  58943. */
  58944. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58945. }
  58946. }
  58947. declare module "babylonjs/Particles/particleHelper" {
  58948. import { Nullable } from "babylonjs/types";
  58949. import { Scene } from "babylonjs/scene";
  58950. import { Vector3 } from "babylonjs/Maths/math.vector";
  58951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58952. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58953. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58954. /**
  58955. * This class is made for on one-liner static method to help creating particle system set.
  58956. */
  58957. export class ParticleHelper {
  58958. /**
  58959. * Gets or sets base Assets URL
  58960. */
  58961. static BaseAssetsUrl: string;
  58962. /**
  58963. * Create a default particle system that you can tweak
  58964. * @param emitter defines the emitter to use
  58965. * @param capacity defines the system capacity (default is 500 particles)
  58966. * @param scene defines the hosting scene
  58967. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58968. * @returns the new Particle system
  58969. */
  58970. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58971. /**
  58972. * This is the main static method (one-liner) of this helper to create different particle systems
  58973. * @param type This string represents the type to the particle system to create
  58974. * @param scene The scene where the particle system should live
  58975. * @param gpu If the system will use gpu
  58976. * @returns the ParticleSystemSet created
  58977. */
  58978. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58979. /**
  58980. * Static function used to export a particle system to a ParticleSystemSet variable.
  58981. * Please note that the emitter shape is not exported
  58982. * @param systems defines the particle systems to export
  58983. * @returns the created particle system set
  58984. */
  58985. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58986. }
  58987. }
  58988. declare module "babylonjs/Particles/particleSystemComponent" {
  58989. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58990. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58991. import "babylonjs/Shaders/particles.vertex";
  58992. module "babylonjs/Engines/engine" {
  58993. interface Engine {
  58994. /**
  58995. * Create an effect to use with particle systems.
  58996. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58997. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58998. * @param uniformsNames defines a list of attribute names
  58999. * @param samplers defines an array of string used to represent textures
  59000. * @param defines defines the string containing the defines to use to compile the shaders
  59001. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59002. * @param onCompiled defines a function to call when the effect creation is successful
  59003. * @param onError defines a function to call when the effect creation has failed
  59004. * @returns the new Effect
  59005. */
  59006. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59007. }
  59008. }
  59009. module "babylonjs/Meshes/mesh" {
  59010. interface Mesh {
  59011. /**
  59012. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59013. * @returns an array of IParticleSystem
  59014. */
  59015. getEmittedParticleSystems(): IParticleSystem[];
  59016. /**
  59017. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59018. * @returns an array of IParticleSystem
  59019. */
  59020. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59021. }
  59022. }
  59023. /**
  59024. * @hidden
  59025. */
  59026. export var _IDoNeedToBeInTheBuild: number;
  59027. }
  59028. declare module "babylonjs/Particles/index" {
  59029. export * from "babylonjs/Particles/baseParticleSystem";
  59030. export * from "babylonjs/Particles/EmitterTypes/index";
  59031. export * from "babylonjs/Particles/gpuParticleSystem";
  59032. export * from "babylonjs/Particles/IParticleSystem";
  59033. export * from "babylonjs/Particles/particle";
  59034. export * from "babylonjs/Particles/particleHelper";
  59035. export * from "babylonjs/Particles/particleSystem";
  59036. export * from "babylonjs/Particles/particleSystemComponent";
  59037. export * from "babylonjs/Particles/particleSystemSet";
  59038. export * from "babylonjs/Particles/solidParticle";
  59039. export * from "babylonjs/Particles/solidParticleSystem";
  59040. export * from "babylonjs/Particles/subEmitter";
  59041. }
  59042. declare module "babylonjs/Physics/physicsEngineComponent" {
  59043. import { Nullable } from "babylonjs/types";
  59044. import { Observable, Observer } from "babylonjs/Misc/observable";
  59045. import { Vector3 } from "babylonjs/Maths/math.vector";
  59046. import { Mesh } from "babylonjs/Meshes/mesh";
  59047. import { ISceneComponent } from "babylonjs/sceneComponent";
  59048. import { Scene } from "babylonjs/scene";
  59049. import { Node } from "babylonjs/node";
  59050. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59051. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59052. module "babylonjs/scene" {
  59053. interface Scene {
  59054. /** @hidden (Backing field) */
  59055. _physicsEngine: Nullable<IPhysicsEngine>;
  59056. /**
  59057. * Gets the current physics engine
  59058. * @returns a IPhysicsEngine or null if none attached
  59059. */
  59060. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59061. /**
  59062. * Enables physics to the current scene
  59063. * @param gravity defines the scene's gravity for the physics engine
  59064. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59065. * @return a boolean indicating if the physics engine was initialized
  59066. */
  59067. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59068. /**
  59069. * Disables and disposes the physics engine associated with the scene
  59070. */
  59071. disablePhysicsEngine(): void;
  59072. /**
  59073. * Gets a boolean indicating if there is an active physics engine
  59074. * @returns a boolean indicating if there is an active physics engine
  59075. */
  59076. isPhysicsEnabled(): boolean;
  59077. /**
  59078. * Deletes a physics compound impostor
  59079. * @param compound defines the compound to delete
  59080. */
  59081. deleteCompoundImpostor(compound: any): void;
  59082. /**
  59083. * An event triggered when physic simulation is about to be run
  59084. */
  59085. onBeforePhysicsObservable: Observable<Scene>;
  59086. /**
  59087. * An event triggered when physic simulation has been done
  59088. */
  59089. onAfterPhysicsObservable: Observable<Scene>;
  59090. }
  59091. }
  59092. module "babylonjs/Meshes/abstractMesh" {
  59093. interface AbstractMesh {
  59094. /** @hidden */
  59095. _physicsImpostor: Nullable<PhysicsImpostor>;
  59096. /**
  59097. * Gets or sets impostor used for physic simulation
  59098. * @see http://doc.babylonjs.com/features/physics_engine
  59099. */
  59100. physicsImpostor: Nullable<PhysicsImpostor>;
  59101. /**
  59102. * Gets the current physics impostor
  59103. * @see http://doc.babylonjs.com/features/physics_engine
  59104. * @returns a physics impostor or null
  59105. */
  59106. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59107. /** Apply a physic impulse to the mesh
  59108. * @param force defines the force to apply
  59109. * @param contactPoint defines where to apply the force
  59110. * @returns the current mesh
  59111. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59112. */
  59113. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59114. /**
  59115. * Creates a physic joint between two meshes
  59116. * @param otherMesh defines the other mesh to use
  59117. * @param pivot1 defines the pivot to use on this mesh
  59118. * @param pivot2 defines the pivot to use on the other mesh
  59119. * @param options defines additional options (can be plugin dependent)
  59120. * @returns the current mesh
  59121. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59122. */
  59123. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59124. /** @hidden */
  59125. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59126. }
  59127. }
  59128. /**
  59129. * Defines the physics engine scene component responsible to manage a physics engine
  59130. */
  59131. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59132. /**
  59133. * The component name helpful to identify the component in the list of scene components.
  59134. */
  59135. readonly name: string;
  59136. /**
  59137. * The scene the component belongs to.
  59138. */
  59139. scene: Scene;
  59140. /**
  59141. * Creates a new instance of the component for the given scene
  59142. * @param scene Defines the scene to register the component in
  59143. */
  59144. constructor(scene: Scene);
  59145. /**
  59146. * Registers the component in a given scene
  59147. */
  59148. register(): void;
  59149. /**
  59150. * Rebuilds the elements related to this component in case of
  59151. * context lost for instance.
  59152. */
  59153. rebuild(): void;
  59154. /**
  59155. * Disposes the component and the associated ressources
  59156. */
  59157. dispose(): void;
  59158. }
  59159. }
  59160. declare module "babylonjs/Physics/physicsHelper" {
  59161. import { Nullable } from "babylonjs/types";
  59162. import { Vector3 } from "babylonjs/Maths/math.vector";
  59163. import { Mesh } from "babylonjs/Meshes/mesh";
  59164. import { Scene } from "babylonjs/scene";
  59165. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59166. /**
  59167. * A helper for physics simulations
  59168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59169. */
  59170. export class PhysicsHelper {
  59171. private _scene;
  59172. private _physicsEngine;
  59173. /**
  59174. * Initializes the Physics helper
  59175. * @param scene Babylon.js scene
  59176. */
  59177. constructor(scene: Scene);
  59178. /**
  59179. * Applies a radial explosion impulse
  59180. * @param origin the origin of the explosion
  59181. * @param radiusOrEventOptions the radius or the options of radial explosion
  59182. * @param strength the explosion strength
  59183. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59184. * @returns A physics radial explosion event, or null
  59185. */
  59186. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59187. /**
  59188. * Applies a radial explosion force
  59189. * @param origin the origin of the explosion
  59190. * @param radiusOrEventOptions the radius or the options of radial explosion
  59191. * @param strength the explosion strength
  59192. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59193. * @returns A physics radial explosion event, or null
  59194. */
  59195. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59196. /**
  59197. * Creates a gravitational field
  59198. * @param origin the origin of the explosion
  59199. * @param radiusOrEventOptions the radius or the options of radial explosion
  59200. * @param strength the explosion strength
  59201. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59202. * @returns A physics gravitational field event, or null
  59203. */
  59204. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59205. /**
  59206. * Creates a physics updraft event
  59207. * @param origin the origin of the updraft
  59208. * @param radiusOrEventOptions the radius or the options of the updraft
  59209. * @param strength the strength of the updraft
  59210. * @param height the height of the updraft
  59211. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59212. * @returns A physics updraft event, or null
  59213. */
  59214. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59215. /**
  59216. * Creates a physics vortex event
  59217. * @param origin the of the vortex
  59218. * @param radiusOrEventOptions the radius or the options of the vortex
  59219. * @param strength the strength of the vortex
  59220. * @param height the height of the vortex
  59221. * @returns a Physics vortex event, or null
  59222. * A physics vortex event or null
  59223. */
  59224. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59225. }
  59226. /**
  59227. * Represents a physics radial explosion event
  59228. */
  59229. class PhysicsRadialExplosionEvent {
  59230. private _scene;
  59231. private _options;
  59232. private _sphere;
  59233. private _dataFetched;
  59234. /**
  59235. * Initializes a radial explosioin event
  59236. * @param _scene BabylonJS scene
  59237. * @param _options The options for the vortex event
  59238. */
  59239. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59240. /**
  59241. * Returns the data related to the radial explosion event (sphere).
  59242. * @returns The radial explosion event data
  59243. */
  59244. getData(): PhysicsRadialExplosionEventData;
  59245. /**
  59246. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59247. * @param impostor A physics imposter
  59248. * @param origin the origin of the explosion
  59249. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59250. */
  59251. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59252. /**
  59253. * Triggers affecterd impostors callbacks
  59254. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59255. */
  59256. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59257. /**
  59258. * Disposes the sphere.
  59259. * @param force Specifies if the sphere should be disposed by force
  59260. */
  59261. dispose(force?: boolean): void;
  59262. /*** Helpers ***/
  59263. private _prepareSphere;
  59264. private _intersectsWithSphere;
  59265. }
  59266. /**
  59267. * Represents a gravitational field event
  59268. */
  59269. class PhysicsGravitationalFieldEvent {
  59270. private _physicsHelper;
  59271. private _scene;
  59272. private _origin;
  59273. private _options;
  59274. private _tickCallback;
  59275. private _sphere;
  59276. private _dataFetched;
  59277. /**
  59278. * Initializes the physics gravitational field event
  59279. * @param _physicsHelper A physics helper
  59280. * @param _scene BabylonJS scene
  59281. * @param _origin The origin position of the gravitational field event
  59282. * @param _options The options for the vortex event
  59283. */
  59284. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59285. /**
  59286. * Returns the data related to the gravitational field event (sphere).
  59287. * @returns A gravitational field event
  59288. */
  59289. getData(): PhysicsGravitationalFieldEventData;
  59290. /**
  59291. * Enables the gravitational field.
  59292. */
  59293. enable(): void;
  59294. /**
  59295. * Disables the gravitational field.
  59296. */
  59297. disable(): void;
  59298. /**
  59299. * Disposes the sphere.
  59300. * @param force The force to dispose from the gravitational field event
  59301. */
  59302. dispose(force?: boolean): void;
  59303. private _tick;
  59304. }
  59305. /**
  59306. * Represents a physics updraft event
  59307. */
  59308. class PhysicsUpdraftEvent {
  59309. private _scene;
  59310. private _origin;
  59311. private _options;
  59312. private _physicsEngine;
  59313. private _originTop;
  59314. private _originDirection;
  59315. private _tickCallback;
  59316. private _cylinder;
  59317. private _cylinderPosition;
  59318. private _dataFetched;
  59319. /**
  59320. * Initializes the physics updraft event
  59321. * @param _scene BabylonJS scene
  59322. * @param _origin The origin position of the updraft
  59323. * @param _options The options for the updraft event
  59324. */
  59325. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59326. /**
  59327. * Returns the data related to the updraft event (cylinder).
  59328. * @returns A physics updraft event
  59329. */
  59330. getData(): PhysicsUpdraftEventData;
  59331. /**
  59332. * Enables the updraft.
  59333. */
  59334. enable(): void;
  59335. /**
  59336. * Disables the updraft.
  59337. */
  59338. disable(): void;
  59339. /**
  59340. * Disposes the cylinder.
  59341. * @param force Specifies if the updraft should be disposed by force
  59342. */
  59343. dispose(force?: boolean): void;
  59344. private getImpostorHitData;
  59345. private _tick;
  59346. /*** Helpers ***/
  59347. private _prepareCylinder;
  59348. private _intersectsWithCylinder;
  59349. }
  59350. /**
  59351. * Represents a physics vortex event
  59352. */
  59353. class PhysicsVortexEvent {
  59354. private _scene;
  59355. private _origin;
  59356. private _options;
  59357. private _physicsEngine;
  59358. private _originTop;
  59359. private _tickCallback;
  59360. private _cylinder;
  59361. private _cylinderPosition;
  59362. private _dataFetched;
  59363. /**
  59364. * Initializes the physics vortex event
  59365. * @param _scene The BabylonJS scene
  59366. * @param _origin The origin position of the vortex
  59367. * @param _options The options for the vortex event
  59368. */
  59369. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59370. /**
  59371. * Returns the data related to the vortex event (cylinder).
  59372. * @returns The physics vortex event data
  59373. */
  59374. getData(): PhysicsVortexEventData;
  59375. /**
  59376. * Enables the vortex.
  59377. */
  59378. enable(): void;
  59379. /**
  59380. * Disables the cortex.
  59381. */
  59382. disable(): void;
  59383. /**
  59384. * Disposes the sphere.
  59385. * @param force
  59386. */
  59387. dispose(force?: boolean): void;
  59388. private getImpostorHitData;
  59389. private _tick;
  59390. /*** Helpers ***/
  59391. private _prepareCylinder;
  59392. private _intersectsWithCylinder;
  59393. }
  59394. /**
  59395. * Options fot the radial explosion event
  59396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59397. */
  59398. export class PhysicsRadialExplosionEventOptions {
  59399. /**
  59400. * The radius of the sphere for the radial explosion.
  59401. */
  59402. radius: number;
  59403. /**
  59404. * The strenth of the explosion.
  59405. */
  59406. strength: number;
  59407. /**
  59408. * The strenght of the force in correspondence to the distance of the affected object
  59409. */
  59410. falloff: PhysicsRadialImpulseFalloff;
  59411. /**
  59412. * Sphere options for the radial explosion.
  59413. */
  59414. sphere: {
  59415. segments: number;
  59416. diameter: number;
  59417. };
  59418. /**
  59419. * Sphere options for the radial explosion.
  59420. */
  59421. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59422. }
  59423. /**
  59424. * Options fot the updraft event
  59425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59426. */
  59427. export class PhysicsUpdraftEventOptions {
  59428. /**
  59429. * The radius of the cylinder for the vortex
  59430. */
  59431. radius: number;
  59432. /**
  59433. * The strenth of the updraft.
  59434. */
  59435. strength: number;
  59436. /**
  59437. * The height of the cylinder for the updraft.
  59438. */
  59439. height: number;
  59440. /**
  59441. * The mode for the the updraft.
  59442. */
  59443. updraftMode: PhysicsUpdraftMode;
  59444. }
  59445. /**
  59446. * Options fot the vortex event
  59447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59448. */
  59449. export class PhysicsVortexEventOptions {
  59450. /**
  59451. * The radius of the cylinder for the vortex
  59452. */
  59453. radius: number;
  59454. /**
  59455. * The strenth of the vortex.
  59456. */
  59457. strength: number;
  59458. /**
  59459. * The height of the cylinder for the vortex.
  59460. */
  59461. height: number;
  59462. /**
  59463. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59464. */
  59465. centripetalForceThreshold: number;
  59466. /**
  59467. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59468. */
  59469. centripetalForceMultiplier: number;
  59470. /**
  59471. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59472. */
  59473. centrifugalForceMultiplier: number;
  59474. /**
  59475. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59476. */
  59477. updraftForceMultiplier: number;
  59478. }
  59479. /**
  59480. * The strenght of the force in correspondence to the distance of the affected object
  59481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59482. */
  59483. export enum PhysicsRadialImpulseFalloff {
  59484. /** Defines that impulse is constant in strength across it's whole radius */
  59485. Constant = 0,
  59486. /** Defines that impulse gets weaker if it's further from the origin */
  59487. Linear = 1
  59488. }
  59489. /**
  59490. * The strength of the force in correspondence to the distance of the affected object
  59491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59492. */
  59493. export enum PhysicsUpdraftMode {
  59494. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59495. Center = 0,
  59496. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59497. Perpendicular = 1
  59498. }
  59499. /**
  59500. * Interface for a physics hit data
  59501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59502. */
  59503. export interface PhysicsHitData {
  59504. /**
  59505. * The force applied at the contact point
  59506. */
  59507. force: Vector3;
  59508. /**
  59509. * The contact point
  59510. */
  59511. contactPoint: Vector3;
  59512. /**
  59513. * The distance from the origin to the contact point
  59514. */
  59515. distanceFromOrigin: number;
  59516. }
  59517. /**
  59518. * Interface for radial explosion event data
  59519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59520. */
  59521. export interface PhysicsRadialExplosionEventData {
  59522. /**
  59523. * A sphere used for the radial explosion event
  59524. */
  59525. sphere: Mesh;
  59526. }
  59527. /**
  59528. * Interface for gravitational field event data
  59529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59530. */
  59531. export interface PhysicsGravitationalFieldEventData {
  59532. /**
  59533. * A sphere mesh used for the gravitational field event
  59534. */
  59535. sphere: Mesh;
  59536. }
  59537. /**
  59538. * Interface for updraft event data
  59539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59540. */
  59541. export interface PhysicsUpdraftEventData {
  59542. /**
  59543. * A cylinder used for the updraft event
  59544. */
  59545. cylinder: Mesh;
  59546. }
  59547. /**
  59548. * Interface for vortex event data
  59549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59550. */
  59551. export interface PhysicsVortexEventData {
  59552. /**
  59553. * A cylinder used for the vortex event
  59554. */
  59555. cylinder: Mesh;
  59556. }
  59557. /**
  59558. * Interface for an affected physics impostor
  59559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59560. */
  59561. export interface PhysicsAffectedImpostorWithData {
  59562. /**
  59563. * The impostor affected by the effect
  59564. */
  59565. impostor: PhysicsImpostor;
  59566. /**
  59567. * The data about the hit/horce from the explosion
  59568. */
  59569. hitData: PhysicsHitData;
  59570. }
  59571. }
  59572. declare module "babylonjs/Physics/Plugins/index" {
  59573. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59574. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59575. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59576. }
  59577. declare module "babylonjs/Physics/index" {
  59578. export * from "babylonjs/Physics/IPhysicsEngine";
  59579. export * from "babylonjs/Physics/physicsEngine";
  59580. export * from "babylonjs/Physics/physicsEngineComponent";
  59581. export * from "babylonjs/Physics/physicsHelper";
  59582. export * from "babylonjs/Physics/physicsImpostor";
  59583. export * from "babylonjs/Physics/physicsJoint";
  59584. export * from "babylonjs/Physics/Plugins/index";
  59585. }
  59586. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59587. /** @hidden */
  59588. export var blackAndWhitePixelShader: {
  59589. name: string;
  59590. shader: string;
  59591. };
  59592. }
  59593. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59595. import { Camera } from "babylonjs/Cameras/camera";
  59596. import { Engine } from "babylonjs/Engines/engine";
  59597. import "babylonjs/Shaders/blackAndWhite.fragment";
  59598. /**
  59599. * Post process used to render in black and white
  59600. */
  59601. export class BlackAndWhitePostProcess extends PostProcess {
  59602. /**
  59603. * Linear about to convert he result to black and white (default: 1)
  59604. */
  59605. degree: number;
  59606. /**
  59607. * Creates a black and white post process
  59608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59609. * @param name The name of the effect.
  59610. * @param options The required width/height ratio to downsize to before computing the render pass.
  59611. * @param camera The camera to apply the render pass to.
  59612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59613. * @param engine The engine which the post process will be applied. (default: current engine)
  59614. * @param reusable If the post process can be reused on the same frame. (default: false)
  59615. */
  59616. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59617. }
  59618. }
  59619. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59620. import { Nullable } from "babylonjs/types";
  59621. import { Camera } from "babylonjs/Cameras/camera";
  59622. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59623. import { Engine } from "babylonjs/Engines/engine";
  59624. /**
  59625. * This represents a set of one or more post processes in Babylon.
  59626. * A post process can be used to apply a shader to a texture after it is rendered.
  59627. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59628. */
  59629. export class PostProcessRenderEffect {
  59630. private _postProcesses;
  59631. private _getPostProcesses;
  59632. private _singleInstance;
  59633. private _cameras;
  59634. private _indicesForCamera;
  59635. /**
  59636. * Name of the effect
  59637. * @hidden
  59638. */
  59639. _name: string;
  59640. /**
  59641. * Instantiates a post process render effect.
  59642. * A post process can be used to apply a shader to a texture after it is rendered.
  59643. * @param engine The engine the effect is tied to
  59644. * @param name The name of the effect
  59645. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59646. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59647. */
  59648. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59649. /**
  59650. * Checks if all the post processes in the effect are supported.
  59651. */
  59652. readonly isSupported: boolean;
  59653. /**
  59654. * Updates the current state of the effect
  59655. * @hidden
  59656. */
  59657. _update(): void;
  59658. /**
  59659. * Attaches the effect on cameras
  59660. * @param cameras The camera to attach to.
  59661. * @hidden
  59662. */
  59663. _attachCameras(cameras: Camera): void;
  59664. /**
  59665. * Attaches the effect on cameras
  59666. * @param cameras The camera to attach to.
  59667. * @hidden
  59668. */
  59669. _attachCameras(cameras: Camera[]): void;
  59670. /**
  59671. * Detaches the effect on cameras
  59672. * @param cameras The camera to detatch from.
  59673. * @hidden
  59674. */
  59675. _detachCameras(cameras: Camera): void;
  59676. /**
  59677. * Detatches the effect on cameras
  59678. * @param cameras The camera to detatch from.
  59679. * @hidden
  59680. */
  59681. _detachCameras(cameras: Camera[]): void;
  59682. /**
  59683. * Enables the effect on given cameras
  59684. * @param cameras The camera to enable.
  59685. * @hidden
  59686. */
  59687. _enable(cameras: Camera): void;
  59688. /**
  59689. * Enables the effect on given cameras
  59690. * @param cameras The camera to enable.
  59691. * @hidden
  59692. */
  59693. _enable(cameras: Nullable<Camera[]>): void;
  59694. /**
  59695. * Disables the effect on the given cameras
  59696. * @param cameras The camera to disable.
  59697. * @hidden
  59698. */
  59699. _disable(cameras: Camera): void;
  59700. /**
  59701. * Disables the effect on the given cameras
  59702. * @param cameras The camera to disable.
  59703. * @hidden
  59704. */
  59705. _disable(cameras: Nullable<Camera[]>): void;
  59706. /**
  59707. * Gets a list of the post processes contained in the effect.
  59708. * @param camera The camera to get the post processes on.
  59709. * @returns The list of the post processes in the effect.
  59710. */
  59711. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59712. }
  59713. }
  59714. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59716. /** @hidden */
  59717. export var extractHighlightsPixelShader: {
  59718. name: string;
  59719. shader: string;
  59720. };
  59721. }
  59722. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59723. import { Nullable } from "babylonjs/types";
  59724. import { Camera } from "babylonjs/Cameras/camera";
  59725. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59726. import { Engine } from "babylonjs/Engines/engine";
  59727. import "babylonjs/Shaders/extractHighlights.fragment";
  59728. /**
  59729. * 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.
  59730. */
  59731. export class ExtractHighlightsPostProcess extends PostProcess {
  59732. /**
  59733. * The luminance threshold, pixels below this value will be set to black.
  59734. */
  59735. threshold: number;
  59736. /** @hidden */
  59737. _exposure: number;
  59738. /**
  59739. * Post process which has the input texture to be used when performing highlight extraction
  59740. * @hidden
  59741. */
  59742. _inputPostProcess: Nullable<PostProcess>;
  59743. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59744. }
  59745. }
  59746. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59747. /** @hidden */
  59748. export var bloomMergePixelShader: {
  59749. name: string;
  59750. shader: string;
  59751. };
  59752. }
  59753. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59754. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59755. import { Nullable } from "babylonjs/types";
  59756. import { Engine } from "babylonjs/Engines/engine";
  59757. import { Camera } from "babylonjs/Cameras/camera";
  59758. import "babylonjs/Shaders/bloomMerge.fragment";
  59759. /**
  59760. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59761. */
  59762. export class BloomMergePostProcess extends PostProcess {
  59763. /** Weight of the bloom to be added to the original input. */
  59764. weight: number;
  59765. /**
  59766. * Creates a new instance of @see BloomMergePostProcess
  59767. * @param name The name of the effect.
  59768. * @param originalFromInput Post process which's input will be used for the merge.
  59769. * @param blurred Blurred highlights post process which's output will be used.
  59770. * @param weight Weight of the bloom to be added to the original input.
  59771. * @param options The required width/height ratio to downsize to before computing the render pass.
  59772. * @param camera The camera to apply the render pass to.
  59773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59774. * @param engine The engine which the post process will be applied. (default: current engine)
  59775. * @param reusable If the post process can be reused on the same frame. (default: false)
  59776. * @param textureType Type of textures used when performing the post process. (default: 0)
  59777. * @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)
  59778. */
  59779. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59780. /** Weight of the bloom to be added to the original input. */
  59781. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59782. }
  59783. }
  59784. declare module "babylonjs/PostProcesses/bloomEffect" {
  59785. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59787. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59788. import { Camera } from "babylonjs/Cameras/camera";
  59789. import { Scene } from "babylonjs/scene";
  59790. /**
  59791. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59792. */
  59793. export class BloomEffect extends PostProcessRenderEffect {
  59794. private bloomScale;
  59795. /**
  59796. * @hidden Internal
  59797. */
  59798. _effects: Array<PostProcess>;
  59799. /**
  59800. * @hidden Internal
  59801. */
  59802. _downscale: ExtractHighlightsPostProcess;
  59803. private _blurX;
  59804. private _blurY;
  59805. private _merge;
  59806. /**
  59807. * The luminance threshold to find bright areas of the image to bloom.
  59808. */
  59809. threshold: number;
  59810. /**
  59811. * The strength of the bloom.
  59812. */
  59813. weight: number;
  59814. /**
  59815. * Specifies the size of the bloom blur kernel, relative to the final output size
  59816. */
  59817. kernel: number;
  59818. /**
  59819. * Creates a new instance of @see BloomEffect
  59820. * @param scene The scene the effect belongs to.
  59821. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59822. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59823. * @param bloomWeight The the strength of bloom.
  59824. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59825. * @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)
  59826. */
  59827. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59828. /**
  59829. * Disposes each of the internal effects for a given camera.
  59830. * @param camera The camera to dispose the effect on.
  59831. */
  59832. disposeEffects(camera: Camera): void;
  59833. /**
  59834. * @hidden Internal
  59835. */
  59836. _updateEffects(): void;
  59837. /**
  59838. * Internal
  59839. * @returns if all the contained post processes are ready.
  59840. * @hidden
  59841. */
  59842. _isReady(): boolean;
  59843. }
  59844. }
  59845. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59846. /** @hidden */
  59847. export var chromaticAberrationPixelShader: {
  59848. name: string;
  59849. shader: string;
  59850. };
  59851. }
  59852. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59853. import { Vector2 } from "babylonjs/Maths/math.vector";
  59854. import { Nullable } from "babylonjs/types";
  59855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59856. import { Camera } from "babylonjs/Cameras/camera";
  59857. import { Engine } from "babylonjs/Engines/engine";
  59858. import "babylonjs/Shaders/chromaticAberration.fragment";
  59859. /**
  59860. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59861. */
  59862. export class ChromaticAberrationPostProcess extends PostProcess {
  59863. /**
  59864. * The amount of seperation of rgb channels (default: 30)
  59865. */
  59866. aberrationAmount: number;
  59867. /**
  59868. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59869. */
  59870. radialIntensity: number;
  59871. /**
  59872. * 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))
  59873. */
  59874. direction: Vector2;
  59875. /**
  59876. * 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))
  59877. */
  59878. centerPosition: Vector2;
  59879. /**
  59880. * Creates a new instance ChromaticAberrationPostProcess
  59881. * @param name The name of the effect.
  59882. * @param screenWidth The width of the screen to apply the effect on.
  59883. * @param screenHeight The height of the screen to apply the effect on.
  59884. * @param options The required width/height ratio to downsize to before computing the render pass.
  59885. * @param camera The camera to apply the render pass to.
  59886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59887. * @param engine The engine which the post process will be applied. (default: current engine)
  59888. * @param reusable If the post process can be reused on the same frame. (default: false)
  59889. * @param textureType Type of textures used when performing the post process. (default: 0)
  59890. * @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)
  59891. */
  59892. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59893. }
  59894. }
  59895. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59896. /** @hidden */
  59897. export var circleOfConfusionPixelShader: {
  59898. name: string;
  59899. shader: string;
  59900. };
  59901. }
  59902. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59903. import { Nullable } from "babylonjs/types";
  59904. import { Engine } from "babylonjs/Engines/engine";
  59905. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59907. import { Camera } from "babylonjs/Cameras/camera";
  59908. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59909. /**
  59910. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59911. */
  59912. export class CircleOfConfusionPostProcess extends PostProcess {
  59913. /**
  59914. * 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.
  59915. */
  59916. lensSize: number;
  59917. /**
  59918. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59919. */
  59920. fStop: number;
  59921. /**
  59922. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59923. */
  59924. focusDistance: number;
  59925. /**
  59926. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59927. */
  59928. focalLength: number;
  59929. private _depthTexture;
  59930. /**
  59931. * Creates a new instance CircleOfConfusionPostProcess
  59932. * @param name The name of the effect.
  59933. * @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.
  59934. * @param options The required width/height ratio to downsize to before computing the render pass.
  59935. * @param camera The camera to apply the render pass to.
  59936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59937. * @param engine The engine which the post process will be applied. (default: current engine)
  59938. * @param reusable If the post process can be reused on the same frame. (default: false)
  59939. * @param textureType Type of textures used when performing the post process. (default: 0)
  59940. * @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)
  59941. */
  59942. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59943. /**
  59944. * 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.
  59945. */
  59946. depthTexture: RenderTargetTexture;
  59947. }
  59948. }
  59949. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59950. /** @hidden */
  59951. export var colorCorrectionPixelShader: {
  59952. name: string;
  59953. shader: string;
  59954. };
  59955. }
  59956. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59958. import { Engine } from "babylonjs/Engines/engine";
  59959. import { Camera } from "babylonjs/Cameras/camera";
  59960. import "babylonjs/Shaders/colorCorrection.fragment";
  59961. /**
  59962. *
  59963. * This post-process allows the modification of rendered colors by using
  59964. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59965. *
  59966. * The object needs to be provided an url to a texture containing the color
  59967. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59968. * Use an image editing software to tweak the LUT to match your needs.
  59969. *
  59970. * For an example of a color LUT, see here:
  59971. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59972. * For explanations on color grading, see here:
  59973. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59974. *
  59975. */
  59976. export class ColorCorrectionPostProcess extends PostProcess {
  59977. private _colorTableTexture;
  59978. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59979. }
  59980. }
  59981. declare module "babylonjs/Shaders/convolution.fragment" {
  59982. /** @hidden */
  59983. export var convolutionPixelShader: {
  59984. name: string;
  59985. shader: string;
  59986. };
  59987. }
  59988. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59989. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59990. import { Nullable } from "babylonjs/types";
  59991. import { Camera } from "babylonjs/Cameras/camera";
  59992. import { Engine } from "babylonjs/Engines/engine";
  59993. import "babylonjs/Shaders/convolution.fragment";
  59994. /**
  59995. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59996. * input texture to perform effects such as edge detection or sharpening
  59997. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59998. */
  59999. export class ConvolutionPostProcess extends PostProcess {
  60000. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60001. kernel: number[];
  60002. /**
  60003. * Creates a new instance ConvolutionPostProcess
  60004. * @param name The name of the effect.
  60005. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60006. * @param options The required width/height ratio to downsize to before computing the render pass.
  60007. * @param camera The camera to apply the render pass to.
  60008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60009. * @param engine The engine which the post process will be applied. (default: current engine)
  60010. * @param reusable If the post process can be reused on the same frame. (default: false)
  60011. * @param textureType Type of textures used when performing the post process. (default: 0)
  60012. */
  60013. constructor(name: string,
  60014. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60015. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60016. /**
  60017. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60018. */
  60019. static EdgeDetect0Kernel: number[];
  60020. /**
  60021. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60022. */
  60023. static EdgeDetect1Kernel: number[];
  60024. /**
  60025. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60026. */
  60027. static EdgeDetect2Kernel: number[];
  60028. /**
  60029. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60030. */
  60031. static SharpenKernel: number[];
  60032. /**
  60033. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60034. */
  60035. static EmbossKernel: number[];
  60036. /**
  60037. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60038. */
  60039. static GaussianKernel: number[];
  60040. }
  60041. }
  60042. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60043. import { Nullable } from "babylonjs/types";
  60044. import { Vector2 } from "babylonjs/Maths/math.vector";
  60045. import { Camera } from "babylonjs/Cameras/camera";
  60046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60047. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60048. import { Engine } from "babylonjs/Engines/engine";
  60049. import { Scene } from "babylonjs/scene";
  60050. /**
  60051. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60052. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60053. * based on samples that have a large difference in distance than the center pixel.
  60054. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60055. */
  60056. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60057. direction: Vector2;
  60058. /**
  60059. * Creates a new instance CircleOfConfusionPostProcess
  60060. * @param name The name of the effect.
  60061. * @param scene The scene the effect belongs to.
  60062. * @param direction The direction the blur should be applied.
  60063. * @param kernel The size of the kernel used to blur.
  60064. * @param options The required width/height ratio to downsize to before computing the render pass.
  60065. * @param camera The camera to apply the render pass to.
  60066. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60067. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60069. * @param engine The engine which the post process will be applied. (default: current engine)
  60070. * @param reusable If the post process can be reused on the same frame. (default: false)
  60071. * @param textureType Type of textures used when performing the post process. (default: 0)
  60072. * @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)
  60073. */
  60074. 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);
  60075. }
  60076. }
  60077. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60078. /** @hidden */
  60079. export var depthOfFieldMergePixelShader: {
  60080. name: string;
  60081. shader: string;
  60082. };
  60083. }
  60084. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60085. import { Nullable } from "babylonjs/types";
  60086. import { Camera } from "babylonjs/Cameras/camera";
  60087. import { Effect } from "babylonjs/Materials/effect";
  60088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60089. import { Engine } from "babylonjs/Engines/engine";
  60090. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60091. /**
  60092. * Options to be set when merging outputs from the default pipeline.
  60093. */
  60094. export class DepthOfFieldMergePostProcessOptions {
  60095. /**
  60096. * The original image to merge on top of
  60097. */
  60098. originalFromInput: PostProcess;
  60099. /**
  60100. * Parameters to perform the merge of the depth of field effect
  60101. */
  60102. depthOfField?: {
  60103. circleOfConfusion: PostProcess;
  60104. blurSteps: Array<PostProcess>;
  60105. };
  60106. /**
  60107. * Parameters to perform the merge of bloom effect
  60108. */
  60109. bloom?: {
  60110. blurred: PostProcess;
  60111. weight: number;
  60112. };
  60113. }
  60114. /**
  60115. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60116. */
  60117. export class DepthOfFieldMergePostProcess extends PostProcess {
  60118. private blurSteps;
  60119. /**
  60120. * Creates a new instance of DepthOfFieldMergePostProcess
  60121. * @param name The name of the effect.
  60122. * @param originalFromInput Post process which's input will be used for the merge.
  60123. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60124. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60125. * @param options The required width/height ratio to downsize to before computing the render pass.
  60126. * @param camera The camera to apply the render pass to.
  60127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60128. * @param engine The engine which the post process will be applied. (default: current engine)
  60129. * @param reusable If the post process can be reused on the same frame. (default: false)
  60130. * @param textureType Type of textures used when performing the post process. (default: 0)
  60131. * @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)
  60132. */
  60133. 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);
  60134. /**
  60135. * Updates the effect with the current post process compile time values and recompiles the shader.
  60136. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60137. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60138. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60139. * @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
  60140. * @param onCompiled Called when the shader has been compiled.
  60141. * @param onError Called if there is an error when compiling a shader.
  60142. */
  60143. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60144. }
  60145. }
  60146. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60147. import { Nullable } from "babylonjs/types";
  60148. import { Camera } from "babylonjs/Cameras/camera";
  60149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60151. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60152. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60153. import { Scene } from "babylonjs/scene";
  60154. /**
  60155. * Specifies the level of max blur that should be applied when using the depth of field effect
  60156. */
  60157. export enum DepthOfFieldEffectBlurLevel {
  60158. /**
  60159. * Subtle blur
  60160. */
  60161. Low = 0,
  60162. /**
  60163. * Medium blur
  60164. */
  60165. Medium = 1,
  60166. /**
  60167. * Large blur
  60168. */
  60169. High = 2
  60170. }
  60171. /**
  60172. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60173. */
  60174. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60175. private _circleOfConfusion;
  60176. /**
  60177. * @hidden Internal, blurs from high to low
  60178. */
  60179. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60180. private _depthOfFieldBlurY;
  60181. private _dofMerge;
  60182. /**
  60183. * @hidden Internal post processes in depth of field effect
  60184. */
  60185. _effects: Array<PostProcess>;
  60186. /**
  60187. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60188. */
  60189. focalLength: number;
  60190. /**
  60191. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60192. */
  60193. fStop: number;
  60194. /**
  60195. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60196. */
  60197. focusDistance: number;
  60198. /**
  60199. * 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.
  60200. */
  60201. lensSize: number;
  60202. /**
  60203. * Creates a new instance DepthOfFieldEffect
  60204. * @param scene The scene the effect belongs to.
  60205. * @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.
  60206. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60207. * @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)
  60208. */
  60209. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60210. /**
  60211. * Get the current class name of the current effet
  60212. * @returns "DepthOfFieldEffect"
  60213. */
  60214. getClassName(): string;
  60215. /**
  60216. * 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.
  60217. */
  60218. depthTexture: RenderTargetTexture;
  60219. /**
  60220. * Disposes each of the internal effects for a given camera.
  60221. * @param camera The camera to dispose the effect on.
  60222. */
  60223. disposeEffects(camera: Camera): void;
  60224. /**
  60225. * @hidden Internal
  60226. */
  60227. _updateEffects(): void;
  60228. /**
  60229. * Internal
  60230. * @returns if all the contained post processes are ready.
  60231. * @hidden
  60232. */
  60233. _isReady(): boolean;
  60234. }
  60235. }
  60236. declare module "babylonjs/Shaders/displayPass.fragment" {
  60237. /** @hidden */
  60238. export var displayPassPixelShader: {
  60239. name: string;
  60240. shader: string;
  60241. };
  60242. }
  60243. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60244. import { Nullable } from "babylonjs/types";
  60245. import { Camera } from "babylonjs/Cameras/camera";
  60246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60247. import { Engine } from "babylonjs/Engines/engine";
  60248. import "babylonjs/Shaders/displayPass.fragment";
  60249. /**
  60250. * DisplayPassPostProcess which produces an output the same as it's input
  60251. */
  60252. export class DisplayPassPostProcess extends PostProcess {
  60253. /**
  60254. * Creates the DisplayPassPostProcess
  60255. * @param name The name of the effect.
  60256. * @param options The required width/height ratio to downsize to before computing the render pass.
  60257. * @param camera The camera to apply the render pass to.
  60258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60259. * @param engine The engine which the post process will be applied. (default: current engine)
  60260. * @param reusable If the post process can be reused on the same frame. (default: false)
  60261. */
  60262. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60263. }
  60264. }
  60265. declare module "babylonjs/Shaders/filter.fragment" {
  60266. /** @hidden */
  60267. export var filterPixelShader: {
  60268. name: string;
  60269. shader: string;
  60270. };
  60271. }
  60272. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60273. import { Nullable } from "babylonjs/types";
  60274. import { Matrix } from "babylonjs/Maths/math.vector";
  60275. import { Camera } from "babylonjs/Cameras/camera";
  60276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60277. import { Engine } from "babylonjs/Engines/engine";
  60278. import "babylonjs/Shaders/filter.fragment";
  60279. /**
  60280. * Applies a kernel filter to the image
  60281. */
  60282. export class FilterPostProcess extends PostProcess {
  60283. /** The matrix to be applied to the image */
  60284. kernelMatrix: Matrix;
  60285. /**
  60286. *
  60287. * @param name The name of the effect.
  60288. * @param kernelMatrix The matrix to be applied to the image
  60289. * @param options The required width/height ratio to downsize to before computing the render pass.
  60290. * @param camera The camera to apply the render pass to.
  60291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60292. * @param engine The engine which the post process will be applied. (default: current engine)
  60293. * @param reusable If the post process can be reused on the same frame. (default: false)
  60294. */
  60295. constructor(name: string,
  60296. /** The matrix to be applied to the image */
  60297. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60298. }
  60299. }
  60300. declare module "babylonjs/Shaders/fxaa.fragment" {
  60301. /** @hidden */
  60302. export var fxaaPixelShader: {
  60303. name: string;
  60304. shader: string;
  60305. };
  60306. }
  60307. declare module "babylonjs/Shaders/fxaa.vertex" {
  60308. /** @hidden */
  60309. export var fxaaVertexShader: {
  60310. name: string;
  60311. shader: string;
  60312. };
  60313. }
  60314. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60315. import { Nullable } from "babylonjs/types";
  60316. import { Camera } from "babylonjs/Cameras/camera";
  60317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60318. import { Engine } from "babylonjs/Engines/engine";
  60319. import "babylonjs/Shaders/fxaa.fragment";
  60320. import "babylonjs/Shaders/fxaa.vertex";
  60321. /**
  60322. * Fxaa post process
  60323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60324. */
  60325. export class FxaaPostProcess extends PostProcess {
  60326. /** @hidden */
  60327. texelWidth: number;
  60328. /** @hidden */
  60329. texelHeight: number;
  60330. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60331. private _getDefines;
  60332. }
  60333. }
  60334. declare module "babylonjs/Shaders/grain.fragment" {
  60335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60336. /** @hidden */
  60337. export var grainPixelShader: {
  60338. name: string;
  60339. shader: string;
  60340. };
  60341. }
  60342. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60343. import { Nullable } from "babylonjs/types";
  60344. import { Camera } from "babylonjs/Cameras/camera";
  60345. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60346. import { Engine } from "babylonjs/Engines/engine";
  60347. import "babylonjs/Shaders/grain.fragment";
  60348. /**
  60349. * The GrainPostProcess adds noise to the image at mid luminance levels
  60350. */
  60351. export class GrainPostProcess extends PostProcess {
  60352. /**
  60353. * The intensity of the grain added (default: 30)
  60354. */
  60355. intensity: number;
  60356. /**
  60357. * If the grain should be randomized on every frame
  60358. */
  60359. animated: boolean;
  60360. /**
  60361. * Creates a new instance of @see GrainPostProcess
  60362. * @param name The name of the effect.
  60363. * @param options The required width/height ratio to downsize to before computing the render pass.
  60364. * @param camera The camera to apply the render pass to.
  60365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60366. * @param engine The engine which the post process will be applied. (default: current engine)
  60367. * @param reusable If the post process can be reused on the same frame. (default: false)
  60368. * @param textureType Type of textures used when performing the post process. (default: 0)
  60369. * @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)
  60370. */
  60371. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60372. }
  60373. }
  60374. declare module "babylonjs/Shaders/highlights.fragment" {
  60375. /** @hidden */
  60376. export var highlightsPixelShader: {
  60377. name: string;
  60378. shader: string;
  60379. };
  60380. }
  60381. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60382. import { Nullable } from "babylonjs/types";
  60383. import { Camera } from "babylonjs/Cameras/camera";
  60384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60385. import { Engine } from "babylonjs/Engines/engine";
  60386. import "babylonjs/Shaders/highlights.fragment";
  60387. /**
  60388. * Extracts highlights from the image
  60389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60390. */
  60391. export class HighlightsPostProcess extends PostProcess {
  60392. /**
  60393. * Extracts highlights from the image
  60394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60395. * @param name The name of the effect.
  60396. * @param options The required width/height ratio to downsize to before computing the render pass.
  60397. * @param camera The camera to apply the render pass to.
  60398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60399. * @param engine The engine which the post process will be applied. (default: current engine)
  60400. * @param reusable If the post process can be reused on the same frame. (default: false)
  60401. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60402. */
  60403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60404. }
  60405. }
  60406. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60407. /** @hidden */
  60408. export var mrtFragmentDeclaration: {
  60409. name: string;
  60410. shader: string;
  60411. };
  60412. }
  60413. declare module "babylonjs/Shaders/geometry.fragment" {
  60414. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60415. /** @hidden */
  60416. export var geometryPixelShader: {
  60417. name: string;
  60418. shader: string;
  60419. };
  60420. }
  60421. declare module "babylonjs/Shaders/geometry.vertex" {
  60422. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60423. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60425. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60427. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60428. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60429. /** @hidden */
  60430. export var geometryVertexShader: {
  60431. name: string;
  60432. shader: string;
  60433. };
  60434. }
  60435. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60436. import { Matrix } from "babylonjs/Maths/math.vector";
  60437. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60438. import { Mesh } from "babylonjs/Meshes/mesh";
  60439. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60440. import { Effect } from "babylonjs/Materials/effect";
  60441. import { Scene } from "babylonjs/scene";
  60442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60443. import "babylonjs/Shaders/geometry.fragment";
  60444. import "babylonjs/Shaders/geometry.vertex";
  60445. /** @hidden */
  60446. interface ISavedTransformationMatrix {
  60447. world: Matrix;
  60448. viewProjection: Matrix;
  60449. }
  60450. /**
  60451. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60452. */
  60453. export class GeometryBufferRenderer {
  60454. /**
  60455. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60456. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60457. */
  60458. static readonly POSITION_TEXTURE_TYPE: number;
  60459. /**
  60460. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60461. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60462. */
  60463. static readonly VELOCITY_TEXTURE_TYPE: number;
  60464. /**
  60465. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60466. * in order to compute objects velocities when enableVelocity is set to "true"
  60467. * @hidden
  60468. */
  60469. _previousTransformationMatrices: {
  60470. [index: number]: ISavedTransformationMatrix;
  60471. };
  60472. /**
  60473. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60474. * in order to compute objects velocities when enableVelocity is set to "true"
  60475. * @hidden
  60476. */
  60477. _previousBonesTransformationMatrices: {
  60478. [index: number]: Float32Array;
  60479. };
  60480. /**
  60481. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60482. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60483. */
  60484. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60485. private _scene;
  60486. private _multiRenderTarget;
  60487. private _ratio;
  60488. private _enablePosition;
  60489. private _enableVelocity;
  60490. private _positionIndex;
  60491. private _velocityIndex;
  60492. protected _effect: Effect;
  60493. protected _cachedDefines: string;
  60494. /**
  60495. * Set the render list (meshes to be rendered) used in the G buffer.
  60496. */
  60497. renderList: Mesh[];
  60498. /**
  60499. * Gets wether or not G buffer are supported by the running hardware.
  60500. * This requires draw buffer supports
  60501. */
  60502. readonly isSupported: boolean;
  60503. /**
  60504. * Returns the index of the given texture type in the G-Buffer textures array
  60505. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60506. * @returns the index of the given texture type in the G-Buffer textures array
  60507. */
  60508. getTextureIndex(textureType: number): number;
  60509. /**
  60510. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60511. */
  60512. /**
  60513. * Sets whether or not objects positions are enabled for the G buffer.
  60514. */
  60515. enablePosition: boolean;
  60516. /**
  60517. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60518. */
  60519. /**
  60520. * Sets wether or not objects velocities are enabled for the G buffer.
  60521. */
  60522. enableVelocity: boolean;
  60523. /**
  60524. * Gets the scene associated with the buffer.
  60525. */
  60526. readonly scene: Scene;
  60527. /**
  60528. * Gets the ratio used by the buffer during its creation.
  60529. * How big is the buffer related to the main canvas.
  60530. */
  60531. readonly ratio: number;
  60532. /** @hidden */
  60533. static _SceneComponentInitialization: (scene: Scene) => void;
  60534. /**
  60535. * Creates a new G Buffer for the scene
  60536. * @param scene The scene the buffer belongs to
  60537. * @param ratio How big is the buffer related to the main canvas.
  60538. */
  60539. constructor(scene: Scene, ratio?: number);
  60540. /**
  60541. * Checks wether everything is ready to render a submesh to the G buffer.
  60542. * @param subMesh the submesh to check readiness for
  60543. * @param useInstances is the mesh drawn using instance or not
  60544. * @returns true if ready otherwise false
  60545. */
  60546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60547. /**
  60548. * Gets the current underlying G Buffer.
  60549. * @returns the buffer
  60550. */
  60551. getGBuffer(): MultiRenderTarget;
  60552. /**
  60553. * Gets the number of samples used to render the buffer (anti aliasing).
  60554. */
  60555. /**
  60556. * Sets the number of samples used to render the buffer (anti aliasing).
  60557. */
  60558. samples: number;
  60559. /**
  60560. * Disposes the renderer and frees up associated resources.
  60561. */
  60562. dispose(): void;
  60563. protected _createRenderTargets(): void;
  60564. private _copyBonesTransformationMatrices;
  60565. }
  60566. }
  60567. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60568. import { Nullable } from "babylonjs/types";
  60569. import { Scene } from "babylonjs/scene";
  60570. import { ISceneComponent } from "babylonjs/sceneComponent";
  60571. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60572. module "babylonjs/scene" {
  60573. interface Scene {
  60574. /** @hidden (Backing field) */
  60575. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60576. /**
  60577. * Gets or Sets the current geometry buffer associated to the scene.
  60578. */
  60579. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60580. /**
  60581. * Enables a GeometryBufferRender and associates it with the scene
  60582. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60583. * @returns the GeometryBufferRenderer
  60584. */
  60585. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60586. /**
  60587. * Disables the GeometryBufferRender associated with the scene
  60588. */
  60589. disableGeometryBufferRenderer(): void;
  60590. }
  60591. }
  60592. /**
  60593. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60594. * in several rendering techniques.
  60595. */
  60596. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60597. /**
  60598. * The component name helpful to identify the component in the list of scene components.
  60599. */
  60600. readonly name: string;
  60601. /**
  60602. * The scene the component belongs to.
  60603. */
  60604. scene: Scene;
  60605. /**
  60606. * Creates a new instance of the component for the given scene
  60607. * @param scene Defines the scene to register the component in
  60608. */
  60609. constructor(scene: Scene);
  60610. /**
  60611. * Registers the component in a given scene
  60612. */
  60613. register(): void;
  60614. /**
  60615. * Rebuilds the elements related to this component in case of
  60616. * context lost for instance.
  60617. */
  60618. rebuild(): void;
  60619. /**
  60620. * Disposes the component and the associated ressources
  60621. */
  60622. dispose(): void;
  60623. private _gatherRenderTargets;
  60624. }
  60625. }
  60626. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60627. /** @hidden */
  60628. export var motionBlurPixelShader: {
  60629. name: string;
  60630. shader: string;
  60631. };
  60632. }
  60633. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60634. import { Nullable } from "babylonjs/types";
  60635. import { Camera } from "babylonjs/Cameras/camera";
  60636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60637. import { Scene } from "babylonjs/scene";
  60638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60639. import "babylonjs/Animations/animatable";
  60640. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60641. import "babylonjs/Shaders/motionBlur.fragment";
  60642. import { Engine } from "babylonjs/Engines/engine";
  60643. /**
  60644. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60645. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60646. * As an example, all you have to do is to create the post-process:
  60647. * var mb = new BABYLON.MotionBlurPostProcess(
  60648. * 'mb', // The name of the effect.
  60649. * scene, // The scene containing the objects to blur according to their velocity.
  60650. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60651. * camera // The camera to apply the render pass to.
  60652. * );
  60653. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60654. */
  60655. export class MotionBlurPostProcess extends PostProcess {
  60656. /**
  60657. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60658. */
  60659. motionStrength: number;
  60660. /**
  60661. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60662. */
  60663. /**
  60664. * Sets the number of iterations to be used for motion blur quality
  60665. */
  60666. motionBlurSamples: number;
  60667. private _motionBlurSamples;
  60668. private _geometryBufferRenderer;
  60669. /**
  60670. * Creates a new instance MotionBlurPostProcess
  60671. * @param name The name of the effect.
  60672. * @param scene The scene containing the objects to blur according to their velocity.
  60673. * @param options The required width/height ratio to downsize to before computing the render pass.
  60674. * @param camera The camera to apply the render pass to.
  60675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60676. * @param engine The engine which the post process will be applied. (default: current engine)
  60677. * @param reusable If the post process can be reused on the same frame. (default: false)
  60678. * @param textureType Type of textures used when performing the post process. (default: 0)
  60679. * @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)
  60680. */
  60681. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60682. /**
  60683. * Excludes the given skinned mesh from computing bones velocities.
  60684. * 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.
  60685. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60686. */
  60687. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60688. /**
  60689. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60690. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60691. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60692. */
  60693. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60694. /**
  60695. * Disposes the post process.
  60696. * @param camera The camera to dispose the post process on.
  60697. */
  60698. dispose(camera?: Camera): void;
  60699. }
  60700. }
  60701. declare module "babylonjs/Shaders/refraction.fragment" {
  60702. /** @hidden */
  60703. export var refractionPixelShader: {
  60704. name: string;
  60705. shader: string;
  60706. };
  60707. }
  60708. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60709. import { Color3 } from "babylonjs/Maths/math.color";
  60710. import { Camera } from "babylonjs/Cameras/camera";
  60711. import { Texture } from "babylonjs/Materials/Textures/texture";
  60712. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60713. import { Engine } from "babylonjs/Engines/engine";
  60714. import "babylonjs/Shaders/refraction.fragment";
  60715. /**
  60716. * Post process which applies a refractin texture
  60717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60718. */
  60719. export class RefractionPostProcess extends PostProcess {
  60720. /** the base color of the refraction (used to taint the rendering) */
  60721. color: Color3;
  60722. /** simulated refraction depth */
  60723. depth: number;
  60724. /** the coefficient of the base color (0 to remove base color tainting) */
  60725. colorLevel: number;
  60726. private _refTexture;
  60727. private _ownRefractionTexture;
  60728. /**
  60729. * Gets or sets the refraction texture
  60730. * Please note that you are responsible for disposing the texture if you set it manually
  60731. */
  60732. refractionTexture: Texture;
  60733. /**
  60734. * Initializes the RefractionPostProcess
  60735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60736. * @param name The name of the effect.
  60737. * @param refractionTextureUrl Url of the refraction texture to use
  60738. * @param color the base color of the refraction (used to taint the rendering)
  60739. * @param depth simulated refraction depth
  60740. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60741. * @param camera The camera to apply the render pass to.
  60742. * @param options The required width/height ratio to downsize to before computing the render pass.
  60743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60744. * @param engine The engine which the post process will be applied. (default: current engine)
  60745. * @param reusable If the post process can be reused on the same frame. (default: false)
  60746. */
  60747. constructor(name: string, refractionTextureUrl: string,
  60748. /** the base color of the refraction (used to taint the rendering) */
  60749. color: Color3,
  60750. /** simulated refraction depth */
  60751. depth: number,
  60752. /** the coefficient of the base color (0 to remove base color tainting) */
  60753. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60754. /**
  60755. * Disposes of the post process
  60756. * @param camera Camera to dispose post process on
  60757. */
  60758. dispose(camera: Camera): void;
  60759. }
  60760. }
  60761. declare module "babylonjs/Shaders/sharpen.fragment" {
  60762. /** @hidden */
  60763. export var sharpenPixelShader: {
  60764. name: string;
  60765. shader: string;
  60766. };
  60767. }
  60768. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60769. import { Nullable } from "babylonjs/types";
  60770. import { Camera } from "babylonjs/Cameras/camera";
  60771. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60772. import "babylonjs/Shaders/sharpen.fragment";
  60773. import { Engine } from "babylonjs/Engines/engine";
  60774. /**
  60775. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60776. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60777. */
  60778. export class SharpenPostProcess extends PostProcess {
  60779. /**
  60780. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60781. */
  60782. colorAmount: number;
  60783. /**
  60784. * How much sharpness should be applied (default: 0.3)
  60785. */
  60786. edgeAmount: number;
  60787. /**
  60788. * Creates a new instance ConvolutionPostProcess
  60789. * @param name The name of the effect.
  60790. * @param options The required width/height ratio to downsize to before computing the render pass.
  60791. * @param camera The camera to apply the render pass to.
  60792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60793. * @param engine The engine which the post process will be applied. (default: current engine)
  60794. * @param reusable If the post process can be reused on the same frame. (default: false)
  60795. * @param textureType Type of textures used when performing the post process. (default: 0)
  60796. * @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)
  60797. */
  60798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60799. }
  60800. }
  60801. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60802. import { Nullable } from "babylonjs/types";
  60803. import { Camera } from "babylonjs/Cameras/camera";
  60804. import { Engine } from "babylonjs/Engines/engine";
  60805. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60806. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60807. /**
  60808. * PostProcessRenderPipeline
  60809. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60810. */
  60811. export class PostProcessRenderPipeline {
  60812. private engine;
  60813. private _renderEffects;
  60814. private _renderEffectsForIsolatedPass;
  60815. /**
  60816. * List of inspectable custom properties (used by the Inspector)
  60817. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60818. */
  60819. inspectableCustomProperties: IInspectable[];
  60820. /**
  60821. * @hidden
  60822. */
  60823. protected _cameras: Camera[];
  60824. /** @hidden */
  60825. _name: string;
  60826. /**
  60827. * Gets pipeline name
  60828. */
  60829. readonly name: string;
  60830. /**
  60831. * Initializes a PostProcessRenderPipeline
  60832. * @param engine engine to add the pipeline to
  60833. * @param name name of the pipeline
  60834. */
  60835. constructor(engine: Engine, name: string);
  60836. /**
  60837. * Gets the class name
  60838. * @returns "PostProcessRenderPipeline"
  60839. */
  60840. getClassName(): string;
  60841. /**
  60842. * If all the render effects in the pipeline are supported
  60843. */
  60844. readonly isSupported: boolean;
  60845. /**
  60846. * Adds an effect to the pipeline
  60847. * @param renderEffect the effect to add
  60848. */
  60849. addEffect(renderEffect: PostProcessRenderEffect): void;
  60850. /** @hidden */
  60851. _rebuild(): void;
  60852. /** @hidden */
  60853. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60854. /** @hidden */
  60855. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60856. /** @hidden */
  60857. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60858. /** @hidden */
  60859. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60860. /** @hidden */
  60861. _attachCameras(cameras: Camera, unique: boolean): void;
  60862. /** @hidden */
  60863. _attachCameras(cameras: Camera[], unique: boolean): void;
  60864. /** @hidden */
  60865. _detachCameras(cameras: Camera): void;
  60866. /** @hidden */
  60867. _detachCameras(cameras: Nullable<Camera[]>): void;
  60868. /** @hidden */
  60869. _update(): void;
  60870. /** @hidden */
  60871. _reset(): void;
  60872. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60873. /**
  60874. * Disposes of the pipeline
  60875. */
  60876. dispose(): void;
  60877. }
  60878. }
  60879. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60880. import { Camera } from "babylonjs/Cameras/camera";
  60881. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60882. /**
  60883. * PostProcessRenderPipelineManager class
  60884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60885. */
  60886. export class PostProcessRenderPipelineManager {
  60887. private _renderPipelines;
  60888. /**
  60889. * Initializes a PostProcessRenderPipelineManager
  60890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60891. */
  60892. constructor();
  60893. /**
  60894. * Gets the list of supported render pipelines
  60895. */
  60896. readonly supportedPipelines: PostProcessRenderPipeline[];
  60897. /**
  60898. * Adds a pipeline to the manager
  60899. * @param renderPipeline The pipeline to add
  60900. */
  60901. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60902. /**
  60903. * Attaches a camera to the pipeline
  60904. * @param renderPipelineName The name of the pipeline to attach to
  60905. * @param cameras the camera to attach
  60906. * @param unique if the camera can be attached multiple times to the pipeline
  60907. */
  60908. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60909. /**
  60910. * Detaches a camera from the pipeline
  60911. * @param renderPipelineName The name of the pipeline to detach from
  60912. * @param cameras the camera to detach
  60913. */
  60914. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60915. /**
  60916. * Enables an effect by name on a pipeline
  60917. * @param renderPipelineName the name of the pipeline to enable the effect in
  60918. * @param renderEffectName the name of the effect to enable
  60919. * @param cameras the cameras that the effect should be enabled on
  60920. */
  60921. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60922. /**
  60923. * Disables an effect by name on a pipeline
  60924. * @param renderPipelineName the name of the pipeline to disable the effect in
  60925. * @param renderEffectName the name of the effect to disable
  60926. * @param cameras the cameras that the effect should be disabled on
  60927. */
  60928. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60929. /**
  60930. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60931. */
  60932. update(): void;
  60933. /** @hidden */
  60934. _rebuild(): void;
  60935. /**
  60936. * Disposes of the manager and pipelines
  60937. */
  60938. dispose(): void;
  60939. }
  60940. }
  60941. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60942. import { ISceneComponent } from "babylonjs/sceneComponent";
  60943. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60944. import { Scene } from "babylonjs/scene";
  60945. module "babylonjs/scene" {
  60946. interface Scene {
  60947. /** @hidden (Backing field) */
  60948. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60949. /**
  60950. * Gets the postprocess render pipeline manager
  60951. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60952. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60953. */
  60954. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60955. }
  60956. }
  60957. /**
  60958. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60959. */
  60960. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60961. /**
  60962. * The component name helpfull to identify the component in the list of scene components.
  60963. */
  60964. readonly name: string;
  60965. /**
  60966. * The scene the component belongs to.
  60967. */
  60968. scene: Scene;
  60969. /**
  60970. * Creates a new instance of the component for the given scene
  60971. * @param scene Defines the scene to register the component in
  60972. */
  60973. constructor(scene: Scene);
  60974. /**
  60975. * Registers the component in a given scene
  60976. */
  60977. register(): void;
  60978. /**
  60979. * Rebuilds the elements related to this component in case of
  60980. * context lost for instance.
  60981. */
  60982. rebuild(): void;
  60983. /**
  60984. * Disposes the component and the associated ressources
  60985. */
  60986. dispose(): void;
  60987. private _gatherRenderTargets;
  60988. }
  60989. }
  60990. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60991. import { Nullable } from "babylonjs/types";
  60992. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60993. import { Camera } from "babylonjs/Cameras/camera";
  60994. import { IDisposable } from "babylonjs/scene";
  60995. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60996. import { Scene } from "babylonjs/scene";
  60997. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60998. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60999. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61000. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61001. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61002. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61003. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61004. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61005. import { Animation } from "babylonjs/Animations/animation";
  61006. /**
  61007. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61008. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61009. */
  61010. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61011. private _scene;
  61012. private _camerasToBeAttached;
  61013. /**
  61014. * ID of the sharpen post process,
  61015. */
  61016. private readonly SharpenPostProcessId;
  61017. /**
  61018. * @ignore
  61019. * ID of the image processing post process;
  61020. */
  61021. readonly ImageProcessingPostProcessId: string;
  61022. /**
  61023. * @ignore
  61024. * ID of the Fast Approximate Anti-Aliasing post process;
  61025. */
  61026. readonly FxaaPostProcessId: string;
  61027. /**
  61028. * ID of the chromatic aberration post process,
  61029. */
  61030. private readonly ChromaticAberrationPostProcessId;
  61031. /**
  61032. * ID of the grain post process
  61033. */
  61034. private readonly GrainPostProcessId;
  61035. /**
  61036. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61037. */
  61038. sharpen: SharpenPostProcess;
  61039. private _sharpenEffect;
  61040. private bloom;
  61041. /**
  61042. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61043. */
  61044. depthOfField: DepthOfFieldEffect;
  61045. /**
  61046. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61047. */
  61048. fxaa: FxaaPostProcess;
  61049. /**
  61050. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61051. */
  61052. imageProcessing: ImageProcessingPostProcess;
  61053. /**
  61054. * Chromatic aberration post process which will shift rgb colors in the image
  61055. */
  61056. chromaticAberration: ChromaticAberrationPostProcess;
  61057. private _chromaticAberrationEffect;
  61058. /**
  61059. * Grain post process which add noise to the image
  61060. */
  61061. grain: GrainPostProcess;
  61062. private _grainEffect;
  61063. /**
  61064. * Glow post process which adds a glow to emissive areas of the image
  61065. */
  61066. private _glowLayer;
  61067. /**
  61068. * Animations which can be used to tweak settings over a period of time
  61069. */
  61070. animations: Animation[];
  61071. private _imageProcessingConfigurationObserver;
  61072. private _sharpenEnabled;
  61073. private _bloomEnabled;
  61074. private _depthOfFieldEnabled;
  61075. private _depthOfFieldBlurLevel;
  61076. private _fxaaEnabled;
  61077. private _imageProcessingEnabled;
  61078. private _defaultPipelineTextureType;
  61079. private _bloomScale;
  61080. private _chromaticAberrationEnabled;
  61081. private _grainEnabled;
  61082. private _buildAllowed;
  61083. /**
  61084. * Gets active scene
  61085. */
  61086. readonly scene: Scene;
  61087. /**
  61088. * Enable or disable the sharpen process from the pipeline
  61089. */
  61090. sharpenEnabled: boolean;
  61091. private _resizeObserver;
  61092. private _hardwareScaleLevel;
  61093. private _bloomKernel;
  61094. /**
  61095. * Specifies the size of the bloom blur kernel, relative to the final output size
  61096. */
  61097. bloomKernel: number;
  61098. /**
  61099. * Specifies the weight of the bloom in the final rendering
  61100. */
  61101. private _bloomWeight;
  61102. /**
  61103. * Specifies the luma threshold for the area that will be blurred by the bloom
  61104. */
  61105. private _bloomThreshold;
  61106. private _hdr;
  61107. /**
  61108. * The strength of the bloom.
  61109. */
  61110. bloomWeight: number;
  61111. /**
  61112. * The strength of the bloom.
  61113. */
  61114. bloomThreshold: number;
  61115. /**
  61116. * The scale of the bloom, lower value will provide better performance.
  61117. */
  61118. bloomScale: number;
  61119. /**
  61120. * Enable or disable the bloom from the pipeline
  61121. */
  61122. bloomEnabled: boolean;
  61123. private _rebuildBloom;
  61124. /**
  61125. * If the depth of field is enabled.
  61126. */
  61127. depthOfFieldEnabled: boolean;
  61128. /**
  61129. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61130. */
  61131. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61132. /**
  61133. * If the anti aliasing is enabled.
  61134. */
  61135. fxaaEnabled: boolean;
  61136. private _samples;
  61137. /**
  61138. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61139. */
  61140. samples: number;
  61141. /**
  61142. * If image processing is enabled.
  61143. */
  61144. imageProcessingEnabled: boolean;
  61145. /**
  61146. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61147. */
  61148. glowLayerEnabled: boolean;
  61149. /**
  61150. * Gets the glow layer (or null if not defined)
  61151. */
  61152. readonly glowLayer: Nullable<GlowLayer>;
  61153. /**
  61154. * Enable or disable the chromaticAberration process from the pipeline
  61155. */
  61156. chromaticAberrationEnabled: boolean;
  61157. /**
  61158. * Enable or disable the grain process from the pipeline
  61159. */
  61160. grainEnabled: boolean;
  61161. /**
  61162. * @constructor
  61163. * @param name - The rendering pipeline name (default: "")
  61164. * @param hdr - If high dynamic range textures should be used (default: true)
  61165. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61166. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61167. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61168. */
  61169. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61170. /**
  61171. * Get the class name
  61172. * @returns "DefaultRenderingPipeline"
  61173. */
  61174. getClassName(): string;
  61175. /**
  61176. * Force the compilation of the entire pipeline.
  61177. */
  61178. prepare(): void;
  61179. private _hasCleared;
  61180. private _prevPostProcess;
  61181. private _prevPrevPostProcess;
  61182. private _setAutoClearAndTextureSharing;
  61183. private _depthOfFieldSceneObserver;
  61184. private _buildPipeline;
  61185. private _disposePostProcesses;
  61186. /**
  61187. * Adds a camera to the pipeline
  61188. * @param camera the camera to be added
  61189. */
  61190. addCamera(camera: Camera): void;
  61191. /**
  61192. * Removes a camera from the pipeline
  61193. * @param camera the camera to remove
  61194. */
  61195. removeCamera(camera: Camera): void;
  61196. /**
  61197. * Dispose of the pipeline and stop all post processes
  61198. */
  61199. dispose(): void;
  61200. /**
  61201. * Serialize the rendering pipeline (Used when exporting)
  61202. * @returns the serialized object
  61203. */
  61204. serialize(): any;
  61205. /**
  61206. * Parse the serialized pipeline
  61207. * @param source Source pipeline.
  61208. * @param scene The scene to load the pipeline to.
  61209. * @param rootUrl The URL of the serialized pipeline.
  61210. * @returns An instantiated pipeline from the serialized object.
  61211. */
  61212. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61213. }
  61214. }
  61215. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61216. /** @hidden */
  61217. export var lensHighlightsPixelShader: {
  61218. name: string;
  61219. shader: string;
  61220. };
  61221. }
  61222. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61223. /** @hidden */
  61224. export var depthOfFieldPixelShader: {
  61225. name: string;
  61226. shader: string;
  61227. };
  61228. }
  61229. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61230. import { Camera } from "babylonjs/Cameras/camera";
  61231. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61232. import { Scene } from "babylonjs/scene";
  61233. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61234. import "babylonjs/Shaders/chromaticAberration.fragment";
  61235. import "babylonjs/Shaders/lensHighlights.fragment";
  61236. import "babylonjs/Shaders/depthOfField.fragment";
  61237. /**
  61238. * BABYLON.JS Chromatic Aberration GLSL Shader
  61239. * Author: Olivier Guyot
  61240. * Separates very slightly R, G and B colors on the edges of the screen
  61241. * Inspired by Francois Tarlier & Martins Upitis
  61242. */
  61243. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61244. /**
  61245. * @ignore
  61246. * The chromatic aberration PostProcess id in the pipeline
  61247. */
  61248. LensChromaticAberrationEffect: string;
  61249. /**
  61250. * @ignore
  61251. * The highlights enhancing PostProcess id in the pipeline
  61252. */
  61253. HighlightsEnhancingEffect: string;
  61254. /**
  61255. * @ignore
  61256. * The depth-of-field PostProcess id in the pipeline
  61257. */
  61258. LensDepthOfFieldEffect: string;
  61259. private _scene;
  61260. private _depthTexture;
  61261. private _grainTexture;
  61262. private _chromaticAberrationPostProcess;
  61263. private _highlightsPostProcess;
  61264. private _depthOfFieldPostProcess;
  61265. private _edgeBlur;
  61266. private _grainAmount;
  61267. private _chromaticAberration;
  61268. private _distortion;
  61269. private _highlightsGain;
  61270. private _highlightsThreshold;
  61271. private _dofDistance;
  61272. private _dofAperture;
  61273. private _dofDarken;
  61274. private _dofPentagon;
  61275. private _blurNoise;
  61276. /**
  61277. * @constructor
  61278. *
  61279. * Effect parameters are as follow:
  61280. * {
  61281. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61282. * edge_blur: number; // from 0 to x (1 for realism)
  61283. * distortion: number; // from 0 to x (1 for realism)
  61284. * grain_amount: number; // from 0 to 1
  61285. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61286. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61287. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61288. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61289. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61290. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61291. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61292. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61293. * }
  61294. * Note: if an effect parameter is unset, effect is disabled
  61295. *
  61296. * @param name The rendering pipeline name
  61297. * @param parameters - An object containing all parameters (see above)
  61298. * @param scene The scene linked to this pipeline
  61299. * @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)
  61300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61301. */
  61302. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61303. /**
  61304. * Get the class name
  61305. * @returns "LensRenderingPipeline"
  61306. */
  61307. getClassName(): string;
  61308. /**
  61309. * Gets associated scene
  61310. */
  61311. readonly scene: Scene;
  61312. /**
  61313. * Gets or sets the edge blur
  61314. */
  61315. edgeBlur: number;
  61316. /**
  61317. * Gets or sets the grain amount
  61318. */
  61319. grainAmount: number;
  61320. /**
  61321. * Gets or sets the chromatic aberration amount
  61322. */
  61323. chromaticAberration: number;
  61324. /**
  61325. * Gets or sets the depth of field aperture
  61326. */
  61327. dofAperture: number;
  61328. /**
  61329. * Gets or sets the edge distortion
  61330. */
  61331. edgeDistortion: number;
  61332. /**
  61333. * Gets or sets the depth of field distortion
  61334. */
  61335. dofDistortion: number;
  61336. /**
  61337. * Gets or sets the darken out of focus amount
  61338. */
  61339. darkenOutOfFocus: number;
  61340. /**
  61341. * Gets or sets a boolean indicating if blur noise is enabled
  61342. */
  61343. blurNoise: boolean;
  61344. /**
  61345. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61346. */
  61347. pentagonBokeh: boolean;
  61348. /**
  61349. * Gets or sets the highlight grain amount
  61350. */
  61351. highlightsGain: number;
  61352. /**
  61353. * Gets or sets the highlight threshold
  61354. */
  61355. highlightsThreshold: number;
  61356. /**
  61357. * Sets the amount of blur at the edges
  61358. * @param amount blur amount
  61359. */
  61360. setEdgeBlur(amount: number): void;
  61361. /**
  61362. * Sets edge blur to 0
  61363. */
  61364. disableEdgeBlur(): void;
  61365. /**
  61366. * Sets the amout of grain
  61367. * @param amount Amount of grain
  61368. */
  61369. setGrainAmount(amount: number): void;
  61370. /**
  61371. * Set grain amount to 0
  61372. */
  61373. disableGrain(): void;
  61374. /**
  61375. * Sets the chromatic aberration amount
  61376. * @param amount amount of chromatic aberration
  61377. */
  61378. setChromaticAberration(amount: number): void;
  61379. /**
  61380. * Sets chromatic aberration amount to 0
  61381. */
  61382. disableChromaticAberration(): void;
  61383. /**
  61384. * Sets the EdgeDistortion amount
  61385. * @param amount amount of EdgeDistortion
  61386. */
  61387. setEdgeDistortion(amount: number): void;
  61388. /**
  61389. * Sets edge distortion to 0
  61390. */
  61391. disableEdgeDistortion(): void;
  61392. /**
  61393. * Sets the FocusDistance amount
  61394. * @param amount amount of FocusDistance
  61395. */
  61396. setFocusDistance(amount: number): void;
  61397. /**
  61398. * Disables depth of field
  61399. */
  61400. disableDepthOfField(): void;
  61401. /**
  61402. * Sets the Aperture amount
  61403. * @param amount amount of Aperture
  61404. */
  61405. setAperture(amount: number): void;
  61406. /**
  61407. * Sets the DarkenOutOfFocus amount
  61408. * @param amount amount of DarkenOutOfFocus
  61409. */
  61410. setDarkenOutOfFocus(amount: number): void;
  61411. private _pentagonBokehIsEnabled;
  61412. /**
  61413. * Creates a pentagon bokeh effect
  61414. */
  61415. enablePentagonBokeh(): void;
  61416. /**
  61417. * Disables the pentagon bokeh effect
  61418. */
  61419. disablePentagonBokeh(): void;
  61420. /**
  61421. * Enables noise blur
  61422. */
  61423. enableNoiseBlur(): void;
  61424. /**
  61425. * Disables noise blur
  61426. */
  61427. disableNoiseBlur(): void;
  61428. /**
  61429. * Sets the HighlightsGain amount
  61430. * @param amount amount of HighlightsGain
  61431. */
  61432. setHighlightsGain(amount: number): void;
  61433. /**
  61434. * Sets the HighlightsThreshold amount
  61435. * @param amount amount of HighlightsThreshold
  61436. */
  61437. setHighlightsThreshold(amount: number): void;
  61438. /**
  61439. * Disables highlights
  61440. */
  61441. disableHighlights(): void;
  61442. /**
  61443. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61444. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61445. */
  61446. dispose(disableDepthRender?: boolean): void;
  61447. private _createChromaticAberrationPostProcess;
  61448. private _createHighlightsPostProcess;
  61449. private _createDepthOfFieldPostProcess;
  61450. private _createGrainTexture;
  61451. }
  61452. }
  61453. declare module "babylonjs/Shaders/ssao2.fragment" {
  61454. /** @hidden */
  61455. export var ssao2PixelShader: {
  61456. name: string;
  61457. shader: string;
  61458. };
  61459. }
  61460. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61461. /** @hidden */
  61462. export var ssaoCombinePixelShader: {
  61463. name: string;
  61464. shader: string;
  61465. };
  61466. }
  61467. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61468. import { Camera } from "babylonjs/Cameras/camera";
  61469. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61470. import { Scene } from "babylonjs/scene";
  61471. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61472. import "babylonjs/Shaders/ssao2.fragment";
  61473. import "babylonjs/Shaders/ssaoCombine.fragment";
  61474. /**
  61475. * Render pipeline to produce ssao effect
  61476. */
  61477. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61478. /**
  61479. * @ignore
  61480. * The PassPostProcess id in the pipeline that contains the original scene color
  61481. */
  61482. SSAOOriginalSceneColorEffect: string;
  61483. /**
  61484. * @ignore
  61485. * The SSAO PostProcess id in the pipeline
  61486. */
  61487. SSAORenderEffect: string;
  61488. /**
  61489. * @ignore
  61490. * The horizontal blur PostProcess id in the pipeline
  61491. */
  61492. SSAOBlurHRenderEffect: string;
  61493. /**
  61494. * @ignore
  61495. * The vertical blur PostProcess id in the pipeline
  61496. */
  61497. SSAOBlurVRenderEffect: string;
  61498. /**
  61499. * @ignore
  61500. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61501. */
  61502. SSAOCombineRenderEffect: string;
  61503. /**
  61504. * The output strength of the SSAO post-process. Default value is 1.0.
  61505. */
  61506. totalStrength: number;
  61507. /**
  61508. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61509. */
  61510. maxZ: number;
  61511. /**
  61512. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61513. */
  61514. minZAspect: number;
  61515. private _samples;
  61516. /**
  61517. * Number of samples used for the SSAO calculations. Default value is 8
  61518. */
  61519. samples: number;
  61520. private _textureSamples;
  61521. /**
  61522. * Number of samples to use for antialiasing
  61523. */
  61524. textureSamples: number;
  61525. /**
  61526. * Ratio object used for SSAO ratio and blur ratio
  61527. */
  61528. private _ratio;
  61529. /**
  61530. * Dynamically generated sphere sampler.
  61531. */
  61532. private _sampleSphere;
  61533. /**
  61534. * Blur filter offsets
  61535. */
  61536. private _samplerOffsets;
  61537. private _expensiveBlur;
  61538. /**
  61539. * If bilateral blur should be used
  61540. */
  61541. expensiveBlur: boolean;
  61542. /**
  61543. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61544. */
  61545. radius: number;
  61546. /**
  61547. * The base color of the SSAO post-process
  61548. * The final result is "base + ssao" between [0, 1]
  61549. */
  61550. base: number;
  61551. /**
  61552. * Support test.
  61553. */
  61554. static readonly IsSupported: boolean;
  61555. private _scene;
  61556. private _depthTexture;
  61557. private _normalTexture;
  61558. private _randomTexture;
  61559. private _originalColorPostProcess;
  61560. private _ssaoPostProcess;
  61561. private _blurHPostProcess;
  61562. private _blurVPostProcess;
  61563. private _ssaoCombinePostProcess;
  61564. private _firstUpdate;
  61565. /**
  61566. * Gets active scene
  61567. */
  61568. readonly scene: Scene;
  61569. /**
  61570. * @constructor
  61571. * @param name The rendering pipeline name
  61572. * @param scene The scene linked to this pipeline
  61573. * @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 }
  61574. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61575. */
  61576. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61577. /**
  61578. * Get the class name
  61579. * @returns "SSAO2RenderingPipeline"
  61580. */
  61581. getClassName(): string;
  61582. /**
  61583. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61584. */
  61585. dispose(disableGeometryBufferRenderer?: boolean): void;
  61586. private _createBlurPostProcess;
  61587. /** @hidden */
  61588. _rebuild(): void;
  61589. private _bits;
  61590. private _radicalInverse_VdC;
  61591. private _hammersley;
  61592. private _hemisphereSample_uniform;
  61593. private _generateHemisphere;
  61594. private _createSSAOPostProcess;
  61595. private _createSSAOCombinePostProcess;
  61596. private _createRandomTexture;
  61597. /**
  61598. * Serialize the rendering pipeline (Used when exporting)
  61599. * @returns the serialized object
  61600. */
  61601. serialize(): any;
  61602. /**
  61603. * Parse the serialized pipeline
  61604. * @param source Source pipeline.
  61605. * @param scene The scene to load the pipeline to.
  61606. * @param rootUrl The URL of the serialized pipeline.
  61607. * @returns An instantiated pipeline from the serialized object.
  61608. */
  61609. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61610. }
  61611. }
  61612. declare module "babylonjs/Shaders/ssao.fragment" {
  61613. /** @hidden */
  61614. export var ssaoPixelShader: {
  61615. name: string;
  61616. shader: string;
  61617. };
  61618. }
  61619. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61620. import { Camera } from "babylonjs/Cameras/camera";
  61621. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61622. import { Scene } from "babylonjs/scene";
  61623. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61624. import "babylonjs/Shaders/ssao.fragment";
  61625. import "babylonjs/Shaders/ssaoCombine.fragment";
  61626. /**
  61627. * Render pipeline to produce ssao effect
  61628. */
  61629. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61630. /**
  61631. * @ignore
  61632. * The PassPostProcess id in the pipeline that contains the original scene color
  61633. */
  61634. SSAOOriginalSceneColorEffect: string;
  61635. /**
  61636. * @ignore
  61637. * The SSAO PostProcess id in the pipeline
  61638. */
  61639. SSAORenderEffect: string;
  61640. /**
  61641. * @ignore
  61642. * The horizontal blur PostProcess id in the pipeline
  61643. */
  61644. SSAOBlurHRenderEffect: string;
  61645. /**
  61646. * @ignore
  61647. * The vertical blur PostProcess id in the pipeline
  61648. */
  61649. SSAOBlurVRenderEffect: string;
  61650. /**
  61651. * @ignore
  61652. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61653. */
  61654. SSAOCombineRenderEffect: string;
  61655. /**
  61656. * The output strength of the SSAO post-process. Default value is 1.0.
  61657. */
  61658. totalStrength: number;
  61659. /**
  61660. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61661. */
  61662. radius: number;
  61663. /**
  61664. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61665. * Must not be equal to fallOff and superior to fallOff.
  61666. * Default value is 0.0075
  61667. */
  61668. area: number;
  61669. /**
  61670. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61671. * Must not be equal to area and inferior to area.
  61672. * Default value is 0.000001
  61673. */
  61674. fallOff: number;
  61675. /**
  61676. * The base color of the SSAO post-process
  61677. * The final result is "base + ssao" between [0, 1]
  61678. */
  61679. base: number;
  61680. private _scene;
  61681. private _depthTexture;
  61682. private _randomTexture;
  61683. private _originalColorPostProcess;
  61684. private _ssaoPostProcess;
  61685. private _blurHPostProcess;
  61686. private _blurVPostProcess;
  61687. private _ssaoCombinePostProcess;
  61688. private _firstUpdate;
  61689. /**
  61690. * Gets active scene
  61691. */
  61692. readonly scene: Scene;
  61693. /**
  61694. * @constructor
  61695. * @param name - The rendering pipeline name
  61696. * @param scene - The scene linked to this pipeline
  61697. * @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 }
  61698. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61699. */
  61700. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61701. /**
  61702. * Get the class name
  61703. * @returns "SSAORenderingPipeline"
  61704. */
  61705. getClassName(): string;
  61706. /**
  61707. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61708. */
  61709. dispose(disableDepthRender?: boolean): void;
  61710. private _createBlurPostProcess;
  61711. /** @hidden */
  61712. _rebuild(): void;
  61713. private _createSSAOPostProcess;
  61714. private _createSSAOCombinePostProcess;
  61715. private _createRandomTexture;
  61716. }
  61717. }
  61718. declare module "babylonjs/Shaders/standard.fragment" {
  61719. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61720. /** @hidden */
  61721. export var standardPixelShader: {
  61722. name: string;
  61723. shader: string;
  61724. };
  61725. }
  61726. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61727. import { Nullable } from "babylonjs/types";
  61728. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61729. import { Camera } from "babylonjs/Cameras/camera";
  61730. import { Texture } from "babylonjs/Materials/Textures/texture";
  61731. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61732. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61733. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61734. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61735. import { IDisposable } from "babylonjs/scene";
  61736. import { SpotLight } from "babylonjs/Lights/spotLight";
  61737. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61738. import { Scene } from "babylonjs/scene";
  61739. import { Animation } from "babylonjs/Animations/animation";
  61740. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61741. import "babylonjs/Shaders/standard.fragment";
  61742. /**
  61743. * Standard rendering pipeline
  61744. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61745. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61746. */
  61747. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61748. /**
  61749. * Public members
  61750. */
  61751. /**
  61752. * Post-process which contains the original scene color before the pipeline applies all the effects
  61753. */
  61754. originalPostProcess: Nullable<PostProcess>;
  61755. /**
  61756. * Post-process used to down scale an image x4
  61757. */
  61758. downSampleX4PostProcess: Nullable<PostProcess>;
  61759. /**
  61760. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61761. */
  61762. brightPassPostProcess: Nullable<PostProcess>;
  61763. /**
  61764. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61765. */
  61766. blurHPostProcesses: PostProcess[];
  61767. /**
  61768. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61769. */
  61770. blurVPostProcesses: PostProcess[];
  61771. /**
  61772. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61773. */
  61774. textureAdderPostProcess: Nullable<PostProcess>;
  61775. /**
  61776. * Post-process used to create volumetric lighting effect
  61777. */
  61778. volumetricLightPostProcess: Nullable<PostProcess>;
  61779. /**
  61780. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61781. */
  61782. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61783. /**
  61784. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61785. */
  61786. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61787. /**
  61788. * Post-process used to merge the volumetric light effect and the real scene color
  61789. */
  61790. volumetricLightMergePostProces: Nullable<PostProcess>;
  61791. /**
  61792. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61793. */
  61794. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61795. /**
  61796. * Base post-process used to calculate the average luminance of the final image for HDR
  61797. */
  61798. luminancePostProcess: Nullable<PostProcess>;
  61799. /**
  61800. * Post-processes used to create down sample post-processes in order to get
  61801. * the average luminance of the final image for HDR
  61802. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61803. */
  61804. luminanceDownSamplePostProcesses: PostProcess[];
  61805. /**
  61806. * Post-process used to create a HDR effect (light adaptation)
  61807. */
  61808. hdrPostProcess: Nullable<PostProcess>;
  61809. /**
  61810. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61811. */
  61812. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61813. /**
  61814. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61815. */
  61816. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61817. /**
  61818. * Post-process used to merge the final HDR post-process and the real scene color
  61819. */
  61820. hdrFinalPostProcess: Nullable<PostProcess>;
  61821. /**
  61822. * Post-process used to create a lens flare effect
  61823. */
  61824. lensFlarePostProcess: Nullable<PostProcess>;
  61825. /**
  61826. * Post-process that merges the result of the lens flare post-process and the real scene color
  61827. */
  61828. lensFlareComposePostProcess: Nullable<PostProcess>;
  61829. /**
  61830. * Post-process used to create a motion blur effect
  61831. */
  61832. motionBlurPostProcess: Nullable<PostProcess>;
  61833. /**
  61834. * Post-process used to create a depth of field effect
  61835. */
  61836. depthOfFieldPostProcess: Nullable<PostProcess>;
  61837. /**
  61838. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61839. */
  61840. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61841. /**
  61842. * Represents the brightness threshold in order to configure the illuminated surfaces
  61843. */
  61844. brightThreshold: number;
  61845. /**
  61846. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61847. */
  61848. blurWidth: number;
  61849. /**
  61850. * Sets if the blur for highlighted surfaces must be only horizontal
  61851. */
  61852. horizontalBlur: boolean;
  61853. /**
  61854. * Gets the overall exposure used by the pipeline
  61855. */
  61856. /**
  61857. * Sets the overall exposure used by the pipeline
  61858. */
  61859. exposure: number;
  61860. /**
  61861. * Texture used typically to simulate "dirty" on camera lens
  61862. */
  61863. lensTexture: Nullable<Texture>;
  61864. /**
  61865. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61866. */
  61867. volumetricLightCoefficient: number;
  61868. /**
  61869. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61870. */
  61871. volumetricLightPower: number;
  61872. /**
  61873. * Used the set the blur intensity to smooth the volumetric lights
  61874. */
  61875. volumetricLightBlurScale: number;
  61876. /**
  61877. * Light (spot or directional) used to generate the volumetric lights rays
  61878. * The source light must have a shadow generate so the pipeline can get its
  61879. * depth map
  61880. */
  61881. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61882. /**
  61883. * For eye adaptation, represents the minimum luminance the eye can see
  61884. */
  61885. hdrMinimumLuminance: number;
  61886. /**
  61887. * For eye adaptation, represents the decrease luminance speed
  61888. */
  61889. hdrDecreaseRate: number;
  61890. /**
  61891. * For eye adaptation, represents the increase luminance speed
  61892. */
  61893. hdrIncreaseRate: number;
  61894. /**
  61895. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61896. */
  61897. /**
  61898. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61899. */
  61900. hdrAutoExposure: boolean;
  61901. /**
  61902. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61903. */
  61904. lensColorTexture: Nullable<Texture>;
  61905. /**
  61906. * The overall strengh for the lens flare effect
  61907. */
  61908. lensFlareStrength: number;
  61909. /**
  61910. * Dispersion coefficient for lens flare ghosts
  61911. */
  61912. lensFlareGhostDispersal: number;
  61913. /**
  61914. * Main lens flare halo width
  61915. */
  61916. lensFlareHaloWidth: number;
  61917. /**
  61918. * Based on the lens distortion effect, defines how much the lens flare result
  61919. * is distorted
  61920. */
  61921. lensFlareDistortionStrength: number;
  61922. /**
  61923. * Lens star texture must be used to simulate rays on the flares and is available
  61924. * in the documentation
  61925. */
  61926. lensStarTexture: Nullable<Texture>;
  61927. /**
  61928. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61929. * flare effect by taking account of the dirt texture
  61930. */
  61931. lensFlareDirtTexture: Nullable<Texture>;
  61932. /**
  61933. * Represents the focal length for the depth of field effect
  61934. */
  61935. depthOfFieldDistance: number;
  61936. /**
  61937. * Represents the blur intensity for the blurred part of the depth of field effect
  61938. */
  61939. depthOfFieldBlurWidth: number;
  61940. /**
  61941. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61942. */
  61943. /**
  61944. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61945. */
  61946. motionStrength: number;
  61947. /**
  61948. * Gets wether or not the motion blur post-process is object based or screen based.
  61949. */
  61950. /**
  61951. * Sets wether or not the motion blur post-process should be object based or screen based
  61952. */
  61953. objectBasedMotionBlur: boolean;
  61954. /**
  61955. * List of animations for the pipeline (IAnimatable implementation)
  61956. */
  61957. animations: Animation[];
  61958. /**
  61959. * Private members
  61960. */
  61961. private _scene;
  61962. private _currentDepthOfFieldSource;
  61963. private _basePostProcess;
  61964. private _fixedExposure;
  61965. private _currentExposure;
  61966. private _hdrAutoExposure;
  61967. private _hdrCurrentLuminance;
  61968. private _motionStrength;
  61969. private _isObjectBasedMotionBlur;
  61970. private _floatTextureType;
  61971. private _ratio;
  61972. private _bloomEnabled;
  61973. private _depthOfFieldEnabled;
  61974. private _vlsEnabled;
  61975. private _lensFlareEnabled;
  61976. private _hdrEnabled;
  61977. private _motionBlurEnabled;
  61978. private _fxaaEnabled;
  61979. private _motionBlurSamples;
  61980. private _volumetricLightStepsCount;
  61981. private _samples;
  61982. /**
  61983. * @ignore
  61984. * Specifies if the bloom pipeline is enabled
  61985. */
  61986. BloomEnabled: boolean;
  61987. /**
  61988. * @ignore
  61989. * Specifies if the depth of field pipeline is enabed
  61990. */
  61991. DepthOfFieldEnabled: boolean;
  61992. /**
  61993. * @ignore
  61994. * Specifies if the lens flare pipeline is enabed
  61995. */
  61996. LensFlareEnabled: boolean;
  61997. /**
  61998. * @ignore
  61999. * Specifies if the HDR pipeline is enabled
  62000. */
  62001. HDREnabled: boolean;
  62002. /**
  62003. * @ignore
  62004. * Specifies if the volumetric lights scattering effect is enabled
  62005. */
  62006. VLSEnabled: boolean;
  62007. /**
  62008. * @ignore
  62009. * Specifies if the motion blur effect is enabled
  62010. */
  62011. MotionBlurEnabled: boolean;
  62012. /**
  62013. * Specifies if anti-aliasing is enabled
  62014. */
  62015. fxaaEnabled: boolean;
  62016. /**
  62017. * Specifies the number of steps used to calculate the volumetric lights
  62018. * Typically in interval [50, 200]
  62019. */
  62020. volumetricLightStepsCount: number;
  62021. /**
  62022. * Specifies the number of samples used for the motion blur effect
  62023. * Typically in interval [16, 64]
  62024. */
  62025. motionBlurSamples: number;
  62026. /**
  62027. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62028. */
  62029. samples: number;
  62030. /**
  62031. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62032. * @constructor
  62033. * @param name The rendering pipeline name
  62034. * @param scene The scene linked to this pipeline
  62035. * @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)
  62036. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62037. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62038. */
  62039. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62040. private _buildPipeline;
  62041. private _createDownSampleX4PostProcess;
  62042. private _createBrightPassPostProcess;
  62043. private _createBlurPostProcesses;
  62044. private _createTextureAdderPostProcess;
  62045. private _createVolumetricLightPostProcess;
  62046. private _createLuminancePostProcesses;
  62047. private _createHdrPostProcess;
  62048. private _createLensFlarePostProcess;
  62049. private _createDepthOfFieldPostProcess;
  62050. private _createMotionBlurPostProcess;
  62051. private _getDepthTexture;
  62052. private _disposePostProcesses;
  62053. /**
  62054. * Dispose of the pipeline and stop all post processes
  62055. */
  62056. dispose(): void;
  62057. /**
  62058. * Serialize the rendering pipeline (Used when exporting)
  62059. * @returns the serialized object
  62060. */
  62061. serialize(): any;
  62062. /**
  62063. * Parse the serialized pipeline
  62064. * @param source Source pipeline.
  62065. * @param scene The scene to load the pipeline to.
  62066. * @param rootUrl The URL of the serialized pipeline.
  62067. * @returns An instantiated pipeline from the serialized object.
  62068. */
  62069. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62070. /**
  62071. * Luminance steps
  62072. */
  62073. static LuminanceSteps: number;
  62074. }
  62075. }
  62076. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62077. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62078. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62079. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62080. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62081. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62082. }
  62083. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62084. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62085. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62086. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62087. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62088. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62089. }
  62090. declare module "babylonjs/Shaders/tonemap.fragment" {
  62091. /** @hidden */
  62092. export var tonemapPixelShader: {
  62093. name: string;
  62094. shader: string;
  62095. };
  62096. }
  62097. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62098. import { Camera } from "babylonjs/Cameras/camera";
  62099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62100. import "babylonjs/Shaders/tonemap.fragment";
  62101. import { Engine } from "babylonjs/Engines/engine";
  62102. /** Defines operator used for tonemapping */
  62103. export enum TonemappingOperator {
  62104. /** Hable */
  62105. Hable = 0,
  62106. /** Reinhard */
  62107. Reinhard = 1,
  62108. /** HejiDawson */
  62109. HejiDawson = 2,
  62110. /** Photographic */
  62111. Photographic = 3
  62112. }
  62113. /**
  62114. * Defines a post process to apply tone mapping
  62115. */
  62116. export class TonemapPostProcess extends PostProcess {
  62117. private _operator;
  62118. /** Defines the required exposure adjustement */
  62119. exposureAdjustment: number;
  62120. /**
  62121. * Creates a new TonemapPostProcess
  62122. * @param name defines the name of the postprocess
  62123. * @param _operator defines the operator to use
  62124. * @param exposureAdjustment defines the required exposure adjustement
  62125. * @param camera defines the camera to use (can be null)
  62126. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62127. * @param engine defines the hosting engine (can be ignore if camera is set)
  62128. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62129. */
  62130. constructor(name: string, _operator: TonemappingOperator,
  62131. /** Defines the required exposure adjustement */
  62132. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62133. }
  62134. }
  62135. declare module "babylonjs/Shaders/depth.vertex" {
  62136. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62137. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62139. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62140. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62141. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62142. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62143. /** @hidden */
  62144. export var depthVertexShader: {
  62145. name: string;
  62146. shader: string;
  62147. };
  62148. }
  62149. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62150. /** @hidden */
  62151. export var volumetricLightScatteringPixelShader: {
  62152. name: string;
  62153. shader: string;
  62154. };
  62155. }
  62156. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62157. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62158. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62159. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62160. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62162. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62163. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62164. /** @hidden */
  62165. export var volumetricLightScatteringPassVertexShader: {
  62166. name: string;
  62167. shader: string;
  62168. };
  62169. }
  62170. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62171. /** @hidden */
  62172. export var volumetricLightScatteringPassPixelShader: {
  62173. name: string;
  62174. shader: string;
  62175. };
  62176. }
  62177. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62178. import { Vector3 } from "babylonjs/Maths/math.vector";
  62179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62180. import { Mesh } from "babylonjs/Meshes/mesh";
  62181. import { Camera } from "babylonjs/Cameras/camera";
  62182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62183. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62184. import { Scene } from "babylonjs/scene";
  62185. import "babylonjs/Meshes/Builders/planeBuilder";
  62186. import "babylonjs/Shaders/depth.vertex";
  62187. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62188. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62189. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62190. import { Engine } from "babylonjs/Engines/engine";
  62191. /**
  62192. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62193. */
  62194. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62195. private _volumetricLightScatteringPass;
  62196. private _volumetricLightScatteringRTT;
  62197. private _viewPort;
  62198. private _screenCoordinates;
  62199. private _cachedDefines;
  62200. /**
  62201. * If not undefined, the mesh position is computed from the attached node position
  62202. */
  62203. attachedNode: {
  62204. position: Vector3;
  62205. };
  62206. /**
  62207. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62208. */
  62209. customMeshPosition: Vector3;
  62210. /**
  62211. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62212. */
  62213. useCustomMeshPosition: boolean;
  62214. /**
  62215. * If the post-process should inverse the light scattering direction
  62216. */
  62217. invert: boolean;
  62218. /**
  62219. * The internal mesh used by the post-process
  62220. */
  62221. mesh: Mesh;
  62222. /**
  62223. * @hidden
  62224. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62225. */
  62226. useDiffuseColor: boolean;
  62227. /**
  62228. * Array containing the excluded meshes not rendered in the internal pass
  62229. */
  62230. excludedMeshes: AbstractMesh[];
  62231. /**
  62232. * Controls the overall intensity of the post-process
  62233. */
  62234. exposure: number;
  62235. /**
  62236. * Dissipates each sample's contribution in range [0, 1]
  62237. */
  62238. decay: number;
  62239. /**
  62240. * Controls the overall intensity of each sample
  62241. */
  62242. weight: number;
  62243. /**
  62244. * Controls the density of each sample
  62245. */
  62246. density: number;
  62247. /**
  62248. * @constructor
  62249. * @param name The post-process name
  62250. * @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)
  62251. * @param camera The camera that the post-process will be attached to
  62252. * @param mesh The mesh used to create the light scattering
  62253. * @param samples The post-process quality, default 100
  62254. * @param samplingModeThe post-process filtering mode
  62255. * @param engine The babylon engine
  62256. * @param reusable If the post-process is reusable
  62257. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62258. */
  62259. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62260. /**
  62261. * Returns the string "VolumetricLightScatteringPostProcess"
  62262. * @returns "VolumetricLightScatteringPostProcess"
  62263. */
  62264. getClassName(): string;
  62265. private _isReady;
  62266. /**
  62267. * Sets the new light position for light scattering effect
  62268. * @param position The new custom light position
  62269. */
  62270. setCustomMeshPosition(position: Vector3): void;
  62271. /**
  62272. * Returns the light position for light scattering effect
  62273. * @return Vector3 The custom light position
  62274. */
  62275. getCustomMeshPosition(): Vector3;
  62276. /**
  62277. * Disposes the internal assets and detaches the post-process from the camera
  62278. */
  62279. dispose(camera: Camera): void;
  62280. /**
  62281. * Returns the render target texture used by the post-process
  62282. * @return the render target texture used by the post-process
  62283. */
  62284. getPass(): RenderTargetTexture;
  62285. private _meshExcluded;
  62286. private _createPass;
  62287. private _updateMeshScreenCoordinates;
  62288. /**
  62289. * Creates a default mesh for the Volumeric Light Scattering post-process
  62290. * @param name The mesh name
  62291. * @param scene The scene where to create the mesh
  62292. * @return the default mesh
  62293. */
  62294. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62295. }
  62296. }
  62297. declare module "babylonjs/PostProcesses/index" {
  62298. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62299. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62300. export * from "babylonjs/PostProcesses/bloomEffect";
  62301. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62302. export * from "babylonjs/PostProcesses/blurPostProcess";
  62303. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62304. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62305. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62306. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62307. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62308. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62309. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62310. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62311. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62312. export * from "babylonjs/PostProcesses/filterPostProcess";
  62313. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62314. export * from "babylonjs/PostProcesses/grainPostProcess";
  62315. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62316. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62317. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62318. export * from "babylonjs/PostProcesses/passPostProcess";
  62319. export * from "babylonjs/PostProcesses/postProcess";
  62320. export * from "babylonjs/PostProcesses/postProcessManager";
  62321. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62322. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62323. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62324. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62325. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62326. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62327. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62328. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62329. }
  62330. declare module "babylonjs/Probes/index" {
  62331. export * from "babylonjs/Probes/reflectionProbe";
  62332. }
  62333. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62334. import { Scene } from "babylonjs/scene";
  62335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62336. import { SmartArray } from "babylonjs/Misc/smartArray";
  62337. import { ISceneComponent } from "babylonjs/sceneComponent";
  62338. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62339. import "babylonjs/Meshes/Builders/boxBuilder";
  62340. import "babylonjs/Shaders/color.fragment";
  62341. import "babylonjs/Shaders/color.vertex";
  62342. import { Color3 } from "babylonjs/Maths/math.color";
  62343. module "babylonjs/scene" {
  62344. interface Scene {
  62345. /** @hidden (Backing field) */
  62346. _boundingBoxRenderer: BoundingBoxRenderer;
  62347. /** @hidden (Backing field) */
  62348. _forceShowBoundingBoxes: boolean;
  62349. /**
  62350. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62351. */
  62352. forceShowBoundingBoxes: boolean;
  62353. /**
  62354. * Gets the bounding box renderer associated with the scene
  62355. * @returns a BoundingBoxRenderer
  62356. */
  62357. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62358. }
  62359. }
  62360. module "babylonjs/Meshes/abstractMesh" {
  62361. interface AbstractMesh {
  62362. /** @hidden (Backing field) */
  62363. _showBoundingBox: boolean;
  62364. /**
  62365. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62366. */
  62367. showBoundingBox: boolean;
  62368. }
  62369. }
  62370. /**
  62371. * Component responsible of rendering the bounding box of the meshes in a scene.
  62372. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62373. */
  62374. export class BoundingBoxRenderer implements ISceneComponent {
  62375. /**
  62376. * The component name helpfull to identify the component in the list of scene components.
  62377. */
  62378. readonly name: string;
  62379. /**
  62380. * The scene the component belongs to.
  62381. */
  62382. scene: Scene;
  62383. /**
  62384. * Color of the bounding box lines placed in front of an object
  62385. */
  62386. frontColor: Color3;
  62387. /**
  62388. * Color of the bounding box lines placed behind an object
  62389. */
  62390. backColor: Color3;
  62391. /**
  62392. * Defines if the renderer should show the back lines or not
  62393. */
  62394. showBackLines: boolean;
  62395. /**
  62396. * @hidden
  62397. */
  62398. renderList: SmartArray<BoundingBox>;
  62399. private _colorShader;
  62400. private _vertexBuffers;
  62401. private _indexBuffer;
  62402. private _fillIndexBuffer;
  62403. private _fillIndexData;
  62404. /**
  62405. * Instantiates a new bounding box renderer in a scene.
  62406. * @param scene the scene the renderer renders in
  62407. */
  62408. constructor(scene: Scene);
  62409. /**
  62410. * Registers the component in a given scene
  62411. */
  62412. register(): void;
  62413. private _evaluateSubMesh;
  62414. private _activeMesh;
  62415. private _prepareRessources;
  62416. private _createIndexBuffer;
  62417. /**
  62418. * Rebuilds the elements related to this component in case of
  62419. * context lost for instance.
  62420. */
  62421. rebuild(): void;
  62422. /**
  62423. * @hidden
  62424. */
  62425. reset(): void;
  62426. /**
  62427. * Render the bounding boxes of a specific rendering group
  62428. * @param renderingGroupId defines the rendering group to render
  62429. */
  62430. render(renderingGroupId: number): void;
  62431. /**
  62432. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62433. * @param mesh Define the mesh to render the occlusion bounding box for
  62434. */
  62435. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62436. /**
  62437. * Dispose and release the resources attached to this renderer.
  62438. */
  62439. dispose(): void;
  62440. }
  62441. }
  62442. declare module "babylonjs/Shaders/depth.fragment" {
  62443. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62444. /** @hidden */
  62445. export var depthPixelShader: {
  62446. name: string;
  62447. shader: string;
  62448. };
  62449. }
  62450. declare module "babylonjs/Rendering/depthRenderer" {
  62451. import { Nullable } from "babylonjs/types";
  62452. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62453. import { Scene } from "babylonjs/scene";
  62454. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62455. import { Camera } from "babylonjs/Cameras/camera";
  62456. import "babylonjs/Shaders/depth.fragment";
  62457. import "babylonjs/Shaders/depth.vertex";
  62458. /**
  62459. * This represents a depth renderer in Babylon.
  62460. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62461. */
  62462. export class DepthRenderer {
  62463. private _scene;
  62464. private _depthMap;
  62465. private _effect;
  62466. private readonly _storeNonLinearDepth;
  62467. private readonly _clearColor;
  62468. /** Get if the depth renderer is using packed depth or not */
  62469. readonly isPacked: boolean;
  62470. private _cachedDefines;
  62471. private _camera;
  62472. /**
  62473. * Specifiess that the depth renderer will only be used within
  62474. * the camera it is created for.
  62475. * This can help forcing its rendering during the camera processing.
  62476. */
  62477. useOnlyInActiveCamera: boolean;
  62478. /** @hidden */
  62479. static _SceneComponentInitialization: (scene: Scene) => void;
  62480. /**
  62481. * Instantiates a depth renderer
  62482. * @param scene The scene the renderer belongs to
  62483. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62484. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62485. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62486. */
  62487. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62488. /**
  62489. * Creates the depth rendering effect and checks if the effect is ready.
  62490. * @param subMesh The submesh to be used to render the depth map of
  62491. * @param useInstances If multiple world instances should be used
  62492. * @returns if the depth renderer is ready to render the depth map
  62493. */
  62494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62495. /**
  62496. * Gets the texture which the depth map will be written to.
  62497. * @returns The depth map texture
  62498. */
  62499. getDepthMap(): RenderTargetTexture;
  62500. /**
  62501. * Disposes of the depth renderer.
  62502. */
  62503. dispose(): void;
  62504. }
  62505. }
  62506. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62507. import { Nullable } from "babylonjs/types";
  62508. import { Scene } from "babylonjs/scene";
  62509. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62510. import { Camera } from "babylonjs/Cameras/camera";
  62511. import { ISceneComponent } from "babylonjs/sceneComponent";
  62512. module "babylonjs/scene" {
  62513. interface Scene {
  62514. /** @hidden (Backing field) */
  62515. _depthRenderer: {
  62516. [id: string]: DepthRenderer;
  62517. };
  62518. /**
  62519. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62520. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62521. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62522. * @returns the created depth renderer
  62523. */
  62524. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62525. /**
  62526. * Disables a depth renderer for a given camera
  62527. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62528. */
  62529. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62530. }
  62531. }
  62532. /**
  62533. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62534. * in several rendering techniques.
  62535. */
  62536. export class DepthRendererSceneComponent implements ISceneComponent {
  62537. /**
  62538. * The component name helpfull to identify the component in the list of scene components.
  62539. */
  62540. readonly name: string;
  62541. /**
  62542. * The scene the component belongs to.
  62543. */
  62544. scene: Scene;
  62545. /**
  62546. * Creates a new instance of the component for the given scene
  62547. * @param scene Defines the scene to register the component in
  62548. */
  62549. constructor(scene: Scene);
  62550. /**
  62551. * Registers the component in a given scene
  62552. */
  62553. register(): void;
  62554. /**
  62555. * Rebuilds the elements related to this component in case of
  62556. * context lost for instance.
  62557. */
  62558. rebuild(): void;
  62559. /**
  62560. * Disposes the component and the associated ressources
  62561. */
  62562. dispose(): void;
  62563. private _gatherRenderTargets;
  62564. private _gatherActiveCameraRenderTargets;
  62565. }
  62566. }
  62567. declare module "babylonjs/Shaders/outline.fragment" {
  62568. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62569. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62570. /** @hidden */
  62571. export var outlinePixelShader: {
  62572. name: string;
  62573. shader: string;
  62574. };
  62575. }
  62576. declare module "babylonjs/Shaders/outline.vertex" {
  62577. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62580. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62581. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62583. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62584. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62585. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62586. /** @hidden */
  62587. export var outlineVertexShader: {
  62588. name: string;
  62589. shader: string;
  62590. };
  62591. }
  62592. declare module "babylonjs/Rendering/outlineRenderer" {
  62593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62594. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62595. import { Scene } from "babylonjs/scene";
  62596. import { ISceneComponent } from "babylonjs/sceneComponent";
  62597. import "babylonjs/Shaders/outline.fragment";
  62598. import "babylonjs/Shaders/outline.vertex";
  62599. module "babylonjs/scene" {
  62600. interface Scene {
  62601. /** @hidden */
  62602. _outlineRenderer: OutlineRenderer;
  62603. /**
  62604. * Gets the outline renderer associated with the scene
  62605. * @returns a OutlineRenderer
  62606. */
  62607. getOutlineRenderer(): OutlineRenderer;
  62608. }
  62609. }
  62610. module "babylonjs/Meshes/abstractMesh" {
  62611. interface AbstractMesh {
  62612. /** @hidden (Backing field) */
  62613. _renderOutline: boolean;
  62614. /**
  62615. * Gets or sets a boolean indicating if the outline must be rendered as well
  62616. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62617. */
  62618. renderOutline: boolean;
  62619. /** @hidden (Backing field) */
  62620. _renderOverlay: boolean;
  62621. /**
  62622. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62623. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62624. */
  62625. renderOverlay: boolean;
  62626. }
  62627. }
  62628. /**
  62629. * This class is responsible to draw bothe outline/overlay of meshes.
  62630. * It should not be used directly but through the available method on mesh.
  62631. */
  62632. export class OutlineRenderer implements ISceneComponent {
  62633. /**
  62634. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62635. */
  62636. private static _StencilReference;
  62637. /**
  62638. * The name of the component. Each component must have a unique name.
  62639. */
  62640. name: string;
  62641. /**
  62642. * The scene the component belongs to.
  62643. */
  62644. scene: Scene;
  62645. /**
  62646. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62647. */
  62648. zOffset: number;
  62649. private _engine;
  62650. private _effect;
  62651. private _cachedDefines;
  62652. private _savedDepthWrite;
  62653. /**
  62654. * Instantiates a new outline renderer. (There could be only one per scene).
  62655. * @param scene Defines the scene it belongs to
  62656. */
  62657. constructor(scene: Scene);
  62658. /**
  62659. * Register the component to one instance of a scene.
  62660. */
  62661. register(): void;
  62662. /**
  62663. * Rebuilds the elements related to this component in case of
  62664. * context lost for instance.
  62665. */
  62666. rebuild(): void;
  62667. /**
  62668. * Disposes the component and the associated ressources.
  62669. */
  62670. dispose(): void;
  62671. /**
  62672. * Renders the outline in the canvas.
  62673. * @param subMesh Defines the sumesh to render
  62674. * @param batch Defines the batch of meshes in case of instances
  62675. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62676. */
  62677. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62678. /**
  62679. * Returns whether or not the outline renderer is ready for a given submesh.
  62680. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62681. * @param subMesh Defines the submesh to check readyness for
  62682. * @param useInstances Defines wheter wee are trying to render instances or not
  62683. * @returns true if ready otherwise false
  62684. */
  62685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62686. private _beforeRenderingMesh;
  62687. private _afterRenderingMesh;
  62688. }
  62689. }
  62690. declare module "babylonjs/Rendering/index" {
  62691. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62692. export * from "babylonjs/Rendering/depthRenderer";
  62693. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62694. export * from "babylonjs/Rendering/edgesRenderer";
  62695. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62696. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62697. export * from "babylonjs/Rendering/outlineRenderer";
  62698. export * from "babylonjs/Rendering/renderingGroup";
  62699. export * from "babylonjs/Rendering/renderingManager";
  62700. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62701. }
  62702. declare module "babylonjs/Sprites/spritePackedManager" {
  62703. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  62704. import { Scene } from "babylonjs/scene";
  62705. /**
  62706. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62707. * @see http://doc.babylonjs.com/babylon101/sprites
  62708. */
  62709. export class SpritePackedManager extends SpriteManager {
  62710. /** defines the packed manager's name */
  62711. name: string;
  62712. /**
  62713. * Creates a new sprite manager from a packed sprite sheet
  62714. * @param name defines the manager's name
  62715. * @param imgUrl defines the sprite sheet url
  62716. * @param capacity defines the maximum allowed number of sprites
  62717. * @param scene defines the hosting scene
  62718. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62719. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62720. * @param samplingMode defines the smapling mode to use with spritesheet
  62721. * @param fromPacked set to true; do not alter
  62722. */
  62723. constructor(
  62724. /** defines the packed manager's name */
  62725. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62726. }
  62727. }
  62728. declare module "babylonjs/Sprites/index" {
  62729. export * from "babylonjs/Sprites/sprite";
  62730. export * from "babylonjs/Sprites/spriteManager";
  62731. export * from "babylonjs/Sprites/spritePackedManager";
  62732. export * from "babylonjs/Sprites/spriteSceneComponent";
  62733. }
  62734. declare module "babylonjs/Misc/assetsManager" {
  62735. import { Scene } from "babylonjs/scene";
  62736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62738. import { Skeleton } from "babylonjs/Bones/skeleton";
  62739. import { Observable } from "babylonjs/Misc/observable";
  62740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62741. import { Texture } from "babylonjs/Materials/Textures/texture";
  62742. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62743. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62744. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62745. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62746. /**
  62747. * Defines the list of states available for a task inside a AssetsManager
  62748. */
  62749. export enum AssetTaskState {
  62750. /**
  62751. * Initialization
  62752. */
  62753. INIT = 0,
  62754. /**
  62755. * Running
  62756. */
  62757. RUNNING = 1,
  62758. /**
  62759. * Done
  62760. */
  62761. DONE = 2,
  62762. /**
  62763. * Error
  62764. */
  62765. ERROR = 3
  62766. }
  62767. /**
  62768. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62769. */
  62770. export abstract class AbstractAssetTask {
  62771. /**
  62772. * Task name
  62773. */ name: string;
  62774. /**
  62775. * Callback called when the task is successful
  62776. */
  62777. onSuccess: (task: any) => void;
  62778. /**
  62779. * Callback called when the task is not successful
  62780. */
  62781. onError: (task: any, message?: string, exception?: any) => void;
  62782. /**
  62783. * Creates a new AssetsManager
  62784. * @param name defines the name of the task
  62785. */
  62786. constructor(
  62787. /**
  62788. * Task name
  62789. */ name: string);
  62790. private _isCompleted;
  62791. private _taskState;
  62792. private _errorObject;
  62793. /**
  62794. * Get if the task is completed
  62795. */
  62796. readonly isCompleted: boolean;
  62797. /**
  62798. * Gets the current state of the task
  62799. */
  62800. readonly taskState: AssetTaskState;
  62801. /**
  62802. * Gets the current error object (if task is in error)
  62803. */
  62804. readonly errorObject: {
  62805. message?: string;
  62806. exception?: any;
  62807. };
  62808. /**
  62809. * Internal only
  62810. * @hidden
  62811. */
  62812. _setErrorObject(message?: string, exception?: any): void;
  62813. /**
  62814. * Execute the current task
  62815. * @param scene defines the scene where you want your assets to be loaded
  62816. * @param onSuccess is a callback called when the task is successfully executed
  62817. * @param onError is a callback called if an error occurs
  62818. */
  62819. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62820. /**
  62821. * Execute the current task
  62822. * @param scene defines the scene where you want your assets to be loaded
  62823. * @param onSuccess is a callback called when the task is successfully executed
  62824. * @param onError is a callback called if an error occurs
  62825. */
  62826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62827. /**
  62828. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62829. * This can be used with failed tasks that have the reason for failure fixed.
  62830. */
  62831. reset(): void;
  62832. private onErrorCallback;
  62833. private onDoneCallback;
  62834. }
  62835. /**
  62836. * Define the interface used by progress events raised during assets loading
  62837. */
  62838. export interface IAssetsProgressEvent {
  62839. /**
  62840. * Defines the number of remaining tasks to process
  62841. */
  62842. remainingCount: number;
  62843. /**
  62844. * Defines the total number of tasks
  62845. */
  62846. totalCount: number;
  62847. /**
  62848. * Defines the task that was just processed
  62849. */
  62850. task: AbstractAssetTask;
  62851. }
  62852. /**
  62853. * Class used to share progress information about assets loading
  62854. */
  62855. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62856. /**
  62857. * Defines the number of remaining tasks to process
  62858. */
  62859. remainingCount: number;
  62860. /**
  62861. * Defines the total number of tasks
  62862. */
  62863. totalCount: number;
  62864. /**
  62865. * Defines the task that was just processed
  62866. */
  62867. task: AbstractAssetTask;
  62868. /**
  62869. * Creates a AssetsProgressEvent
  62870. * @param remainingCount defines the number of remaining tasks to process
  62871. * @param totalCount defines the total number of tasks
  62872. * @param task defines the task that was just processed
  62873. */
  62874. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62875. }
  62876. /**
  62877. * Define a task used by AssetsManager to load meshes
  62878. */
  62879. export class MeshAssetTask extends AbstractAssetTask {
  62880. /**
  62881. * Defines the name of the task
  62882. */
  62883. name: string;
  62884. /**
  62885. * Defines the list of mesh's names you want to load
  62886. */
  62887. meshesNames: any;
  62888. /**
  62889. * Defines the root url to use as a base to load your meshes and associated resources
  62890. */
  62891. rootUrl: string;
  62892. /**
  62893. * Defines the filename of the scene to load from
  62894. */
  62895. sceneFilename: string;
  62896. /**
  62897. * Gets the list of loaded meshes
  62898. */
  62899. loadedMeshes: Array<AbstractMesh>;
  62900. /**
  62901. * Gets the list of loaded particle systems
  62902. */
  62903. loadedParticleSystems: Array<IParticleSystem>;
  62904. /**
  62905. * Gets the list of loaded skeletons
  62906. */
  62907. loadedSkeletons: Array<Skeleton>;
  62908. /**
  62909. * Gets the list of loaded animation groups
  62910. */
  62911. loadedAnimationGroups: Array<AnimationGroup>;
  62912. /**
  62913. * Callback called when the task is successful
  62914. */
  62915. onSuccess: (task: MeshAssetTask) => void;
  62916. /**
  62917. * Callback called when the task is successful
  62918. */
  62919. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62920. /**
  62921. * Creates a new MeshAssetTask
  62922. * @param name defines the name of the task
  62923. * @param meshesNames defines the list of mesh's names you want to load
  62924. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62925. * @param sceneFilename defines the filename of the scene to load from
  62926. */
  62927. constructor(
  62928. /**
  62929. * Defines the name of the task
  62930. */
  62931. name: string,
  62932. /**
  62933. * Defines the list of mesh's names you want to load
  62934. */
  62935. meshesNames: any,
  62936. /**
  62937. * Defines the root url to use as a base to load your meshes and associated resources
  62938. */
  62939. rootUrl: string,
  62940. /**
  62941. * Defines the filename of the scene to load from
  62942. */
  62943. sceneFilename: string);
  62944. /**
  62945. * Execute the current task
  62946. * @param scene defines the scene where you want your assets to be loaded
  62947. * @param onSuccess is a callback called when the task is successfully executed
  62948. * @param onError is a callback called if an error occurs
  62949. */
  62950. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62951. }
  62952. /**
  62953. * Define a task used by AssetsManager to load text content
  62954. */
  62955. export class TextFileAssetTask extends AbstractAssetTask {
  62956. /**
  62957. * Defines the name of the task
  62958. */
  62959. name: string;
  62960. /**
  62961. * Defines the location of the file to load
  62962. */
  62963. url: string;
  62964. /**
  62965. * Gets the loaded text string
  62966. */
  62967. text: string;
  62968. /**
  62969. * Callback called when the task is successful
  62970. */
  62971. onSuccess: (task: TextFileAssetTask) => void;
  62972. /**
  62973. * Callback called when the task is successful
  62974. */
  62975. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62976. /**
  62977. * Creates a new TextFileAssetTask object
  62978. * @param name defines the name of the task
  62979. * @param url defines the location of the file to load
  62980. */
  62981. constructor(
  62982. /**
  62983. * Defines the name of the task
  62984. */
  62985. name: string,
  62986. /**
  62987. * Defines the location of the file to load
  62988. */
  62989. url: string);
  62990. /**
  62991. * Execute the current task
  62992. * @param scene defines the scene where you want your assets to be loaded
  62993. * @param onSuccess is a callback called when the task is successfully executed
  62994. * @param onError is a callback called if an error occurs
  62995. */
  62996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62997. }
  62998. /**
  62999. * Define a task used by AssetsManager to load binary data
  63000. */
  63001. export class BinaryFileAssetTask extends AbstractAssetTask {
  63002. /**
  63003. * Defines the name of the task
  63004. */
  63005. name: string;
  63006. /**
  63007. * Defines the location of the file to load
  63008. */
  63009. url: string;
  63010. /**
  63011. * Gets the lodaded data (as an array buffer)
  63012. */
  63013. data: ArrayBuffer;
  63014. /**
  63015. * Callback called when the task is successful
  63016. */
  63017. onSuccess: (task: BinaryFileAssetTask) => void;
  63018. /**
  63019. * Callback called when the task is successful
  63020. */
  63021. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63022. /**
  63023. * Creates a new BinaryFileAssetTask object
  63024. * @param name defines the name of the new task
  63025. * @param url defines the location of the file to load
  63026. */
  63027. constructor(
  63028. /**
  63029. * Defines the name of the task
  63030. */
  63031. name: string,
  63032. /**
  63033. * Defines the location of the file to load
  63034. */
  63035. url: string);
  63036. /**
  63037. * Execute the current task
  63038. * @param scene defines the scene where you want your assets to be loaded
  63039. * @param onSuccess is a callback called when the task is successfully executed
  63040. * @param onError is a callback called if an error occurs
  63041. */
  63042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63043. }
  63044. /**
  63045. * Define a task used by AssetsManager to load images
  63046. */
  63047. export class ImageAssetTask extends AbstractAssetTask {
  63048. /**
  63049. * Defines the name of the task
  63050. */
  63051. name: string;
  63052. /**
  63053. * Defines the location of the image to load
  63054. */
  63055. url: string;
  63056. /**
  63057. * Gets the loaded images
  63058. */
  63059. image: HTMLImageElement;
  63060. /**
  63061. * Callback called when the task is successful
  63062. */
  63063. onSuccess: (task: ImageAssetTask) => void;
  63064. /**
  63065. * Callback called when the task is successful
  63066. */
  63067. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63068. /**
  63069. * Creates a new ImageAssetTask
  63070. * @param name defines the name of the task
  63071. * @param url defines the location of the image to load
  63072. */
  63073. constructor(
  63074. /**
  63075. * Defines the name of the task
  63076. */
  63077. name: string,
  63078. /**
  63079. * Defines the location of the image to load
  63080. */
  63081. url: string);
  63082. /**
  63083. * Execute the current task
  63084. * @param scene defines the scene where you want your assets to be loaded
  63085. * @param onSuccess is a callback called when the task is successfully executed
  63086. * @param onError is a callback called if an error occurs
  63087. */
  63088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63089. }
  63090. /**
  63091. * Defines the interface used by texture loading tasks
  63092. */
  63093. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63094. /**
  63095. * Gets the loaded texture
  63096. */
  63097. texture: TEX;
  63098. }
  63099. /**
  63100. * Define a task used by AssetsManager to load 2D textures
  63101. */
  63102. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63103. /**
  63104. * Defines the name of the task
  63105. */
  63106. name: string;
  63107. /**
  63108. * Defines the location of the file to load
  63109. */
  63110. url: string;
  63111. /**
  63112. * Defines if mipmap should not be generated (default is false)
  63113. */
  63114. noMipmap?: boolean | undefined;
  63115. /**
  63116. * Defines if texture must be inverted on Y axis (default is false)
  63117. */
  63118. invertY?: boolean | undefined;
  63119. /**
  63120. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63121. */
  63122. samplingMode: number;
  63123. /**
  63124. * Gets the loaded texture
  63125. */
  63126. texture: Texture;
  63127. /**
  63128. * Callback called when the task is successful
  63129. */
  63130. onSuccess: (task: TextureAssetTask) => void;
  63131. /**
  63132. * Callback called when the task is successful
  63133. */
  63134. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63135. /**
  63136. * Creates a new TextureAssetTask object
  63137. * @param name defines the name of the task
  63138. * @param url defines the location of the file to load
  63139. * @param noMipmap defines if mipmap should not be generated (default is false)
  63140. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63141. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63142. */
  63143. constructor(
  63144. /**
  63145. * Defines the name of the task
  63146. */
  63147. name: string,
  63148. /**
  63149. * Defines the location of the file to load
  63150. */
  63151. url: string,
  63152. /**
  63153. * Defines if mipmap should not be generated (default is false)
  63154. */
  63155. noMipmap?: boolean | undefined,
  63156. /**
  63157. * Defines if texture must be inverted on Y axis (default is false)
  63158. */
  63159. invertY?: boolean | undefined,
  63160. /**
  63161. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63162. */
  63163. samplingMode?: number);
  63164. /**
  63165. * Execute the current task
  63166. * @param scene defines the scene where you want your assets to be loaded
  63167. * @param onSuccess is a callback called when the task is successfully executed
  63168. * @param onError is a callback called if an error occurs
  63169. */
  63170. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63171. }
  63172. /**
  63173. * Define a task used by AssetsManager to load cube textures
  63174. */
  63175. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63176. /**
  63177. * Defines the name of the task
  63178. */
  63179. name: string;
  63180. /**
  63181. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63182. */
  63183. url: string;
  63184. /**
  63185. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63186. */
  63187. extensions?: string[] | undefined;
  63188. /**
  63189. * Defines if mipmaps should not be generated (default is false)
  63190. */
  63191. noMipmap?: boolean | undefined;
  63192. /**
  63193. * Defines the explicit list of files (undefined by default)
  63194. */
  63195. files?: string[] | undefined;
  63196. /**
  63197. * Gets the loaded texture
  63198. */
  63199. texture: CubeTexture;
  63200. /**
  63201. * Callback called when the task is successful
  63202. */
  63203. onSuccess: (task: CubeTextureAssetTask) => void;
  63204. /**
  63205. * Callback called when the task is successful
  63206. */
  63207. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63208. /**
  63209. * Creates a new CubeTextureAssetTask
  63210. * @param name defines the name of the task
  63211. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63212. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63213. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63214. * @param files defines the explicit list of files (undefined by default)
  63215. */
  63216. constructor(
  63217. /**
  63218. * Defines the name of the task
  63219. */
  63220. name: string,
  63221. /**
  63222. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63223. */
  63224. url: string,
  63225. /**
  63226. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63227. */
  63228. extensions?: string[] | undefined,
  63229. /**
  63230. * Defines if mipmaps should not be generated (default is false)
  63231. */
  63232. noMipmap?: boolean | undefined,
  63233. /**
  63234. * Defines the explicit list of files (undefined by default)
  63235. */
  63236. files?: string[] | undefined);
  63237. /**
  63238. * Execute the current task
  63239. * @param scene defines the scene where you want your assets to be loaded
  63240. * @param onSuccess is a callback called when the task is successfully executed
  63241. * @param onError is a callback called if an error occurs
  63242. */
  63243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63244. }
  63245. /**
  63246. * Define a task used by AssetsManager to load HDR cube textures
  63247. */
  63248. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63249. /**
  63250. * Defines the name of the task
  63251. */
  63252. name: string;
  63253. /**
  63254. * Defines the location of the file to load
  63255. */
  63256. url: string;
  63257. /**
  63258. * Defines the desired size (the more it increases the longer the generation will be)
  63259. */
  63260. size: number;
  63261. /**
  63262. * Defines if mipmaps should not be generated (default is false)
  63263. */
  63264. noMipmap: boolean;
  63265. /**
  63266. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63267. */
  63268. generateHarmonics: boolean;
  63269. /**
  63270. * 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)
  63271. */
  63272. gammaSpace: boolean;
  63273. /**
  63274. * Internal Use Only
  63275. */
  63276. reserved: boolean;
  63277. /**
  63278. * Gets the loaded texture
  63279. */
  63280. texture: HDRCubeTexture;
  63281. /**
  63282. * Callback called when the task is successful
  63283. */
  63284. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63285. /**
  63286. * Callback called when the task is successful
  63287. */
  63288. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63289. /**
  63290. * Creates a new HDRCubeTextureAssetTask object
  63291. * @param name defines the name of the task
  63292. * @param url defines the location of the file to load
  63293. * @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.
  63294. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63295. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63296. * @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)
  63297. * @param reserved Internal use only
  63298. */
  63299. constructor(
  63300. /**
  63301. * Defines the name of the task
  63302. */
  63303. name: string,
  63304. /**
  63305. * Defines the location of the file to load
  63306. */
  63307. url: string,
  63308. /**
  63309. * Defines the desired size (the more it increases the longer the generation will be)
  63310. */
  63311. size: number,
  63312. /**
  63313. * Defines if mipmaps should not be generated (default is false)
  63314. */
  63315. noMipmap?: boolean,
  63316. /**
  63317. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63318. */
  63319. generateHarmonics?: boolean,
  63320. /**
  63321. * 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)
  63322. */
  63323. gammaSpace?: boolean,
  63324. /**
  63325. * Internal Use Only
  63326. */
  63327. reserved?: boolean);
  63328. /**
  63329. * Execute the current task
  63330. * @param scene defines the scene where you want your assets to be loaded
  63331. * @param onSuccess is a callback called when the task is successfully executed
  63332. * @param onError is a callback called if an error occurs
  63333. */
  63334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63335. }
  63336. /**
  63337. * Define a task used by AssetsManager to load Equirectangular cube textures
  63338. */
  63339. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63340. /**
  63341. * Defines the name of the task
  63342. */
  63343. name: string;
  63344. /**
  63345. * Defines the location of the file to load
  63346. */
  63347. url: string;
  63348. /**
  63349. * Defines the desired size (the more it increases the longer the generation will be)
  63350. */
  63351. size: number;
  63352. /**
  63353. * Defines if mipmaps should not be generated (default is false)
  63354. */
  63355. noMipmap: boolean;
  63356. /**
  63357. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63358. * but the standard material would require them in Gamma space) (default is true)
  63359. */
  63360. gammaSpace: boolean;
  63361. /**
  63362. * Gets the loaded texture
  63363. */
  63364. texture: EquiRectangularCubeTexture;
  63365. /**
  63366. * Callback called when the task is successful
  63367. */
  63368. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63369. /**
  63370. * Callback called when the task is successful
  63371. */
  63372. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63373. /**
  63374. * Creates a new EquiRectangularCubeTextureAssetTask object
  63375. * @param name defines the name of the task
  63376. * @param url defines the location of the file to load
  63377. * @param size defines the desired size (the more it increases the longer the generation will be)
  63378. * If the size is omitted this implies you are using a preprocessed cubemap.
  63379. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63380. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63381. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63382. * (default is true)
  63383. */
  63384. constructor(
  63385. /**
  63386. * Defines the name of the task
  63387. */
  63388. name: string,
  63389. /**
  63390. * Defines the location of the file to load
  63391. */
  63392. url: string,
  63393. /**
  63394. * Defines the desired size (the more it increases the longer the generation will be)
  63395. */
  63396. size: number,
  63397. /**
  63398. * Defines if mipmaps should not be generated (default is false)
  63399. */
  63400. noMipmap?: boolean,
  63401. /**
  63402. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63403. * but the standard material would require them in Gamma space) (default is true)
  63404. */
  63405. gammaSpace?: boolean);
  63406. /**
  63407. * Execute the current task
  63408. * @param scene defines the scene where you want your assets to be loaded
  63409. * @param onSuccess is a callback called when the task is successfully executed
  63410. * @param onError is a callback called if an error occurs
  63411. */
  63412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63413. }
  63414. /**
  63415. * This class can be used to easily import assets into a scene
  63416. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63417. */
  63418. export class AssetsManager {
  63419. private _scene;
  63420. private _isLoading;
  63421. protected _tasks: AbstractAssetTask[];
  63422. protected _waitingTasksCount: number;
  63423. protected _totalTasksCount: number;
  63424. /**
  63425. * Callback called when all tasks are processed
  63426. */
  63427. onFinish: (tasks: AbstractAssetTask[]) => void;
  63428. /**
  63429. * Callback called when a task is successful
  63430. */
  63431. onTaskSuccess: (task: AbstractAssetTask) => void;
  63432. /**
  63433. * Callback called when a task had an error
  63434. */
  63435. onTaskError: (task: AbstractAssetTask) => void;
  63436. /**
  63437. * Callback called when a task is done (whatever the result is)
  63438. */
  63439. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63440. /**
  63441. * Observable called when all tasks are processed
  63442. */
  63443. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63444. /**
  63445. * Observable called when a task had an error
  63446. */
  63447. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63448. /**
  63449. * Observable called when all tasks were executed
  63450. */
  63451. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63452. /**
  63453. * Observable called when a task is done (whatever the result is)
  63454. */
  63455. onProgressObservable: Observable<IAssetsProgressEvent>;
  63456. /**
  63457. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63458. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63459. */
  63460. useDefaultLoadingScreen: boolean;
  63461. /**
  63462. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63463. * when all assets have been downloaded.
  63464. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63465. */
  63466. autoHideLoadingUI: boolean;
  63467. /**
  63468. * Creates a new AssetsManager
  63469. * @param scene defines the scene to work on
  63470. */
  63471. constructor(scene: Scene);
  63472. /**
  63473. * Add a MeshAssetTask to the list of active tasks
  63474. * @param taskName defines the name of the new task
  63475. * @param meshesNames defines the name of meshes to load
  63476. * @param rootUrl defines the root url to use to locate files
  63477. * @param sceneFilename defines the filename of the scene file
  63478. * @returns a new MeshAssetTask object
  63479. */
  63480. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63481. /**
  63482. * Add a TextFileAssetTask to the list of active tasks
  63483. * @param taskName defines the name of the new task
  63484. * @param url defines the url of the file to load
  63485. * @returns a new TextFileAssetTask object
  63486. */
  63487. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63488. /**
  63489. * Add a BinaryFileAssetTask to the list of active tasks
  63490. * @param taskName defines the name of the new task
  63491. * @param url defines the url of the file to load
  63492. * @returns a new BinaryFileAssetTask object
  63493. */
  63494. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63495. /**
  63496. * Add a ImageAssetTask to the list of active tasks
  63497. * @param taskName defines the name of the new task
  63498. * @param url defines the url of the file to load
  63499. * @returns a new ImageAssetTask object
  63500. */
  63501. addImageTask(taskName: string, url: string): ImageAssetTask;
  63502. /**
  63503. * Add a TextureAssetTask to the list of active tasks
  63504. * @param taskName defines the name of the new task
  63505. * @param url defines the url of the file to load
  63506. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63507. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63508. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63509. * @returns a new TextureAssetTask object
  63510. */
  63511. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63512. /**
  63513. * Add a CubeTextureAssetTask to the list of active tasks
  63514. * @param taskName defines the name of the new task
  63515. * @param url defines the url of the file to load
  63516. * @param extensions defines the extension to use to load the cube map (can be null)
  63517. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63518. * @param files defines the list of files to load (can be null)
  63519. * @returns a new CubeTextureAssetTask object
  63520. */
  63521. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63522. /**
  63523. *
  63524. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63525. * @param taskName defines the name of the new task
  63526. * @param url defines the url of the file to load
  63527. * @param size defines the size you want for the cubemap (can be null)
  63528. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63529. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63530. * @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)
  63531. * @param reserved Internal use only
  63532. * @returns a new HDRCubeTextureAssetTask object
  63533. */
  63534. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63535. /**
  63536. *
  63537. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63538. * @param taskName defines the name of the new task
  63539. * @param url defines the url of the file to load
  63540. * @param size defines the size you want for the cubemap (can be null)
  63541. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63542. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63543. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63544. * @returns a new EquiRectangularCubeTextureAssetTask object
  63545. */
  63546. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63547. /**
  63548. * Remove a task from the assets manager.
  63549. * @param task the task to remove
  63550. */
  63551. removeTask(task: AbstractAssetTask): void;
  63552. private _decreaseWaitingTasksCount;
  63553. private _runTask;
  63554. /**
  63555. * Reset the AssetsManager and remove all tasks
  63556. * @return the current instance of the AssetsManager
  63557. */
  63558. reset(): AssetsManager;
  63559. /**
  63560. * Start the loading process
  63561. * @return the current instance of the AssetsManager
  63562. */
  63563. load(): AssetsManager;
  63564. /**
  63565. * Start the loading process as an async operation
  63566. * @return a promise returning the list of failed tasks
  63567. */
  63568. loadAsync(): Promise<void>;
  63569. }
  63570. }
  63571. declare module "babylonjs/Misc/deferred" {
  63572. /**
  63573. * Wrapper class for promise with external resolve and reject.
  63574. */
  63575. export class Deferred<T> {
  63576. /**
  63577. * The promise associated with this deferred object.
  63578. */
  63579. readonly promise: Promise<T>;
  63580. private _resolve;
  63581. private _reject;
  63582. /**
  63583. * The resolve method of the promise associated with this deferred object.
  63584. */
  63585. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63586. /**
  63587. * The reject method of the promise associated with this deferred object.
  63588. */
  63589. readonly reject: (reason?: any) => void;
  63590. /**
  63591. * Constructor for this deferred object.
  63592. */
  63593. constructor();
  63594. }
  63595. }
  63596. declare module "babylonjs/Misc/meshExploder" {
  63597. import { Mesh } from "babylonjs/Meshes/mesh";
  63598. /**
  63599. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63600. */
  63601. export class MeshExploder {
  63602. private _centerMesh;
  63603. private _meshes;
  63604. private _meshesOrigins;
  63605. private _toCenterVectors;
  63606. private _scaledDirection;
  63607. private _newPosition;
  63608. private _centerPosition;
  63609. /**
  63610. * Explodes meshes from a center mesh.
  63611. * @param meshes The meshes to explode.
  63612. * @param centerMesh The mesh to be center of explosion.
  63613. */
  63614. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63615. private _setCenterMesh;
  63616. /**
  63617. * Get class name
  63618. * @returns "MeshExploder"
  63619. */
  63620. getClassName(): string;
  63621. /**
  63622. * "Exploded meshes"
  63623. * @returns Array of meshes with the centerMesh at index 0.
  63624. */
  63625. getMeshes(): Array<Mesh>;
  63626. /**
  63627. * Explodes meshes giving a specific direction
  63628. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63629. */
  63630. explode(direction?: number): void;
  63631. }
  63632. }
  63633. declare module "babylonjs/Misc/filesInput" {
  63634. import { Engine } from "babylonjs/Engines/engine";
  63635. import { Scene } from "babylonjs/scene";
  63636. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63637. /**
  63638. * Class used to help managing file picking and drag'n'drop
  63639. */
  63640. export class FilesInput {
  63641. /**
  63642. * List of files ready to be loaded
  63643. */
  63644. static readonly FilesToLoad: {
  63645. [key: string]: File;
  63646. };
  63647. /**
  63648. * Callback called when a file is processed
  63649. */
  63650. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63651. private _engine;
  63652. private _currentScene;
  63653. private _sceneLoadedCallback;
  63654. private _progressCallback;
  63655. private _additionalRenderLoopLogicCallback;
  63656. private _textureLoadingCallback;
  63657. private _startingProcessingFilesCallback;
  63658. private _onReloadCallback;
  63659. private _errorCallback;
  63660. private _elementToMonitor;
  63661. private _sceneFileToLoad;
  63662. private _filesToLoad;
  63663. /**
  63664. * Creates a new FilesInput
  63665. * @param engine defines the rendering engine
  63666. * @param scene defines the hosting scene
  63667. * @param sceneLoadedCallback callback called when scene is loaded
  63668. * @param progressCallback callback called to track progress
  63669. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63670. * @param textureLoadingCallback callback called when a texture is loading
  63671. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63672. * @param onReloadCallback callback called when a reload is requested
  63673. * @param errorCallback callback call if an error occurs
  63674. */
  63675. 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);
  63676. private _dragEnterHandler;
  63677. private _dragOverHandler;
  63678. private _dropHandler;
  63679. /**
  63680. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63681. * @param elementToMonitor defines the DOM element to track
  63682. */
  63683. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63684. /**
  63685. * Release all associated resources
  63686. */
  63687. dispose(): void;
  63688. private renderFunction;
  63689. private drag;
  63690. private drop;
  63691. private _traverseFolder;
  63692. private _processFiles;
  63693. /**
  63694. * Load files from a drop event
  63695. * @param event defines the drop event to use as source
  63696. */
  63697. loadFiles(event: any): void;
  63698. private _processReload;
  63699. /**
  63700. * Reload the current scene from the loaded files
  63701. */
  63702. reload(): void;
  63703. }
  63704. }
  63705. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63706. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63707. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63708. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63709. }
  63710. declare module "babylonjs/Misc/sceneOptimizer" {
  63711. import { Scene, IDisposable } from "babylonjs/scene";
  63712. import { Observable } from "babylonjs/Misc/observable";
  63713. /**
  63714. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63716. */
  63717. export class SceneOptimization {
  63718. /**
  63719. * Defines the priority of this optimization (0 by default which means first in the list)
  63720. */
  63721. priority: number;
  63722. /**
  63723. * Gets a string describing the action executed by the current optimization
  63724. * @returns description string
  63725. */
  63726. getDescription(): string;
  63727. /**
  63728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63729. * @param scene defines the current scene where to apply this optimization
  63730. * @param optimizer defines the current optimizer
  63731. * @returns true if everything that can be done was applied
  63732. */
  63733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63734. /**
  63735. * Creates the SceneOptimization object
  63736. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63737. * @param desc defines the description associated with the optimization
  63738. */
  63739. constructor(
  63740. /**
  63741. * Defines the priority of this optimization (0 by default which means first in the list)
  63742. */
  63743. priority?: number);
  63744. }
  63745. /**
  63746. * Defines an optimization used to reduce the size of render target textures
  63747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63748. */
  63749. export class TextureOptimization extends SceneOptimization {
  63750. /**
  63751. * Defines the priority of this optimization (0 by default which means first in the list)
  63752. */
  63753. priority: number;
  63754. /**
  63755. * 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
  63756. */
  63757. maximumSize: number;
  63758. /**
  63759. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63760. */
  63761. step: number;
  63762. /**
  63763. * Gets a string describing the action executed by the current optimization
  63764. * @returns description string
  63765. */
  63766. getDescription(): string;
  63767. /**
  63768. * Creates the TextureOptimization object
  63769. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63770. * @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
  63771. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63772. */
  63773. constructor(
  63774. /**
  63775. * Defines the priority of this optimization (0 by default which means first in the list)
  63776. */
  63777. priority?: number,
  63778. /**
  63779. * 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
  63780. */
  63781. maximumSize?: number,
  63782. /**
  63783. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63784. */
  63785. step?: number);
  63786. /**
  63787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63788. * @param scene defines the current scene where to apply this optimization
  63789. * @param optimizer defines the current optimizer
  63790. * @returns true if everything that can be done was applied
  63791. */
  63792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63793. }
  63794. /**
  63795. * Defines an optimization used to increase or decrease the rendering resolution
  63796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63797. */
  63798. export class HardwareScalingOptimization extends SceneOptimization {
  63799. /**
  63800. * Defines the priority of this optimization (0 by default which means first in the list)
  63801. */
  63802. priority: number;
  63803. /**
  63804. * Defines the maximum scale to use (2 by default)
  63805. */
  63806. maximumScale: number;
  63807. /**
  63808. * Defines the step to use between two passes (0.5 by default)
  63809. */
  63810. step: number;
  63811. private _currentScale;
  63812. private _directionOffset;
  63813. /**
  63814. * Gets a string describing the action executed by the current optimization
  63815. * @return description string
  63816. */
  63817. getDescription(): string;
  63818. /**
  63819. * Creates the HardwareScalingOptimization object
  63820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63821. * @param maximumScale defines the maximum scale to use (2 by default)
  63822. * @param step defines the step to use between two passes (0.5 by default)
  63823. */
  63824. constructor(
  63825. /**
  63826. * Defines the priority of this optimization (0 by default which means first in the list)
  63827. */
  63828. priority?: number,
  63829. /**
  63830. * Defines the maximum scale to use (2 by default)
  63831. */
  63832. maximumScale?: number,
  63833. /**
  63834. * Defines the step to use between two passes (0.5 by default)
  63835. */
  63836. step?: number);
  63837. /**
  63838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63839. * @param scene defines the current scene where to apply this optimization
  63840. * @param optimizer defines the current optimizer
  63841. * @returns true if everything that can be done was applied
  63842. */
  63843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63844. }
  63845. /**
  63846. * Defines an optimization used to remove shadows
  63847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63848. */
  63849. export class ShadowsOptimization extends SceneOptimization {
  63850. /**
  63851. * Gets a string describing the action executed by the current optimization
  63852. * @return description string
  63853. */
  63854. getDescription(): string;
  63855. /**
  63856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63857. * @param scene defines the current scene where to apply this optimization
  63858. * @param optimizer defines the current optimizer
  63859. * @returns true if everything that can be done was applied
  63860. */
  63861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63862. }
  63863. /**
  63864. * Defines an optimization used to turn post-processes off
  63865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63866. */
  63867. export class PostProcessesOptimization extends SceneOptimization {
  63868. /**
  63869. * Gets a string describing the action executed by the current optimization
  63870. * @return description string
  63871. */
  63872. getDescription(): string;
  63873. /**
  63874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63875. * @param scene defines the current scene where to apply this optimization
  63876. * @param optimizer defines the current optimizer
  63877. * @returns true if everything that can be done was applied
  63878. */
  63879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63880. }
  63881. /**
  63882. * Defines an optimization used to turn lens flares off
  63883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63884. */
  63885. export class LensFlaresOptimization extends SceneOptimization {
  63886. /**
  63887. * Gets a string describing the action executed by the current optimization
  63888. * @return description string
  63889. */
  63890. getDescription(): string;
  63891. /**
  63892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63893. * @param scene defines the current scene where to apply this optimization
  63894. * @param optimizer defines the current optimizer
  63895. * @returns true if everything that can be done was applied
  63896. */
  63897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63898. }
  63899. /**
  63900. * Defines an optimization based on user defined callback.
  63901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63902. */
  63903. export class CustomOptimization extends SceneOptimization {
  63904. /**
  63905. * Callback called to apply the custom optimization.
  63906. */
  63907. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63908. /**
  63909. * Callback called to get custom description
  63910. */
  63911. onGetDescription: () => string;
  63912. /**
  63913. * Gets a string describing the action executed by the current optimization
  63914. * @returns description string
  63915. */
  63916. getDescription(): string;
  63917. /**
  63918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63919. * @param scene defines the current scene where to apply this optimization
  63920. * @param optimizer defines the current optimizer
  63921. * @returns true if everything that can be done was applied
  63922. */
  63923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63924. }
  63925. /**
  63926. * Defines an optimization used to turn particles off
  63927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63928. */
  63929. export class ParticlesOptimization extends SceneOptimization {
  63930. /**
  63931. * Gets a string describing the action executed by the current optimization
  63932. * @return description string
  63933. */
  63934. getDescription(): string;
  63935. /**
  63936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63937. * @param scene defines the current scene where to apply this optimization
  63938. * @param optimizer defines the current optimizer
  63939. * @returns true if everything that can be done was applied
  63940. */
  63941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63942. }
  63943. /**
  63944. * Defines an optimization used to turn render targets off
  63945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63946. */
  63947. export class RenderTargetsOptimization extends SceneOptimization {
  63948. /**
  63949. * Gets a string describing the action executed by the current optimization
  63950. * @return description string
  63951. */
  63952. getDescription(): string;
  63953. /**
  63954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63955. * @param scene defines the current scene where to apply this optimization
  63956. * @param optimizer defines the current optimizer
  63957. * @returns true if everything that can be done was applied
  63958. */
  63959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63960. }
  63961. /**
  63962. * Defines an optimization used to merge meshes with compatible materials
  63963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63964. */
  63965. export class MergeMeshesOptimization extends SceneOptimization {
  63966. private static _UpdateSelectionTree;
  63967. /**
  63968. * Gets or sets a boolean which defines if optimization octree has to be updated
  63969. */
  63970. /**
  63971. * Gets or sets a boolean which defines if optimization octree has to be updated
  63972. */
  63973. static UpdateSelectionTree: boolean;
  63974. /**
  63975. * Gets a string describing the action executed by the current optimization
  63976. * @return description string
  63977. */
  63978. getDescription(): string;
  63979. private _canBeMerged;
  63980. /**
  63981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63982. * @param scene defines the current scene where to apply this optimization
  63983. * @param optimizer defines the current optimizer
  63984. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63985. * @returns true if everything that can be done was applied
  63986. */
  63987. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63988. }
  63989. /**
  63990. * Defines a list of options used by SceneOptimizer
  63991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63992. */
  63993. export class SceneOptimizerOptions {
  63994. /**
  63995. * Defines the target frame rate to reach (60 by default)
  63996. */
  63997. targetFrameRate: number;
  63998. /**
  63999. * Defines the interval between two checkes (2000ms by default)
  64000. */
  64001. trackerDuration: number;
  64002. /**
  64003. * Gets the list of optimizations to apply
  64004. */
  64005. optimizations: SceneOptimization[];
  64006. /**
  64007. * Creates a new list of options used by SceneOptimizer
  64008. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64009. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64010. */
  64011. constructor(
  64012. /**
  64013. * Defines the target frame rate to reach (60 by default)
  64014. */
  64015. targetFrameRate?: number,
  64016. /**
  64017. * Defines the interval between two checkes (2000ms by default)
  64018. */
  64019. trackerDuration?: number);
  64020. /**
  64021. * Add a new optimization
  64022. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64023. * @returns the current SceneOptimizerOptions
  64024. */
  64025. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64026. /**
  64027. * Add a new custom optimization
  64028. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64029. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64031. * @returns the current SceneOptimizerOptions
  64032. */
  64033. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64034. /**
  64035. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64036. * @param targetFrameRate defines the target frame rate (60 by default)
  64037. * @returns a SceneOptimizerOptions object
  64038. */
  64039. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64040. /**
  64041. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64042. * @param targetFrameRate defines the target frame rate (60 by default)
  64043. * @returns a SceneOptimizerOptions object
  64044. */
  64045. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64046. /**
  64047. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64048. * @param targetFrameRate defines the target frame rate (60 by default)
  64049. * @returns a SceneOptimizerOptions object
  64050. */
  64051. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64052. }
  64053. /**
  64054. * Class used to run optimizations in order to reach a target frame rate
  64055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64056. */
  64057. export class SceneOptimizer implements IDisposable {
  64058. private _isRunning;
  64059. private _options;
  64060. private _scene;
  64061. private _currentPriorityLevel;
  64062. private _targetFrameRate;
  64063. private _trackerDuration;
  64064. private _currentFrameRate;
  64065. private _sceneDisposeObserver;
  64066. private _improvementMode;
  64067. /**
  64068. * Defines an observable called when the optimizer reaches the target frame rate
  64069. */
  64070. onSuccessObservable: Observable<SceneOptimizer>;
  64071. /**
  64072. * Defines an observable called when the optimizer enables an optimization
  64073. */
  64074. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64075. /**
  64076. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64077. */
  64078. onFailureObservable: Observable<SceneOptimizer>;
  64079. /**
  64080. * Gets a boolean indicating if the optimizer is in improvement mode
  64081. */
  64082. readonly isInImprovementMode: boolean;
  64083. /**
  64084. * Gets the current priority level (0 at start)
  64085. */
  64086. readonly currentPriorityLevel: number;
  64087. /**
  64088. * Gets the current frame rate checked by the SceneOptimizer
  64089. */
  64090. readonly currentFrameRate: number;
  64091. /**
  64092. * Gets or sets the current target frame rate (60 by default)
  64093. */
  64094. /**
  64095. * Gets or sets the current target frame rate (60 by default)
  64096. */
  64097. targetFrameRate: number;
  64098. /**
  64099. * Gets or sets the current interval between two checks (every 2000ms by default)
  64100. */
  64101. /**
  64102. * Gets or sets the current interval between two checks (every 2000ms by default)
  64103. */
  64104. trackerDuration: number;
  64105. /**
  64106. * Gets the list of active optimizations
  64107. */
  64108. readonly optimizations: SceneOptimization[];
  64109. /**
  64110. * Creates a new SceneOptimizer
  64111. * @param scene defines the scene to work on
  64112. * @param options defines the options to use with the SceneOptimizer
  64113. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64114. * @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)
  64115. */
  64116. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64117. /**
  64118. * Stops the current optimizer
  64119. */
  64120. stop(): void;
  64121. /**
  64122. * Reset the optimizer to initial step (current priority level = 0)
  64123. */
  64124. reset(): void;
  64125. /**
  64126. * Start the optimizer. By default it will try to reach a specific framerate
  64127. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64128. */
  64129. start(): void;
  64130. private _checkCurrentState;
  64131. /**
  64132. * Release all resources
  64133. */
  64134. dispose(): void;
  64135. /**
  64136. * Helper function to create a SceneOptimizer with one single line of code
  64137. * @param scene defines the scene to work on
  64138. * @param options defines the options to use with the SceneOptimizer
  64139. * @param onSuccess defines a callback to call on success
  64140. * @param onFailure defines a callback to call on failure
  64141. * @returns the new SceneOptimizer object
  64142. */
  64143. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64144. }
  64145. }
  64146. declare module "babylonjs/Misc/sceneSerializer" {
  64147. import { Scene } from "babylonjs/scene";
  64148. /**
  64149. * Class used to serialize a scene into a string
  64150. */
  64151. export class SceneSerializer {
  64152. /**
  64153. * Clear cache used by a previous serialization
  64154. */
  64155. static ClearCache(): void;
  64156. /**
  64157. * Serialize a scene into a JSON compatible object
  64158. * @param scene defines the scene to serialize
  64159. * @returns a JSON compatible object
  64160. */
  64161. static Serialize(scene: Scene): any;
  64162. /**
  64163. * Serialize a mesh into a JSON compatible object
  64164. * @param toSerialize defines the mesh to serialize
  64165. * @param withParents defines if parents must be serialized as well
  64166. * @param withChildren defines if children must be serialized as well
  64167. * @returns a JSON compatible object
  64168. */
  64169. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64170. }
  64171. }
  64172. declare module "babylonjs/Misc/textureTools" {
  64173. import { Texture } from "babylonjs/Materials/Textures/texture";
  64174. /**
  64175. * Class used to host texture specific utilities
  64176. */
  64177. export class TextureTools {
  64178. /**
  64179. * Uses the GPU to create a copy texture rescaled at a given size
  64180. * @param texture Texture to copy from
  64181. * @param width defines the desired width
  64182. * @param height defines the desired height
  64183. * @param useBilinearMode defines if bilinear mode has to be used
  64184. * @return the generated texture
  64185. */
  64186. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64187. }
  64188. }
  64189. declare module "babylonjs/Misc/videoRecorder" {
  64190. import { Nullable } from "babylonjs/types";
  64191. import { Engine } from "babylonjs/Engines/engine";
  64192. /**
  64193. * This represents the different options available for the video capture.
  64194. */
  64195. export interface VideoRecorderOptions {
  64196. /** Defines the mime type of the video. */
  64197. mimeType: string;
  64198. /** Defines the FPS the video should be recorded at. */
  64199. fps: number;
  64200. /** Defines the chunk size for the recording data. */
  64201. recordChunckSize: number;
  64202. /** The audio tracks to attach to the recording. */
  64203. audioTracks?: MediaStreamTrack[];
  64204. }
  64205. /**
  64206. * This can help with recording videos from BabylonJS.
  64207. * This is based on the available WebRTC functionalities of the browser.
  64208. *
  64209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64210. */
  64211. export class VideoRecorder {
  64212. private static readonly _defaultOptions;
  64213. /**
  64214. * Returns whether or not the VideoRecorder is available in your browser.
  64215. * @param engine Defines the Babylon Engine.
  64216. * @returns true if supported otherwise false.
  64217. */
  64218. static IsSupported(engine: Engine): boolean;
  64219. private readonly _options;
  64220. private _canvas;
  64221. private _mediaRecorder;
  64222. private _recordedChunks;
  64223. private _fileName;
  64224. private _resolve;
  64225. private _reject;
  64226. /**
  64227. * True when a recording is already in progress.
  64228. */
  64229. readonly isRecording: boolean;
  64230. /**
  64231. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64232. * @param engine Defines the BabylonJS Engine you wish to record.
  64233. * @param options Defines options that can be used to customize the capture.
  64234. */
  64235. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64236. /**
  64237. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64238. */
  64239. stopRecording(): void;
  64240. /**
  64241. * Starts recording the canvas for a max duration specified in parameters.
  64242. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64243. * If null no automatic download will start and you can rely on the promise to get the data back.
  64244. * @param maxDuration Defines the maximum recording time in seconds.
  64245. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64246. * @return A promise callback at the end of the recording with the video data in Blob.
  64247. */
  64248. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64249. /**
  64250. * Releases internal resources used during the recording.
  64251. */
  64252. dispose(): void;
  64253. private _handleDataAvailable;
  64254. private _handleError;
  64255. private _handleStop;
  64256. }
  64257. }
  64258. declare module "babylonjs/Misc/screenshotTools" {
  64259. import { Camera } from "babylonjs/Cameras/camera";
  64260. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64261. import { Engine } from "babylonjs/Engines/engine";
  64262. /**
  64263. * Class containing a set of static utilities functions for screenshots
  64264. */
  64265. export class ScreenshotTools {
  64266. /**
  64267. * Captures a screenshot of the current rendering
  64268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64269. * @param engine defines the rendering engine
  64270. * @param camera defines the source camera
  64271. * @param size This parameter can be set to a single number or to an object with the
  64272. * following (optional) properties: precision, width, height. If a single number is passed,
  64273. * it will be used for both width and height. If an object is passed, the screenshot size
  64274. * will be derived from the parameters. The precision property is a multiplier allowing
  64275. * rendering at a higher or lower resolution
  64276. * @param successCallback defines the callback receives a single parameter which contains the
  64277. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64278. * src parameter of an <img> to display it
  64279. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64280. * Check your browser for supported MIME types
  64281. */
  64282. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64283. /**
  64284. * Captures a screenshot of the current rendering
  64285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64286. * @param engine defines the rendering engine
  64287. * @param camera defines the source camera
  64288. * @param size This parameter can be set to a single number or to an object with the
  64289. * following (optional) properties: precision, width, height. If a single number is passed,
  64290. * it will be used for both width and height. If an object is passed, the screenshot size
  64291. * will be derived from the parameters. The precision property is a multiplier allowing
  64292. * rendering at a higher or lower resolution
  64293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64294. * Check your browser for supported MIME types
  64295. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64296. * to the src parameter of an <img> to display it
  64297. */
  64298. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64299. /**
  64300. * Generates an image screenshot from the specified camera.
  64301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64302. * @param engine The engine to use for rendering
  64303. * @param camera The camera to use for rendering
  64304. * @param size This parameter can be set to a single number or to an object with the
  64305. * following (optional) properties: precision, width, height. If a single number is passed,
  64306. * it will be used for both width and height. If an object is passed, the screenshot size
  64307. * will be derived from the parameters. The precision property is a multiplier allowing
  64308. * rendering at a higher or lower resolution
  64309. * @param successCallback The callback receives a single parameter which contains the
  64310. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64311. * src parameter of an <img> to display it
  64312. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64313. * Check your browser for supported MIME types
  64314. * @param samples Texture samples (default: 1)
  64315. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64316. * @param fileName A name for for the downloaded file.
  64317. */
  64318. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64319. /**
  64320. * Generates an image screenshot from the specified camera.
  64321. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64322. * @param engine The engine to use for rendering
  64323. * @param camera The camera to use for rendering
  64324. * @param size This parameter can be set to a single number or to an object with the
  64325. * following (optional) properties: precision, width, height. If a single number is passed,
  64326. * it will be used for both width and height. If an object is passed, the screenshot size
  64327. * will be derived from the parameters. The precision property is a multiplier allowing
  64328. * rendering at a higher or lower resolution
  64329. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64330. * Check your browser for supported MIME types
  64331. * @param samples Texture samples (default: 1)
  64332. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64333. * @param fileName A name for for the downloaded file.
  64334. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64335. * to the src parameter of an <img> to display it
  64336. */
  64337. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64338. /**
  64339. * Gets height and width for screenshot size
  64340. * @private
  64341. */
  64342. private static _getScreenshotSize;
  64343. }
  64344. }
  64345. declare module "babylonjs/Misc/index" {
  64346. export * from "babylonjs/Misc/andOrNotEvaluator";
  64347. export * from "babylonjs/Misc/assetsManager";
  64348. export * from "babylonjs/Misc/dds";
  64349. export * from "babylonjs/Misc/decorators";
  64350. export * from "babylonjs/Misc/deferred";
  64351. export * from "babylonjs/Misc/environmentTextureTools";
  64352. export * from "babylonjs/Misc/meshExploder";
  64353. export * from "babylonjs/Misc/filesInput";
  64354. export * from "babylonjs/Misc/HighDynamicRange/index";
  64355. export * from "babylonjs/Misc/khronosTextureContainer";
  64356. export * from "babylonjs/Misc/observable";
  64357. export * from "babylonjs/Misc/performanceMonitor";
  64358. export * from "babylonjs/Misc/promise";
  64359. export * from "babylonjs/Misc/sceneOptimizer";
  64360. export * from "babylonjs/Misc/sceneSerializer";
  64361. export * from "babylonjs/Misc/smartArray";
  64362. export * from "babylonjs/Misc/stringDictionary";
  64363. export * from "babylonjs/Misc/tags";
  64364. export * from "babylonjs/Misc/textureTools";
  64365. export * from "babylonjs/Misc/tga";
  64366. export * from "babylonjs/Misc/tools";
  64367. export * from "babylonjs/Misc/videoRecorder";
  64368. export * from "babylonjs/Misc/virtualJoystick";
  64369. export * from "babylonjs/Misc/workerPool";
  64370. export * from "babylonjs/Misc/logger";
  64371. export * from "babylonjs/Misc/typeStore";
  64372. export * from "babylonjs/Misc/filesInputStore";
  64373. export * from "babylonjs/Misc/deepCopier";
  64374. export * from "babylonjs/Misc/pivotTools";
  64375. export * from "babylonjs/Misc/precisionDate";
  64376. export * from "babylonjs/Misc/screenshotTools";
  64377. export * from "babylonjs/Misc/typeStore";
  64378. export * from "babylonjs/Misc/webRequest";
  64379. export * from "babylonjs/Misc/iInspectable";
  64380. export * from "babylonjs/Misc/brdfTextureTools";
  64381. export * from "babylonjs/Misc/gradients";
  64382. export * from "babylonjs/Misc/perfCounter";
  64383. export * from "babylonjs/Misc/fileRequest";
  64384. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64385. export * from "babylonjs/Misc/retryStrategy";
  64386. export * from "babylonjs/Misc/loadFileError";
  64387. }
  64388. declare module "babylonjs/index" {
  64389. export * from "babylonjs/abstractScene";
  64390. export * from "babylonjs/Actions/index";
  64391. export * from "babylonjs/Animations/index";
  64392. export * from "babylonjs/assetContainer";
  64393. export * from "babylonjs/Audio/index";
  64394. export * from "babylonjs/Behaviors/index";
  64395. export * from "babylonjs/Bones/index";
  64396. export * from "babylonjs/Cameras/index";
  64397. export * from "babylonjs/Collisions/index";
  64398. export * from "babylonjs/Culling/index";
  64399. export * from "babylonjs/Debug/index";
  64400. export * from "babylonjs/Engines/index";
  64401. export * from "babylonjs/Events/index";
  64402. export * from "babylonjs/Gamepads/index";
  64403. export * from "babylonjs/Gizmos/index";
  64404. export * from "babylonjs/Helpers/index";
  64405. export * from "babylonjs/Instrumentation/index";
  64406. export * from "babylonjs/Layers/index";
  64407. export * from "babylonjs/LensFlares/index";
  64408. export * from "babylonjs/Lights/index";
  64409. export * from "babylonjs/Loading/index";
  64410. export * from "babylonjs/Materials/index";
  64411. export * from "babylonjs/Maths/index";
  64412. export * from "babylonjs/Meshes/index";
  64413. export * from "babylonjs/Morph/index";
  64414. export * from "babylonjs/Navigation/index";
  64415. export * from "babylonjs/node";
  64416. export * from "babylonjs/Offline/index";
  64417. export * from "babylonjs/Particles/index";
  64418. export * from "babylonjs/Physics/index";
  64419. export * from "babylonjs/PostProcesses/index";
  64420. export * from "babylonjs/Probes/index";
  64421. export * from "babylonjs/Rendering/index";
  64422. export * from "babylonjs/scene";
  64423. export * from "babylonjs/sceneComponent";
  64424. export * from "babylonjs/Sprites/index";
  64425. export * from "babylonjs/States/index";
  64426. export * from "babylonjs/Misc/index";
  64427. export * from "babylonjs/types";
  64428. }
  64429. declare module "babylonjs/Animations/pathCursor" {
  64430. import { Vector3 } from "babylonjs/Maths/math.vector";
  64431. import { Path2 } from "babylonjs/Maths/math.path";
  64432. /**
  64433. * A cursor which tracks a point on a path
  64434. */
  64435. export class PathCursor {
  64436. private path;
  64437. /**
  64438. * Stores path cursor callbacks for when an onchange event is triggered
  64439. */
  64440. private _onchange;
  64441. /**
  64442. * The value of the path cursor
  64443. */
  64444. value: number;
  64445. /**
  64446. * The animation array of the path cursor
  64447. */
  64448. animations: Animation[];
  64449. /**
  64450. * Initializes the path cursor
  64451. * @param path The path to track
  64452. */
  64453. constructor(path: Path2);
  64454. /**
  64455. * Gets the cursor point on the path
  64456. * @returns A point on the path cursor at the cursor location
  64457. */
  64458. getPoint(): Vector3;
  64459. /**
  64460. * Moves the cursor ahead by the step amount
  64461. * @param step The amount to move the cursor forward
  64462. * @returns This path cursor
  64463. */
  64464. moveAhead(step?: number): PathCursor;
  64465. /**
  64466. * Moves the cursor behind by the step amount
  64467. * @param step The amount to move the cursor back
  64468. * @returns This path cursor
  64469. */
  64470. moveBack(step?: number): PathCursor;
  64471. /**
  64472. * Moves the cursor by the step amount
  64473. * If the step amount is greater than one, an exception is thrown
  64474. * @param step The amount to move the cursor
  64475. * @returns This path cursor
  64476. */
  64477. move(step: number): PathCursor;
  64478. /**
  64479. * Ensures that the value is limited between zero and one
  64480. * @returns This path cursor
  64481. */
  64482. private ensureLimits;
  64483. /**
  64484. * Runs onchange callbacks on change (used by the animation engine)
  64485. * @returns This path cursor
  64486. */
  64487. private raiseOnChange;
  64488. /**
  64489. * Executes a function on change
  64490. * @param f A path cursor onchange callback
  64491. * @returns This path cursor
  64492. */
  64493. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64494. }
  64495. }
  64496. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64497. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64498. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64499. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64500. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64501. }
  64502. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64503. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64504. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64505. }
  64506. declare module "babylonjs/Engines/Processors/index" {
  64507. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64508. export * from "babylonjs/Engines/Processors/Expressions/index";
  64509. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64510. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64511. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64512. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64513. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64514. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64515. }
  64516. declare module "babylonjs/Legacy/legacy" {
  64517. import * as Babylon from "babylonjs/index";
  64518. export * from "babylonjs/index";
  64519. }
  64520. declare module "babylonjs/Shaders/blur.fragment" {
  64521. /** @hidden */
  64522. export var blurPixelShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64528. /** @hidden */
  64529. export var pointCloudVertexDeclaration: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module "babylonjs" {
  64535. export * from "babylonjs/Legacy/legacy";
  64536. }
  64537. declare module BABYLON {
  64538. /** Alias type for value that can be null */
  64539. export type Nullable<T> = T | null;
  64540. /**
  64541. * Alias type for number that are floats
  64542. * @ignorenaming
  64543. */
  64544. export type float = number;
  64545. /**
  64546. * Alias type for number that are doubles.
  64547. * @ignorenaming
  64548. */
  64549. export type double = number;
  64550. /**
  64551. * Alias type for number that are integer
  64552. * @ignorenaming
  64553. */
  64554. export type int = number;
  64555. /** Alias type for number array or Float32Array */
  64556. export type FloatArray = number[] | Float32Array;
  64557. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64558. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64559. /**
  64560. * Alias for types that can be used by a Buffer or VertexBuffer.
  64561. */
  64562. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64563. /**
  64564. * Alias type for primitive types
  64565. * @ignorenaming
  64566. */
  64567. type Primitive = undefined | null | boolean | string | number | Function;
  64568. /**
  64569. * Type modifier to make all the properties of an object Readonly
  64570. */
  64571. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64572. /**
  64573. * Type modifier to make all the properties of an object Readonly recursively
  64574. */
  64575. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64576. /** @hidden */
  64577. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64578. }
  64579. /** @hidden */
  64580. /** @hidden */
  64581. type DeepImmutableObject<T> = {
  64582. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64583. };
  64584. }
  64585. declare module BABYLON {
  64586. /**
  64587. * A class serves as a medium between the observable and its observers
  64588. */
  64589. export class EventState {
  64590. /**
  64591. * Create a new EventState
  64592. * @param mask defines the mask associated with this state
  64593. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64594. * @param target defines the original target of the state
  64595. * @param currentTarget defines the current target of the state
  64596. */
  64597. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64598. /**
  64599. * Initialize the current event state
  64600. * @param mask defines the mask associated with this state
  64601. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64602. * @param target defines the original target of the state
  64603. * @param currentTarget defines the current target of the state
  64604. * @returns the current event state
  64605. */
  64606. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64607. /**
  64608. * An Observer can set this property to true to prevent subsequent observers of being notified
  64609. */
  64610. skipNextObservers: boolean;
  64611. /**
  64612. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64613. */
  64614. mask: number;
  64615. /**
  64616. * The object that originally notified the event
  64617. */
  64618. target?: any;
  64619. /**
  64620. * The current object in the bubbling phase
  64621. */
  64622. currentTarget?: any;
  64623. /**
  64624. * This will be populated with the return value of the last function that was executed.
  64625. * If it is the first function in the callback chain it will be the event data.
  64626. */
  64627. lastReturnValue?: any;
  64628. }
  64629. /**
  64630. * Represent an Observer registered to a given Observable object.
  64631. */
  64632. export class Observer<T> {
  64633. /**
  64634. * Defines the callback to call when the observer is notified
  64635. */
  64636. callback: (eventData: T, eventState: EventState) => void;
  64637. /**
  64638. * Defines the mask of the observer (used to filter notifications)
  64639. */
  64640. mask: number;
  64641. /**
  64642. * Defines the current scope used to restore the JS context
  64643. */
  64644. scope: any;
  64645. /** @hidden */
  64646. _willBeUnregistered: boolean;
  64647. /**
  64648. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64649. */
  64650. unregisterOnNextCall: boolean;
  64651. /**
  64652. * Creates a new observer
  64653. * @param callback defines the callback to call when the observer is notified
  64654. * @param mask defines the mask of the observer (used to filter notifications)
  64655. * @param scope defines the current scope used to restore the JS context
  64656. */
  64657. constructor(
  64658. /**
  64659. * Defines the callback to call when the observer is notified
  64660. */
  64661. callback: (eventData: T, eventState: EventState) => void,
  64662. /**
  64663. * Defines the mask of the observer (used to filter notifications)
  64664. */
  64665. mask: number,
  64666. /**
  64667. * Defines the current scope used to restore the JS context
  64668. */
  64669. scope?: any);
  64670. }
  64671. /**
  64672. * Represent a list of observers registered to multiple Observables object.
  64673. */
  64674. export class MultiObserver<T> {
  64675. private _observers;
  64676. private _observables;
  64677. /**
  64678. * Release associated resources
  64679. */
  64680. dispose(): void;
  64681. /**
  64682. * Raise a callback when one of the observable will notify
  64683. * @param observables defines a list of observables to watch
  64684. * @param callback defines the callback to call on notification
  64685. * @param mask defines the mask used to filter notifications
  64686. * @param scope defines the current scope used to restore the JS context
  64687. * @returns the new MultiObserver
  64688. */
  64689. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64690. }
  64691. /**
  64692. * The Observable class is a simple implementation of the Observable pattern.
  64693. *
  64694. * 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.
  64695. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64696. * 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).
  64697. * 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.
  64698. */
  64699. export class Observable<T> {
  64700. private _observers;
  64701. private _eventState;
  64702. private _onObserverAdded;
  64703. /**
  64704. * Gets the list of observers
  64705. */
  64706. readonly observers: Array<Observer<T>>;
  64707. /**
  64708. * Creates a new observable
  64709. * @param onObserverAdded defines a callback to call when a new observer is added
  64710. */
  64711. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64712. /**
  64713. * Create a new Observer with the specified callback
  64714. * @param callback the callback that will be executed for that Observer
  64715. * @param mask the mask used to filter observers
  64716. * @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.
  64717. * @param scope optional scope for the callback to be called from
  64718. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64719. * @returns the new observer created for the callback
  64720. */
  64721. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64722. /**
  64723. * Create a new Observer with the specified callback and unregisters after the next notification
  64724. * @param callback the callback that will be executed for that Observer
  64725. * @returns the new observer created for the callback
  64726. */
  64727. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64728. /**
  64729. * Remove an Observer from the Observable object
  64730. * @param observer the instance of the Observer to remove
  64731. * @returns false if it doesn't belong to this Observable
  64732. */
  64733. remove(observer: Nullable<Observer<T>>): boolean;
  64734. /**
  64735. * Remove a callback from the Observable object
  64736. * @param callback the callback to remove
  64737. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64738. * @returns false if it doesn't belong to this Observable
  64739. */
  64740. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64741. private _deferUnregister;
  64742. private _remove;
  64743. /**
  64744. * Moves the observable to the top of the observer list making it get called first when notified
  64745. * @param observer the observer to move
  64746. */
  64747. makeObserverTopPriority(observer: Observer<T>): void;
  64748. /**
  64749. * Moves the observable to the bottom of the observer list making it get called last when notified
  64750. * @param observer the observer to move
  64751. */
  64752. makeObserverBottomPriority(observer: Observer<T>): void;
  64753. /**
  64754. * Notify all Observers by calling their respective callback with the given data
  64755. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64756. * @param eventData defines the data to send to all observers
  64757. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64758. * @param target defines the original target of the state
  64759. * @param currentTarget defines the current target of the state
  64760. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64761. */
  64762. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64763. /**
  64764. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64765. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64766. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64767. * and it is crucial that all callbacks will be executed.
  64768. * The order of the callbacks is kept, callbacks are not executed parallel.
  64769. *
  64770. * @param eventData The data to be sent to each callback
  64771. * @param mask is used to filter observers defaults to -1
  64772. * @param target defines the callback target (see EventState)
  64773. * @param currentTarget defines he current object in the bubbling phase
  64774. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64775. */
  64776. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64777. /**
  64778. * Notify a specific observer
  64779. * @param observer defines the observer to notify
  64780. * @param eventData defines the data to be sent to each callback
  64781. * @param mask is used to filter observers defaults to -1
  64782. */
  64783. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64784. /**
  64785. * Gets a boolean indicating if the observable has at least one observer
  64786. * @returns true is the Observable has at least one Observer registered
  64787. */
  64788. hasObservers(): boolean;
  64789. /**
  64790. * Clear the list of observers
  64791. */
  64792. clear(): void;
  64793. /**
  64794. * Clone the current observable
  64795. * @returns a new observable
  64796. */
  64797. clone(): Observable<T>;
  64798. /**
  64799. * Does this observable handles observer registered with a given mask
  64800. * @param mask defines the mask to be tested
  64801. * @return whether or not one observer registered with the given mask is handeled
  64802. **/
  64803. hasSpecificMask(mask?: number): boolean;
  64804. }
  64805. }
  64806. declare module BABYLON {
  64807. /**
  64808. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64809. * Babylon.js
  64810. */
  64811. export class DomManagement {
  64812. /**
  64813. * Checks if the window object exists
  64814. * @returns true if the window object exists
  64815. */
  64816. static IsWindowObjectExist(): boolean;
  64817. /**
  64818. * Extracts text content from a DOM element hierarchy
  64819. * @param element defines the root element
  64820. * @returns a string
  64821. */
  64822. static GetDOMTextContent(element: HTMLElement): string;
  64823. }
  64824. }
  64825. declare module BABYLON {
  64826. /**
  64827. * Logger used througouht the application to allow configuration of
  64828. * the log level required for the messages.
  64829. */
  64830. export class Logger {
  64831. /**
  64832. * No log
  64833. */
  64834. static readonly NoneLogLevel: number;
  64835. /**
  64836. * Only message logs
  64837. */
  64838. static readonly MessageLogLevel: number;
  64839. /**
  64840. * Only warning logs
  64841. */
  64842. static readonly WarningLogLevel: number;
  64843. /**
  64844. * Only error logs
  64845. */
  64846. static readonly ErrorLogLevel: number;
  64847. /**
  64848. * All logs
  64849. */
  64850. static readonly AllLogLevel: number;
  64851. private static _LogCache;
  64852. /**
  64853. * Gets a value indicating the number of loading errors
  64854. * @ignorenaming
  64855. */
  64856. static errorsCount: number;
  64857. /**
  64858. * Callback called when a new log is added
  64859. */
  64860. static OnNewCacheEntry: (entry: string) => void;
  64861. private static _AddLogEntry;
  64862. private static _FormatMessage;
  64863. private static _LogDisabled;
  64864. private static _LogEnabled;
  64865. private static _WarnDisabled;
  64866. private static _WarnEnabled;
  64867. private static _ErrorDisabled;
  64868. private static _ErrorEnabled;
  64869. /**
  64870. * Log a message to the console
  64871. */
  64872. static Log: (message: string) => void;
  64873. /**
  64874. * Write a warning message to the console
  64875. */
  64876. static Warn: (message: string) => void;
  64877. /**
  64878. * Write an error message to the console
  64879. */
  64880. static Error: (message: string) => void;
  64881. /**
  64882. * Gets current log cache (list of logs)
  64883. */
  64884. static readonly LogCache: string;
  64885. /**
  64886. * Clears the log cache
  64887. */
  64888. static ClearLogCache(): void;
  64889. /**
  64890. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64891. */
  64892. static LogLevels: number;
  64893. }
  64894. }
  64895. declare module BABYLON {
  64896. /** @hidden */
  64897. export class _TypeStore {
  64898. /** @hidden */
  64899. static RegisteredTypes: {
  64900. [key: string]: Object;
  64901. };
  64902. /** @hidden */
  64903. static GetClass(fqdn: string): any;
  64904. }
  64905. }
  64906. declare module BABYLON {
  64907. /**
  64908. * Class containing a set of static utilities functions for deep copy.
  64909. */
  64910. export class DeepCopier {
  64911. /**
  64912. * Tries to copy an object by duplicating every property
  64913. * @param source defines the source object
  64914. * @param destination defines the target object
  64915. * @param doNotCopyList defines a list of properties to avoid
  64916. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64917. */
  64918. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64919. }
  64920. }
  64921. declare module BABYLON {
  64922. /**
  64923. * Class containing a set of static utilities functions for precision date
  64924. */
  64925. export class PrecisionDate {
  64926. /**
  64927. * Gets either window.performance.now() if supported or Date.now() else
  64928. */
  64929. static readonly Now: number;
  64930. }
  64931. }
  64932. declare module BABYLON {
  64933. /** @hidden */
  64934. export class _DevTools {
  64935. static WarnImport(name: string): string;
  64936. }
  64937. }
  64938. declare module BABYLON {
  64939. /**
  64940. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64941. */
  64942. export class WebRequest {
  64943. private _xhr;
  64944. /**
  64945. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64946. * i.e. when loading files, where the server/service expects an Authorization header
  64947. */
  64948. static CustomRequestHeaders: {
  64949. [key: string]: string;
  64950. };
  64951. /**
  64952. * Add callback functions in this array to update all the requests before they get sent to the network
  64953. */
  64954. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64955. private _injectCustomRequestHeaders;
  64956. /**
  64957. * Gets or sets a function to be called when loading progress changes
  64958. */
  64959. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64960. /**
  64961. * Returns client's state
  64962. */
  64963. readonly readyState: number;
  64964. /**
  64965. * Returns client's status
  64966. */
  64967. readonly status: number;
  64968. /**
  64969. * Returns client's status as a text
  64970. */
  64971. readonly statusText: string;
  64972. /**
  64973. * Returns client's response
  64974. */
  64975. readonly response: any;
  64976. /**
  64977. * Returns client's response url
  64978. */
  64979. readonly responseURL: string;
  64980. /**
  64981. * Returns client's response as text
  64982. */
  64983. readonly responseText: string;
  64984. /**
  64985. * Gets or sets the expected response type
  64986. */
  64987. responseType: XMLHttpRequestResponseType;
  64988. /** @hidden */
  64989. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64990. /** @hidden */
  64991. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64992. /**
  64993. * Cancels any network activity
  64994. */
  64995. abort(): void;
  64996. /**
  64997. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64998. * @param body defines an optional request body
  64999. */
  65000. send(body?: Document | BodyInit | null): void;
  65001. /**
  65002. * Sets the request method, request URL
  65003. * @param method defines the method to use (GET, POST, etc..)
  65004. * @param url defines the url to connect with
  65005. */
  65006. open(method: string, url: string): void;
  65007. }
  65008. }
  65009. declare module BABYLON {
  65010. /**
  65011. * File request interface
  65012. */
  65013. export interface IFileRequest {
  65014. /**
  65015. * Raised when the request is complete (success or error).
  65016. */
  65017. onCompleteObservable: Observable<IFileRequest>;
  65018. /**
  65019. * Aborts the request for a file.
  65020. */
  65021. abort: () => void;
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /**
  65026. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65027. */
  65028. export class PerformanceMonitor {
  65029. private _enabled;
  65030. private _rollingFrameTime;
  65031. private _lastFrameTimeMs;
  65032. /**
  65033. * constructor
  65034. * @param frameSampleSize The number of samples required to saturate the sliding window
  65035. */
  65036. constructor(frameSampleSize?: number);
  65037. /**
  65038. * Samples current frame
  65039. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65040. */
  65041. sampleFrame(timeMs?: number): void;
  65042. /**
  65043. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65044. */
  65045. readonly averageFrameTime: number;
  65046. /**
  65047. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65048. */
  65049. readonly averageFrameTimeVariance: number;
  65050. /**
  65051. * Returns the frame time of the most recent frame
  65052. */
  65053. readonly instantaneousFrameTime: number;
  65054. /**
  65055. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65056. */
  65057. readonly averageFPS: number;
  65058. /**
  65059. * Returns the average framerate in frames per second using the most recent frame time
  65060. */
  65061. readonly instantaneousFPS: number;
  65062. /**
  65063. * Returns true if enough samples have been taken to completely fill the sliding window
  65064. */
  65065. readonly isSaturated: boolean;
  65066. /**
  65067. * Enables contributions to the sliding window sample set
  65068. */
  65069. enable(): void;
  65070. /**
  65071. * Disables contributions to the sliding window sample set
  65072. * Samples will not be interpolated over the disabled period
  65073. */
  65074. disable(): void;
  65075. /**
  65076. * Returns true if sampling is enabled
  65077. */
  65078. readonly isEnabled: boolean;
  65079. /**
  65080. * Resets performance monitor
  65081. */
  65082. reset(): void;
  65083. }
  65084. /**
  65085. * RollingAverage
  65086. *
  65087. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65088. */
  65089. export class RollingAverage {
  65090. /**
  65091. * Current average
  65092. */
  65093. average: number;
  65094. /**
  65095. * Current variance
  65096. */
  65097. variance: number;
  65098. protected _samples: Array<number>;
  65099. protected _sampleCount: number;
  65100. protected _pos: number;
  65101. protected _m2: number;
  65102. /**
  65103. * constructor
  65104. * @param length The number of samples required to saturate the sliding window
  65105. */
  65106. constructor(length: number);
  65107. /**
  65108. * Adds a sample to the sample set
  65109. * @param v The sample value
  65110. */
  65111. add(v: number): void;
  65112. /**
  65113. * Returns previously added values or null if outside of history or outside the sliding window domain
  65114. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65115. * @return Value previously recorded with add() or null if outside of range
  65116. */
  65117. history(i: number): number;
  65118. /**
  65119. * Returns true if enough samples have been taken to completely fill the sliding window
  65120. * @return true if sample-set saturated
  65121. */
  65122. isSaturated(): boolean;
  65123. /**
  65124. * Resets the rolling average (equivalent to 0 samples taken so far)
  65125. */
  65126. reset(): void;
  65127. /**
  65128. * Wraps a value around the sample range boundaries
  65129. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65130. * @return Wrapped position in sample range
  65131. */
  65132. protected _wrapPosition(i: number): number;
  65133. }
  65134. }
  65135. declare module BABYLON {
  65136. /**
  65137. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65138. * The underlying implementation relies on an associative array to ensure the best performances.
  65139. * The value can be anything including 'null' but except 'undefined'
  65140. */
  65141. export class StringDictionary<T> {
  65142. /**
  65143. * This will clear this dictionary and copy the content from the 'source' one.
  65144. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65145. * @param source the dictionary to take the content from and copy to this dictionary
  65146. */
  65147. copyFrom(source: StringDictionary<T>): void;
  65148. /**
  65149. * Get a value based from its key
  65150. * @param key the given key to get the matching value from
  65151. * @return the value if found, otherwise undefined is returned
  65152. */
  65153. get(key: string): T | undefined;
  65154. /**
  65155. * Get a value from its key or add it if it doesn't exist.
  65156. * This method will ensure you that a given key/data will be present in the dictionary.
  65157. * @param key the given key to get the matching value from
  65158. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65159. * The factory will only be invoked if there's no data for the given key.
  65160. * @return the value corresponding to the key.
  65161. */
  65162. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65163. /**
  65164. * Get a value from its key if present in the dictionary otherwise add it
  65165. * @param key the key to get the value from
  65166. * @param val if there's no such key/value pair in the dictionary add it with this value
  65167. * @return the value corresponding to the key
  65168. */
  65169. getOrAdd(key: string, val: T): T;
  65170. /**
  65171. * Check if there's a given key in the dictionary
  65172. * @param key the key to check for
  65173. * @return true if the key is present, false otherwise
  65174. */
  65175. contains(key: string): boolean;
  65176. /**
  65177. * Add a new key and its corresponding value
  65178. * @param key the key to add
  65179. * @param value the value corresponding to the key
  65180. * @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
  65181. */
  65182. add(key: string, value: T): boolean;
  65183. /**
  65184. * Update a specific value associated to a key
  65185. * @param key defines the key to use
  65186. * @param value defines the value to store
  65187. * @returns true if the value was updated (or false if the key was not found)
  65188. */
  65189. set(key: string, value: T): boolean;
  65190. /**
  65191. * Get the element of the given key and remove it from the dictionary
  65192. * @param key defines the key to search
  65193. * @returns the value associated with the key or null if not found
  65194. */
  65195. getAndRemove(key: string): Nullable<T>;
  65196. /**
  65197. * Remove a key/value from the dictionary.
  65198. * @param key the key to remove
  65199. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65200. */
  65201. remove(key: string): boolean;
  65202. /**
  65203. * Clear the whole content of the dictionary
  65204. */
  65205. clear(): void;
  65206. /**
  65207. * Gets the current count
  65208. */
  65209. readonly count: number;
  65210. /**
  65211. * Execute a callback on each key/val of the dictionary.
  65212. * Note that you can remove any element in this dictionary in the callback implementation
  65213. * @param callback the callback to execute on a given key/value pair
  65214. */
  65215. forEach(callback: (key: string, val: T) => void): void;
  65216. /**
  65217. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65218. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65219. * Note that you can remove any element in this dictionary in the callback implementation
  65220. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65221. * @returns the first item
  65222. */
  65223. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65224. private _count;
  65225. private _data;
  65226. }
  65227. }
  65228. declare module BABYLON {
  65229. /**
  65230. * Class used to store gfx data (like WebGLBuffer)
  65231. */
  65232. export class DataBuffer {
  65233. /**
  65234. * Gets or sets the number of objects referencing this buffer
  65235. */
  65236. references: number;
  65237. /** Gets or sets the size of the underlying buffer */
  65238. capacity: number;
  65239. /**
  65240. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65241. */
  65242. is32Bits: boolean;
  65243. /**
  65244. * Gets the underlying buffer
  65245. */
  65246. readonly underlyingResource: any;
  65247. }
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * Class used to store data that will be store in GPU memory
  65252. */
  65253. export class Buffer {
  65254. private _engine;
  65255. private _buffer;
  65256. /** @hidden */
  65257. _data: Nullable<DataArray>;
  65258. private _updatable;
  65259. private _instanced;
  65260. /**
  65261. * Gets the byte stride.
  65262. */
  65263. readonly byteStride: number;
  65264. /**
  65265. * Constructor
  65266. * @param engine the engine
  65267. * @param data the data to use for this buffer
  65268. * @param updatable whether the data is updatable
  65269. * @param stride the stride (optional)
  65270. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65271. * @param instanced whether the buffer is instanced (optional)
  65272. * @param useBytes set to true if the stride in in bytes (optional)
  65273. */
  65274. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65275. /**
  65276. * Create a new VertexBuffer based on the current buffer
  65277. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65278. * @param offset defines offset in the buffer (0 by default)
  65279. * @param size defines the size in floats of attributes (position is 3 for instance)
  65280. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65281. * @param instanced defines if the vertex buffer contains indexed data
  65282. * @param useBytes defines if the offset and stride are in bytes
  65283. * @returns the new vertex buffer
  65284. */
  65285. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65286. /**
  65287. * Gets a boolean indicating if the Buffer is updatable?
  65288. * @returns true if the buffer is updatable
  65289. */
  65290. isUpdatable(): boolean;
  65291. /**
  65292. * Gets current buffer's data
  65293. * @returns a DataArray or null
  65294. */
  65295. getData(): Nullable<DataArray>;
  65296. /**
  65297. * Gets underlying native buffer
  65298. * @returns underlying native buffer
  65299. */
  65300. getBuffer(): Nullable<DataBuffer>;
  65301. /**
  65302. * Gets the stride in float32 units (i.e. byte stride / 4).
  65303. * May not be an integer if the byte stride is not divisible by 4.
  65304. * DEPRECATED. Use byteStride instead.
  65305. * @returns the stride in float32 units
  65306. */
  65307. getStrideSize(): number;
  65308. /**
  65309. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65310. * @param data defines the data to store
  65311. */
  65312. create(data?: Nullable<DataArray>): void;
  65313. /** @hidden */
  65314. _rebuild(): void;
  65315. /**
  65316. * Update current buffer data
  65317. * @param data defines the data to store
  65318. */
  65319. update(data: DataArray): void;
  65320. /**
  65321. * Updates the data directly.
  65322. * @param data the new data
  65323. * @param offset the new offset
  65324. * @param vertexCount the vertex count (optional)
  65325. * @param useBytes set to true if the offset is in bytes
  65326. */
  65327. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65328. /**
  65329. * Release all resources
  65330. */
  65331. dispose(): void;
  65332. }
  65333. /**
  65334. * Specialized buffer used to store vertex data
  65335. */
  65336. export class VertexBuffer {
  65337. /** @hidden */
  65338. _buffer: Buffer;
  65339. private _kind;
  65340. private _size;
  65341. private _ownsBuffer;
  65342. private _instanced;
  65343. private _instanceDivisor;
  65344. /**
  65345. * The byte type.
  65346. */
  65347. static readonly BYTE: number;
  65348. /**
  65349. * The unsigned byte type.
  65350. */
  65351. static readonly UNSIGNED_BYTE: number;
  65352. /**
  65353. * The short type.
  65354. */
  65355. static readonly SHORT: number;
  65356. /**
  65357. * The unsigned short type.
  65358. */
  65359. static readonly UNSIGNED_SHORT: number;
  65360. /**
  65361. * The integer type.
  65362. */
  65363. static readonly INT: number;
  65364. /**
  65365. * The unsigned integer type.
  65366. */
  65367. static readonly UNSIGNED_INT: number;
  65368. /**
  65369. * The float type.
  65370. */
  65371. static readonly FLOAT: number;
  65372. /**
  65373. * Gets or sets the instance divisor when in instanced mode
  65374. */
  65375. instanceDivisor: number;
  65376. /**
  65377. * Gets the byte stride.
  65378. */
  65379. readonly byteStride: number;
  65380. /**
  65381. * Gets the byte offset.
  65382. */
  65383. readonly byteOffset: number;
  65384. /**
  65385. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65386. */
  65387. readonly normalized: boolean;
  65388. /**
  65389. * Gets the data type of each component in the array.
  65390. */
  65391. readonly type: number;
  65392. /**
  65393. * Constructor
  65394. * @param engine the engine
  65395. * @param data the data to use for this vertex buffer
  65396. * @param kind the vertex buffer kind
  65397. * @param updatable whether the data is updatable
  65398. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65399. * @param stride the stride (optional)
  65400. * @param instanced whether the buffer is instanced (optional)
  65401. * @param offset the offset of the data (optional)
  65402. * @param size the number of components (optional)
  65403. * @param type the type of the component (optional)
  65404. * @param normalized whether the data contains normalized data (optional)
  65405. * @param useBytes set to true if stride and offset are in bytes (optional)
  65406. */
  65407. 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);
  65408. /** @hidden */
  65409. _rebuild(): void;
  65410. /**
  65411. * Returns the kind of the VertexBuffer (string)
  65412. * @returns a string
  65413. */
  65414. getKind(): string;
  65415. /**
  65416. * Gets a boolean indicating if the VertexBuffer is updatable?
  65417. * @returns true if the buffer is updatable
  65418. */
  65419. isUpdatable(): boolean;
  65420. /**
  65421. * Gets current buffer's data
  65422. * @returns a DataArray or null
  65423. */
  65424. getData(): Nullable<DataArray>;
  65425. /**
  65426. * Gets underlying native buffer
  65427. * @returns underlying native buffer
  65428. */
  65429. getBuffer(): Nullable<DataBuffer>;
  65430. /**
  65431. * Gets the stride in float32 units (i.e. byte stride / 4).
  65432. * May not be an integer if the byte stride is not divisible by 4.
  65433. * DEPRECATED. Use byteStride instead.
  65434. * @returns the stride in float32 units
  65435. */
  65436. getStrideSize(): number;
  65437. /**
  65438. * Returns the offset as a multiple of the type byte length.
  65439. * DEPRECATED. Use byteOffset instead.
  65440. * @returns the offset in bytes
  65441. */
  65442. getOffset(): number;
  65443. /**
  65444. * Returns the number of components per vertex attribute (integer)
  65445. * @returns the size in float
  65446. */
  65447. getSize(): number;
  65448. /**
  65449. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65450. * @returns true if this buffer is instanced
  65451. */
  65452. getIsInstanced(): boolean;
  65453. /**
  65454. * Returns the instancing divisor, zero for non-instanced (integer).
  65455. * @returns a number
  65456. */
  65457. getInstanceDivisor(): number;
  65458. /**
  65459. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65460. * @param data defines the data to store
  65461. */
  65462. create(data?: DataArray): void;
  65463. /**
  65464. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65465. * This function will create a new buffer if the current one is not updatable
  65466. * @param data defines the data to store
  65467. */
  65468. update(data: DataArray): void;
  65469. /**
  65470. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65471. * Returns the directly updated WebGLBuffer.
  65472. * @param data the new data
  65473. * @param offset the new offset
  65474. * @param useBytes set to true if the offset is in bytes
  65475. */
  65476. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65477. /**
  65478. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65479. */
  65480. dispose(): void;
  65481. /**
  65482. * Enumerates each value of this vertex buffer as numbers.
  65483. * @param count the number of values to enumerate
  65484. * @param callback the callback function called for each value
  65485. */
  65486. forEach(count: number, callback: (value: number, index: number) => void): void;
  65487. /**
  65488. * Positions
  65489. */
  65490. static readonly PositionKind: string;
  65491. /**
  65492. * Normals
  65493. */
  65494. static readonly NormalKind: string;
  65495. /**
  65496. * Tangents
  65497. */
  65498. static readonly TangentKind: string;
  65499. /**
  65500. * Texture coordinates
  65501. */
  65502. static readonly UVKind: string;
  65503. /**
  65504. * Texture coordinates 2
  65505. */
  65506. static readonly UV2Kind: string;
  65507. /**
  65508. * Texture coordinates 3
  65509. */
  65510. static readonly UV3Kind: string;
  65511. /**
  65512. * Texture coordinates 4
  65513. */
  65514. static readonly UV4Kind: string;
  65515. /**
  65516. * Texture coordinates 5
  65517. */
  65518. static readonly UV5Kind: string;
  65519. /**
  65520. * Texture coordinates 6
  65521. */
  65522. static readonly UV6Kind: string;
  65523. /**
  65524. * Colors
  65525. */
  65526. static readonly ColorKind: string;
  65527. /**
  65528. * Matrix indices (for bones)
  65529. */
  65530. static readonly MatricesIndicesKind: string;
  65531. /**
  65532. * Matrix weights (for bones)
  65533. */
  65534. static readonly MatricesWeightsKind: string;
  65535. /**
  65536. * Additional matrix indices (for bones)
  65537. */
  65538. static readonly MatricesIndicesExtraKind: string;
  65539. /**
  65540. * Additional matrix weights (for bones)
  65541. */
  65542. static readonly MatricesWeightsExtraKind: string;
  65543. /**
  65544. * Deduces the stride given a kind.
  65545. * @param kind The kind string to deduce
  65546. * @returns The deduced stride
  65547. */
  65548. static DeduceStride(kind: string): number;
  65549. /**
  65550. * Gets the byte length of the given type.
  65551. * @param type the type
  65552. * @returns the number of bytes
  65553. */
  65554. static GetTypeByteLength(type: number): number;
  65555. /**
  65556. * Enumerates each value of the given parameters as numbers.
  65557. * @param data the data to enumerate
  65558. * @param byteOffset the byte offset of the data
  65559. * @param byteStride the byte stride of the data
  65560. * @param componentCount the number of components per element
  65561. * @param componentType the type of the component
  65562. * @param count the number of values to enumerate
  65563. * @param normalized whether the data is normalized
  65564. * @param callback the callback function called for each value
  65565. */
  65566. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65567. private static _GetFloatValue;
  65568. }
  65569. }
  65570. declare module BABYLON {
  65571. /**
  65572. * Scalar computation library
  65573. */
  65574. export class Scalar {
  65575. /**
  65576. * Two pi constants convenient for computation.
  65577. */
  65578. static TwoPi: number;
  65579. /**
  65580. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65581. * @param a number
  65582. * @param b number
  65583. * @param epsilon (default = 1.401298E-45)
  65584. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65585. */
  65586. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65587. /**
  65588. * Returns a string : the upper case translation of the number i to hexadecimal.
  65589. * @param i number
  65590. * @returns the upper case translation of the number i to hexadecimal.
  65591. */
  65592. static ToHex(i: number): string;
  65593. /**
  65594. * Returns -1 if value is negative and +1 is value is positive.
  65595. * @param value the value
  65596. * @returns the value itself if it's equal to zero.
  65597. */
  65598. static Sign(value: number): number;
  65599. /**
  65600. * Returns the value itself if it's between min and max.
  65601. * Returns min if the value is lower than min.
  65602. * Returns max if the value is greater than max.
  65603. * @param value the value to clmap
  65604. * @param min the min value to clamp to (default: 0)
  65605. * @param max the max value to clamp to (default: 1)
  65606. * @returns the clamped value
  65607. */
  65608. static Clamp(value: number, min?: number, max?: number): number;
  65609. /**
  65610. * the log2 of value.
  65611. * @param value the value to compute log2 of
  65612. * @returns the log2 of value.
  65613. */
  65614. static Log2(value: number): number;
  65615. /**
  65616. * Loops the value, so that it is never larger than length and never smaller than 0.
  65617. *
  65618. * This is similar to the modulo operator but it works with floating point numbers.
  65619. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65620. * With t = 5 and length = 2.5, the result would be 0.0.
  65621. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65622. * @param value the value
  65623. * @param length the length
  65624. * @returns the looped value
  65625. */
  65626. static Repeat(value: number, length: number): number;
  65627. /**
  65628. * Normalize the value between 0.0 and 1.0 using min and max values
  65629. * @param value value to normalize
  65630. * @param min max to normalize between
  65631. * @param max min to normalize between
  65632. * @returns the normalized value
  65633. */
  65634. static Normalize(value: number, min: number, max: number): number;
  65635. /**
  65636. * Denormalize the value from 0.0 and 1.0 using min and max values
  65637. * @param normalized value to denormalize
  65638. * @param min max to denormalize between
  65639. * @param max min to denormalize between
  65640. * @returns the denormalized value
  65641. */
  65642. static Denormalize(normalized: number, min: number, max: number): number;
  65643. /**
  65644. * Calculates the shortest difference between two given angles given in degrees.
  65645. * @param current current angle in degrees
  65646. * @param target target angle in degrees
  65647. * @returns the delta
  65648. */
  65649. static DeltaAngle(current: number, target: number): number;
  65650. /**
  65651. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65652. * @param tx value
  65653. * @param length length
  65654. * @returns The returned value will move back and forth between 0 and length
  65655. */
  65656. static PingPong(tx: number, length: number): number;
  65657. /**
  65658. * Interpolates between min and max with smoothing at the limits.
  65659. *
  65660. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65661. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65662. * @param from from
  65663. * @param to to
  65664. * @param tx value
  65665. * @returns the smooth stepped value
  65666. */
  65667. static SmoothStep(from: number, to: number, tx: number): number;
  65668. /**
  65669. * Moves a value current towards target.
  65670. *
  65671. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65672. * Negative values of maxDelta pushes the value away from target.
  65673. * @param current current value
  65674. * @param target target value
  65675. * @param maxDelta max distance to move
  65676. * @returns resulting value
  65677. */
  65678. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65679. /**
  65680. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65681. *
  65682. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65683. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65684. * @param current current value
  65685. * @param target target value
  65686. * @param maxDelta max distance to move
  65687. * @returns resulting angle
  65688. */
  65689. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65690. /**
  65691. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65692. * @param start start value
  65693. * @param end target value
  65694. * @param amount amount to lerp between
  65695. * @returns the lerped value
  65696. */
  65697. static Lerp(start: number, end: number, amount: number): number;
  65698. /**
  65699. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65700. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65701. * @param start start value
  65702. * @param end target value
  65703. * @param amount amount to lerp between
  65704. * @returns the lerped value
  65705. */
  65706. static LerpAngle(start: number, end: number, amount: number): number;
  65707. /**
  65708. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65709. * @param a start value
  65710. * @param b target value
  65711. * @param value value between a and b
  65712. * @returns the inverseLerp value
  65713. */
  65714. static InverseLerp(a: number, b: number, value: number): number;
  65715. /**
  65716. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65717. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65718. * @param value1 spline value
  65719. * @param tangent1 spline value
  65720. * @param value2 spline value
  65721. * @param tangent2 spline value
  65722. * @param amount input value
  65723. * @returns hermite result
  65724. */
  65725. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65726. /**
  65727. * Returns a random float number between and min and max values
  65728. * @param min min value of random
  65729. * @param max max value of random
  65730. * @returns random value
  65731. */
  65732. static RandomRange(min: number, max: number): number;
  65733. /**
  65734. * This function returns percentage of a number in a given range.
  65735. *
  65736. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65737. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65738. * @param number to convert to percentage
  65739. * @param min min range
  65740. * @param max max range
  65741. * @returns the percentage
  65742. */
  65743. static RangeToPercent(number: number, min: number, max: number): number;
  65744. /**
  65745. * This function returns number that corresponds to the percentage in a given range.
  65746. *
  65747. * PercentToRange(0.34,0,100) will return 34.
  65748. * @param percent to convert to number
  65749. * @param min min range
  65750. * @param max max range
  65751. * @returns the number
  65752. */
  65753. static PercentToRange(percent: number, min: number, max: number): number;
  65754. /**
  65755. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65756. * @param angle The angle to normalize in radian.
  65757. * @return The converted angle.
  65758. */
  65759. static NormalizeRadians(angle: number): number;
  65760. }
  65761. }
  65762. declare module BABYLON {
  65763. /**
  65764. * Constant used to convert a value to gamma space
  65765. * @ignorenaming
  65766. */
  65767. export const ToGammaSpace: number;
  65768. /**
  65769. * Constant used to convert a value to linear space
  65770. * @ignorenaming
  65771. */
  65772. export const ToLinearSpace = 2.2;
  65773. /**
  65774. * Constant used to define the minimal number value in Babylon.js
  65775. * @ignorenaming
  65776. */
  65777. let Epsilon: number;
  65778. }
  65779. declare module BABYLON {
  65780. /**
  65781. * Class used to represent a viewport on screen
  65782. */
  65783. export class Viewport {
  65784. /** viewport left coordinate */
  65785. x: number;
  65786. /** viewport top coordinate */
  65787. y: number;
  65788. /**viewport width */
  65789. width: number;
  65790. /** viewport height */
  65791. height: number;
  65792. /**
  65793. * Creates a Viewport object located at (x, y) and sized (width, height)
  65794. * @param x defines viewport left coordinate
  65795. * @param y defines viewport top coordinate
  65796. * @param width defines the viewport width
  65797. * @param height defines the viewport height
  65798. */
  65799. constructor(
  65800. /** viewport left coordinate */
  65801. x: number,
  65802. /** viewport top coordinate */
  65803. y: number,
  65804. /**viewport width */
  65805. width: number,
  65806. /** viewport height */
  65807. height: number);
  65808. /**
  65809. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65810. * @param renderWidth defines the rendering width
  65811. * @param renderHeight defines the rendering height
  65812. * @returns a new Viewport
  65813. */
  65814. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65815. /**
  65816. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65817. * @param renderWidth defines the rendering width
  65818. * @param renderHeight defines the rendering height
  65819. * @param ref defines the target viewport
  65820. * @returns the current viewport
  65821. */
  65822. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65823. /**
  65824. * Returns a new Viewport copied from the current one
  65825. * @returns a new Viewport
  65826. */
  65827. clone(): Viewport;
  65828. }
  65829. }
  65830. declare module BABYLON {
  65831. /**
  65832. * Class containing a set of static utilities functions for arrays.
  65833. */
  65834. export class ArrayTools {
  65835. /**
  65836. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65837. * @param size the number of element to construct and put in the array
  65838. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65839. * @returns a new array filled with new objects
  65840. */
  65841. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65842. }
  65843. }
  65844. declare module BABYLON {
  65845. /**
  65846. * @hidden
  65847. */
  65848. export interface IColor4Like {
  65849. r: float;
  65850. g: float;
  65851. b: float;
  65852. a: float;
  65853. }
  65854. /**
  65855. * @hidden
  65856. */
  65857. export interface IColor3Like {
  65858. r: float;
  65859. g: float;
  65860. b: float;
  65861. }
  65862. /**
  65863. * @hidden
  65864. */
  65865. export interface IVector4Like {
  65866. x: float;
  65867. y: float;
  65868. z: float;
  65869. w: float;
  65870. }
  65871. /**
  65872. * @hidden
  65873. */
  65874. export interface IVector3Like {
  65875. x: float;
  65876. y: float;
  65877. z: float;
  65878. }
  65879. /**
  65880. * @hidden
  65881. */
  65882. export interface IVector2Like {
  65883. x: float;
  65884. y: float;
  65885. }
  65886. /**
  65887. * @hidden
  65888. */
  65889. export interface IMatrixLike {
  65890. toArray(): DeepImmutable<Float32Array>;
  65891. updateFlag: int;
  65892. }
  65893. /**
  65894. * @hidden
  65895. */
  65896. export interface IViewportLike {
  65897. x: float;
  65898. y: float;
  65899. width: float;
  65900. height: float;
  65901. }
  65902. /**
  65903. * @hidden
  65904. */
  65905. export interface IPlaneLike {
  65906. normal: IVector3Like;
  65907. d: float;
  65908. normalize(): void;
  65909. }
  65910. }
  65911. declare module BABYLON {
  65912. /**
  65913. * Class representing a vector containing 2 coordinates
  65914. */
  65915. export class Vector2 {
  65916. /** defines the first coordinate */
  65917. x: number;
  65918. /** defines the second coordinate */
  65919. y: number;
  65920. /**
  65921. * Creates a new Vector2 from the given x and y coordinates
  65922. * @param x defines the first coordinate
  65923. * @param y defines the second coordinate
  65924. */
  65925. constructor(
  65926. /** defines the first coordinate */
  65927. x?: number,
  65928. /** defines the second coordinate */
  65929. y?: number);
  65930. /**
  65931. * Gets a string with the Vector2 coordinates
  65932. * @returns a string with the Vector2 coordinates
  65933. */
  65934. toString(): string;
  65935. /**
  65936. * Gets class name
  65937. * @returns the string "Vector2"
  65938. */
  65939. getClassName(): string;
  65940. /**
  65941. * Gets current vector hash code
  65942. * @returns the Vector2 hash code as a number
  65943. */
  65944. getHashCode(): number;
  65945. /**
  65946. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65947. * @param array defines the source array
  65948. * @param index defines the offset in source array
  65949. * @returns the current Vector2
  65950. */
  65951. toArray(array: FloatArray, index?: number): Vector2;
  65952. /**
  65953. * Copy the current vector to an array
  65954. * @returns a new array with 2 elements: the Vector2 coordinates.
  65955. */
  65956. asArray(): number[];
  65957. /**
  65958. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65959. * @param source defines the source Vector2
  65960. * @returns the current updated Vector2
  65961. */
  65962. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65963. /**
  65964. * Sets the Vector2 coordinates with the given floats
  65965. * @param x defines the first coordinate
  65966. * @param y defines the second coordinate
  65967. * @returns the current updated Vector2
  65968. */
  65969. copyFromFloats(x: number, y: number): Vector2;
  65970. /**
  65971. * Sets the Vector2 coordinates with the given floats
  65972. * @param x defines the first coordinate
  65973. * @param y defines the second coordinate
  65974. * @returns the current updated Vector2
  65975. */
  65976. set(x: number, y: number): Vector2;
  65977. /**
  65978. * Add another vector with the current one
  65979. * @param otherVector defines the other vector
  65980. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65981. */
  65982. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65983. /**
  65984. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65985. * @param otherVector defines the other vector
  65986. * @param result defines the target vector
  65987. * @returns the unmodified current Vector2
  65988. */
  65989. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65990. /**
  65991. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65992. * @param otherVector defines the other vector
  65993. * @returns the current updated Vector2
  65994. */
  65995. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65996. /**
  65997. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65998. * @param otherVector defines the other vector
  65999. * @returns a new Vector2
  66000. */
  66001. addVector3(otherVector: Vector3): Vector2;
  66002. /**
  66003. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66004. * @param otherVector defines the other vector
  66005. * @returns a new Vector2
  66006. */
  66007. subtract(otherVector: Vector2): Vector2;
  66008. /**
  66009. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66010. * @param otherVector defines the other vector
  66011. * @param result defines the target vector
  66012. * @returns the unmodified current Vector2
  66013. */
  66014. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66015. /**
  66016. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66017. * @param otherVector defines the other vector
  66018. * @returns the current updated Vector2
  66019. */
  66020. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66021. /**
  66022. * Multiplies in place the current Vector2 coordinates by the given ones
  66023. * @param otherVector defines the other vector
  66024. * @returns the current updated Vector2
  66025. */
  66026. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66027. /**
  66028. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66029. * @param otherVector defines the other vector
  66030. * @returns a new Vector2
  66031. */
  66032. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66033. /**
  66034. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66035. * @param otherVector defines the other vector
  66036. * @param result defines the target vector
  66037. * @returns the unmodified current Vector2
  66038. */
  66039. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66040. /**
  66041. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66042. * @param x defines the first coordinate
  66043. * @param y defines the second coordinate
  66044. * @returns a new Vector2
  66045. */
  66046. multiplyByFloats(x: number, y: number): Vector2;
  66047. /**
  66048. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66049. * @param otherVector defines the other vector
  66050. * @returns a new Vector2
  66051. */
  66052. divide(otherVector: Vector2): Vector2;
  66053. /**
  66054. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66055. * @param otherVector defines the other vector
  66056. * @param result defines the target vector
  66057. * @returns the unmodified current Vector2
  66058. */
  66059. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66060. /**
  66061. * Divides the current Vector2 coordinates by the given ones
  66062. * @param otherVector defines the other vector
  66063. * @returns the current updated Vector2
  66064. */
  66065. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66066. /**
  66067. * Gets a new Vector2 with current Vector2 negated coordinates
  66068. * @returns a new Vector2
  66069. */
  66070. negate(): Vector2;
  66071. /**
  66072. * Multiply the Vector2 coordinates by scale
  66073. * @param scale defines the scaling factor
  66074. * @returns the current updated Vector2
  66075. */
  66076. scaleInPlace(scale: number): Vector2;
  66077. /**
  66078. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66079. * @param scale defines the scaling factor
  66080. * @returns a new Vector2
  66081. */
  66082. scale(scale: number): Vector2;
  66083. /**
  66084. * Scale the current Vector2 values by a factor to a given Vector2
  66085. * @param scale defines the scale factor
  66086. * @param result defines the Vector2 object where to store the result
  66087. * @returns the unmodified current Vector2
  66088. */
  66089. scaleToRef(scale: number, result: Vector2): Vector2;
  66090. /**
  66091. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66092. * @param scale defines the scale factor
  66093. * @param result defines the Vector2 object where to store the result
  66094. * @returns the unmodified current Vector2
  66095. */
  66096. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66097. /**
  66098. * Gets a boolean if two vectors are equals
  66099. * @param otherVector defines the other vector
  66100. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66101. */
  66102. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66103. /**
  66104. * Gets a boolean if two vectors are equals (using an epsilon value)
  66105. * @param otherVector defines the other vector
  66106. * @param epsilon defines the minimal distance to consider equality
  66107. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66108. */
  66109. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66110. /**
  66111. * Gets a new Vector2 from current Vector2 floored values
  66112. * @returns a new Vector2
  66113. */
  66114. floor(): Vector2;
  66115. /**
  66116. * Gets a new Vector2 from current Vector2 floored values
  66117. * @returns a new Vector2
  66118. */
  66119. fract(): Vector2;
  66120. /**
  66121. * Gets the length of the vector
  66122. * @returns the vector length (float)
  66123. */
  66124. length(): number;
  66125. /**
  66126. * Gets the vector squared length
  66127. * @returns the vector squared length (float)
  66128. */
  66129. lengthSquared(): number;
  66130. /**
  66131. * Normalize the vector
  66132. * @returns the current updated Vector2
  66133. */
  66134. normalize(): Vector2;
  66135. /**
  66136. * Gets a new Vector2 copied from the Vector2
  66137. * @returns a new Vector2
  66138. */
  66139. clone(): Vector2;
  66140. /**
  66141. * Gets a new Vector2(0, 0)
  66142. * @returns a new Vector2
  66143. */
  66144. static Zero(): Vector2;
  66145. /**
  66146. * Gets a new Vector2(1, 1)
  66147. * @returns a new Vector2
  66148. */
  66149. static One(): Vector2;
  66150. /**
  66151. * Gets a new Vector2 set from the given index element of the given array
  66152. * @param array defines the data source
  66153. * @param offset defines the offset in the data source
  66154. * @returns a new Vector2
  66155. */
  66156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66157. /**
  66158. * Sets "result" from the given index element of the given array
  66159. * @param array defines the data source
  66160. * @param offset defines the offset in the data source
  66161. * @param result defines the target vector
  66162. */
  66163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66164. /**
  66165. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66166. * @param value1 defines 1st point of control
  66167. * @param value2 defines 2nd point of control
  66168. * @param value3 defines 3rd point of control
  66169. * @param value4 defines 4th point of control
  66170. * @param amount defines the interpolation factor
  66171. * @returns a new Vector2
  66172. */
  66173. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66174. /**
  66175. * 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".
  66176. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66177. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66178. * @param value defines the value to clamp
  66179. * @param min defines the lower limit
  66180. * @param max defines the upper limit
  66181. * @returns a new Vector2
  66182. */
  66183. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66184. /**
  66185. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66186. * @param value1 defines the 1st control point
  66187. * @param tangent1 defines the outgoing tangent
  66188. * @param value2 defines the 2nd control point
  66189. * @param tangent2 defines the incoming tangent
  66190. * @param amount defines the interpolation factor
  66191. * @returns a new Vector2
  66192. */
  66193. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66194. /**
  66195. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66196. * @param start defines the start vector
  66197. * @param end defines the end vector
  66198. * @param amount defines the interpolation factor
  66199. * @returns a new Vector2
  66200. */
  66201. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66202. /**
  66203. * Gets the dot product of the vector "left" and the vector "right"
  66204. * @param left defines first vector
  66205. * @param right defines second vector
  66206. * @returns the dot product (float)
  66207. */
  66208. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66209. /**
  66210. * Returns a new Vector2 equal to the normalized given vector
  66211. * @param vector defines the vector to normalize
  66212. * @returns a new Vector2
  66213. */
  66214. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66215. /**
  66216. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66217. * @param left defines 1st vector
  66218. * @param right defines 2nd vector
  66219. * @returns a new Vector2
  66220. */
  66221. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66222. /**
  66223. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66224. * @param left defines 1st vector
  66225. * @param right defines 2nd vector
  66226. * @returns a new Vector2
  66227. */
  66228. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66229. /**
  66230. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66231. * @param vector defines the vector to transform
  66232. * @param transformation defines the matrix to apply
  66233. * @returns a new Vector2
  66234. */
  66235. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66236. /**
  66237. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66238. * @param vector defines the vector to transform
  66239. * @param transformation defines the matrix to apply
  66240. * @param result defines the target vector
  66241. */
  66242. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66243. /**
  66244. * Determines if a given vector is included in a triangle
  66245. * @param p defines the vector to test
  66246. * @param p0 defines 1st triangle point
  66247. * @param p1 defines 2nd triangle point
  66248. * @param p2 defines 3rd triangle point
  66249. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66250. */
  66251. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66252. /**
  66253. * Gets the distance between the vectors "value1" and "value2"
  66254. * @param value1 defines first vector
  66255. * @param value2 defines second vector
  66256. * @returns the distance between vectors
  66257. */
  66258. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66259. /**
  66260. * Returns the squared distance between the vectors "value1" and "value2"
  66261. * @param value1 defines first vector
  66262. * @param value2 defines second vector
  66263. * @returns the squared distance between vectors
  66264. */
  66265. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66266. /**
  66267. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66268. * @param value1 defines first vector
  66269. * @param value2 defines second vector
  66270. * @returns a new Vector2
  66271. */
  66272. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66273. /**
  66274. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66275. * @param p defines the middle point
  66276. * @param segA defines one point of the segment
  66277. * @param segB defines the other point of the segment
  66278. * @returns the shortest distance
  66279. */
  66280. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66281. }
  66282. /**
  66283. * Classed used to store (x,y,z) vector representation
  66284. * A Vector3 is the main object used in 3D geometry
  66285. * It can represent etiher the coordinates of a point the space, either a direction
  66286. * Reminder: js uses a left handed forward facing system
  66287. */
  66288. export class Vector3 {
  66289. /**
  66290. * Defines the first coordinates (on X axis)
  66291. */
  66292. x: number;
  66293. /**
  66294. * Defines the second coordinates (on Y axis)
  66295. */
  66296. y: number;
  66297. /**
  66298. * Defines the third coordinates (on Z axis)
  66299. */
  66300. z: number;
  66301. private static _UpReadOnly;
  66302. private static _ZeroReadOnly;
  66303. /**
  66304. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66305. * @param x defines the first coordinates (on X axis)
  66306. * @param y defines the second coordinates (on Y axis)
  66307. * @param z defines the third coordinates (on Z axis)
  66308. */
  66309. constructor(
  66310. /**
  66311. * Defines the first coordinates (on X axis)
  66312. */
  66313. x?: number,
  66314. /**
  66315. * Defines the second coordinates (on Y axis)
  66316. */
  66317. y?: number,
  66318. /**
  66319. * Defines the third coordinates (on Z axis)
  66320. */
  66321. z?: number);
  66322. /**
  66323. * Creates a string representation of the Vector3
  66324. * @returns a string with the Vector3 coordinates.
  66325. */
  66326. toString(): string;
  66327. /**
  66328. * Gets the class name
  66329. * @returns the string "Vector3"
  66330. */
  66331. getClassName(): string;
  66332. /**
  66333. * Creates the Vector3 hash code
  66334. * @returns a number which tends to be unique between Vector3 instances
  66335. */
  66336. getHashCode(): number;
  66337. /**
  66338. * Creates an array containing three elements : the coordinates of the Vector3
  66339. * @returns a new array of numbers
  66340. */
  66341. asArray(): number[];
  66342. /**
  66343. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66344. * @param array defines the destination array
  66345. * @param index defines the offset in the destination array
  66346. * @returns the current Vector3
  66347. */
  66348. toArray(array: FloatArray, index?: number): Vector3;
  66349. /**
  66350. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66351. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66352. */
  66353. toQuaternion(): Quaternion;
  66354. /**
  66355. * Adds the given vector to the current Vector3
  66356. * @param otherVector defines the second operand
  66357. * @returns the current updated Vector3
  66358. */
  66359. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66360. /**
  66361. * Adds the given coordinates to the current Vector3
  66362. * @param x defines the x coordinate of the operand
  66363. * @param y defines the y coordinate of the operand
  66364. * @param z defines the z coordinate of the operand
  66365. * @returns the current updated Vector3
  66366. */
  66367. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66368. /**
  66369. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66370. * @param otherVector defines the second operand
  66371. * @returns the resulting Vector3
  66372. */
  66373. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66374. /**
  66375. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66376. * @param otherVector defines the second operand
  66377. * @param result defines the Vector3 object where to store the result
  66378. * @returns the current Vector3
  66379. */
  66380. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66381. /**
  66382. * Subtract the given vector from the current Vector3
  66383. * @param otherVector defines the second operand
  66384. * @returns the current updated Vector3
  66385. */
  66386. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66387. /**
  66388. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66389. * @param otherVector defines the second operand
  66390. * @returns the resulting Vector3
  66391. */
  66392. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66393. /**
  66394. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66395. * @param otherVector defines the second operand
  66396. * @param result defines the Vector3 object where to store the result
  66397. * @returns the current Vector3
  66398. */
  66399. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66400. /**
  66401. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66402. * @param x defines the x coordinate of the operand
  66403. * @param y defines the y coordinate of the operand
  66404. * @param z defines the z coordinate of the operand
  66405. * @returns the resulting Vector3
  66406. */
  66407. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66408. /**
  66409. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66410. * @param x defines the x coordinate of the operand
  66411. * @param y defines the y coordinate of the operand
  66412. * @param z defines the z coordinate of the operand
  66413. * @param result defines the Vector3 object where to store the result
  66414. * @returns the current Vector3
  66415. */
  66416. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66417. /**
  66418. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66419. * @returns a new Vector3
  66420. */
  66421. negate(): Vector3;
  66422. /**
  66423. * Multiplies the Vector3 coordinates by the float "scale"
  66424. * @param scale defines the multiplier factor
  66425. * @returns the current updated Vector3
  66426. */
  66427. scaleInPlace(scale: number): Vector3;
  66428. /**
  66429. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66430. * @param scale defines the multiplier factor
  66431. * @returns a new Vector3
  66432. */
  66433. scale(scale: number): Vector3;
  66434. /**
  66435. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66436. * @param scale defines the multiplier factor
  66437. * @param result defines the Vector3 object where to store the result
  66438. * @returns the current Vector3
  66439. */
  66440. scaleToRef(scale: number, result: Vector3): Vector3;
  66441. /**
  66442. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66443. * @param scale defines the scale factor
  66444. * @param result defines the Vector3 object where to store the result
  66445. * @returns the unmodified current Vector3
  66446. */
  66447. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66448. /**
  66449. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66450. * @param otherVector defines the second operand
  66451. * @returns true if both vectors are equals
  66452. */
  66453. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66454. /**
  66455. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66456. * @param otherVector defines the second operand
  66457. * @param epsilon defines the minimal distance to define values as equals
  66458. * @returns true if both vectors are distant less than epsilon
  66459. */
  66460. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66461. /**
  66462. * Returns true if the current Vector3 coordinates equals the given floats
  66463. * @param x defines the x coordinate of the operand
  66464. * @param y defines the y coordinate of the operand
  66465. * @param z defines the z coordinate of the operand
  66466. * @returns true if both vectors are equals
  66467. */
  66468. equalsToFloats(x: number, y: number, z: number): boolean;
  66469. /**
  66470. * Multiplies the current Vector3 coordinates by the given ones
  66471. * @param otherVector defines the second operand
  66472. * @returns the current updated Vector3
  66473. */
  66474. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66475. /**
  66476. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66477. * @param otherVector defines the second operand
  66478. * @returns the new Vector3
  66479. */
  66480. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66481. /**
  66482. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66483. * @param otherVector defines the second operand
  66484. * @param result defines the Vector3 object where to store the result
  66485. * @returns the current Vector3
  66486. */
  66487. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66488. /**
  66489. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66490. * @param x defines the x coordinate of the operand
  66491. * @param y defines the y coordinate of the operand
  66492. * @param z defines the z coordinate of the operand
  66493. * @returns the new Vector3
  66494. */
  66495. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66496. /**
  66497. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66498. * @param otherVector defines the second operand
  66499. * @returns the new Vector3
  66500. */
  66501. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66502. /**
  66503. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66504. * @param otherVector defines the second operand
  66505. * @param result defines the Vector3 object where to store the result
  66506. * @returns the current Vector3
  66507. */
  66508. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66509. /**
  66510. * Divides the current Vector3 coordinates by the given ones.
  66511. * @param otherVector defines the second operand
  66512. * @returns the current updated Vector3
  66513. */
  66514. divideInPlace(otherVector: Vector3): Vector3;
  66515. /**
  66516. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66517. * @param other defines the second operand
  66518. * @returns the current updated Vector3
  66519. */
  66520. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66521. /**
  66522. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66523. * @param other defines the second operand
  66524. * @returns the current updated Vector3
  66525. */
  66526. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66527. /**
  66528. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66529. * @param x defines the x coordinate of the operand
  66530. * @param y defines the y coordinate of the operand
  66531. * @param z defines the z coordinate of the operand
  66532. * @returns the current updated Vector3
  66533. */
  66534. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66535. /**
  66536. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66537. * @param x defines the x coordinate of the operand
  66538. * @param y defines the y coordinate of the operand
  66539. * @param z defines the z coordinate of the operand
  66540. * @returns the current updated Vector3
  66541. */
  66542. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66543. /**
  66544. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66545. * Check if is non uniform within a certain amount of decimal places to account for this
  66546. * @param epsilon the amount the values can differ
  66547. * @returns if the the vector is non uniform to a certain number of decimal places
  66548. */
  66549. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66550. /**
  66551. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66552. */
  66553. readonly isNonUniform: boolean;
  66554. /**
  66555. * Gets a new Vector3 from current Vector3 floored values
  66556. * @returns a new Vector3
  66557. */
  66558. floor(): Vector3;
  66559. /**
  66560. * Gets a new Vector3 from current Vector3 floored values
  66561. * @returns a new Vector3
  66562. */
  66563. fract(): Vector3;
  66564. /**
  66565. * Gets the length of the Vector3
  66566. * @returns the length of the Vector3
  66567. */
  66568. length(): number;
  66569. /**
  66570. * Gets the squared length of the Vector3
  66571. * @returns squared length of the Vector3
  66572. */
  66573. lengthSquared(): number;
  66574. /**
  66575. * Normalize the current Vector3.
  66576. * Please note that this is an in place operation.
  66577. * @returns the current updated Vector3
  66578. */
  66579. normalize(): Vector3;
  66580. /**
  66581. * Reorders the x y z properties of the vector in place
  66582. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66583. * @returns the current updated vector
  66584. */
  66585. reorderInPlace(order: string): this;
  66586. /**
  66587. * Rotates the vector around 0,0,0 by a quaternion
  66588. * @param quaternion the rotation quaternion
  66589. * @param result vector to store the result
  66590. * @returns the resulting vector
  66591. */
  66592. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66593. /**
  66594. * Rotates a vector around a given point
  66595. * @param quaternion the rotation quaternion
  66596. * @param point the point to rotate around
  66597. * @param result vector to store the result
  66598. * @returns the resulting vector
  66599. */
  66600. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66601. /**
  66602. * Normalize the current Vector3 with the given input length.
  66603. * Please note that this is an in place operation.
  66604. * @param len the length of the vector
  66605. * @returns the current updated Vector3
  66606. */
  66607. normalizeFromLength(len: number): Vector3;
  66608. /**
  66609. * Normalize the current Vector3 to a new vector
  66610. * @returns the new Vector3
  66611. */
  66612. normalizeToNew(): Vector3;
  66613. /**
  66614. * Normalize the current Vector3 to the reference
  66615. * @param reference define the Vector3 to update
  66616. * @returns the updated Vector3
  66617. */
  66618. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66619. /**
  66620. * Creates a new Vector3 copied from the current Vector3
  66621. * @returns the new Vector3
  66622. */
  66623. clone(): Vector3;
  66624. /**
  66625. * Copies the given vector coordinates to the current Vector3 ones
  66626. * @param source defines the source Vector3
  66627. * @returns the current updated Vector3
  66628. */
  66629. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66630. /**
  66631. * Copies the given floats to the current Vector3 coordinates
  66632. * @param x defines the x coordinate of the operand
  66633. * @param y defines the y coordinate of the operand
  66634. * @param z defines the z coordinate of the operand
  66635. * @returns the current updated Vector3
  66636. */
  66637. copyFromFloats(x: number, y: number, z: number): Vector3;
  66638. /**
  66639. * Copies the given floats to the current Vector3 coordinates
  66640. * @param x defines the x coordinate of the operand
  66641. * @param y defines the y coordinate of the operand
  66642. * @param z defines the z coordinate of the operand
  66643. * @returns the current updated Vector3
  66644. */
  66645. set(x: number, y: number, z: number): Vector3;
  66646. /**
  66647. * Copies the given float to the current Vector3 coordinates
  66648. * @param v defines the x, y and z coordinates of the operand
  66649. * @returns the current updated Vector3
  66650. */
  66651. setAll(v: number): Vector3;
  66652. /**
  66653. * Get the clip factor between two vectors
  66654. * @param vector0 defines the first operand
  66655. * @param vector1 defines the second operand
  66656. * @param axis defines the axis to use
  66657. * @param size defines the size along the axis
  66658. * @returns the clip factor
  66659. */
  66660. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66661. /**
  66662. * Get angle between two vectors
  66663. * @param vector0 angle between vector0 and vector1
  66664. * @param vector1 angle between vector0 and vector1
  66665. * @param normal direction of the normal
  66666. * @return the angle between vector0 and vector1
  66667. */
  66668. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66669. /**
  66670. * Returns a new Vector3 set from the index "offset" of the given array
  66671. * @param array defines the source array
  66672. * @param offset defines the offset in the source array
  66673. * @returns the new Vector3
  66674. */
  66675. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66676. /**
  66677. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66678. * This function is deprecated. Use FromArray instead
  66679. * @param array defines the source array
  66680. * @param offset defines the offset in the source array
  66681. * @returns the new Vector3
  66682. */
  66683. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66684. /**
  66685. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66686. * @param array defines the source array
  66687. * @param offset defines the offset in the source array
  66688. * @param result defines the Vector3 where to store the result
  66689. */
  66690. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66691. /**
  66692. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66693. * This function is deprecated. Use FromArrayToRef instead.
  66694. * @param array defines the source array
  66695. * @param offset defines the offset in the source array
  66696. * @param result defines the Vector3 where to store the result
  66697. */
  66698. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66699. /**
  66700. * Sets the given vector "result" with the given floats.
  66701. * @param x defines the x coordinate of the source
  66702. * @param y defines the y coordinate of the source
  66703. * @param z defines the z coordinate of the source
  66704. * @param result defines the Vector3 where to store the result
  66705. */
  66706. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66707. /**
  66708. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66709. * @returns a new empty Vector3
  66710. */
  66711. static Zero(): Vector3;
  66712. /**
  66713. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66714. * @returns a new unit Vector3
  66715. */
  66716. static One(): Vector3;
  66717. /**
  66718. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66719. * @returns a new up Vector3
  66720. */
  66721. static Up(): Vector3;
  66722. /**
  66723. * Gets a up Vector3 that must not be updated
  66724. */
  66725. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66726. /**
  66727. * Gets a zero Vector3 that must not be updated
  66728. */
  66729. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66730. /**
  66731. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66732. * @returns a new down Vector3
  66733. */
  66734. static Down(): Vector3;
  66735. /**
  66736. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66737. * @returns a new forward Vector3
  66738. */
  66739. static Forward(): Vector3;
  66740. /**
  66741. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66742. * @returns a new forward Vector3
  66743. */
  66744. static Backward(): Vector3;
  66745. /**
  66746. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66747. * @returns a new right Vector3
  66748. */
  66749. static Right(): Vector3;
  66750. /**
  66751. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66752. * @returns a new left Vector3
  66753. */
  66754. static Left(): Vector3;
  66755. /**
  66756. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66758. * @param vector defines the Vector3 to transform
  66759. * @param transformation defines the transformation matrix
  66760. * @returns the transformed Vector3
  66761. */
  66762. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66763. /**
  66764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66765. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66766. * @param vector defines the Vector3 to transform
  66767. * @param transformation defines the transformation matrix
  66768. * @param result defines the Vector3 where to store the result
  66769. */
  66770. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66771. /**
  66772. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66773. * This method computes tranformed coordinates only, not transformed direction vectors
  66774. * @param x define the x coordinate of the source vector
  66775. * @param y define the y coordinate of the source vector
  66776. * @param z define the z coordinate of the source vector
  66777. * @param transformation defines the transformation matrix
  66778. * @param result defines the Vector3 where to store the result
  66779. */
  66780. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66781. /**
  66782. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66784. * @param vector defines the Vector3 to transform
  66785. * @param transformation defines the transformation matrix
  66786. * @returns the new Vector3
  66787. */
  66788. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66789. /**
  66790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66792. * @param vector defines the Vector3 to transform
  66793. * @param transformation defines the transformation matrix
  66794. * @param result defines the Vector3 where to store the result
  66795. */
  66796. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66797. /**
  66798. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66800. * @param x define the x coordinate of the source vector
  66801. * @param y define the y coordinate of the source vector
  66802. * @param z define the z coordinate of the source vector
  66803. * @param transformation defines the transformation matrix
  66804. * @param result defines the Vector3 where to store the result
  66805. */
  66806. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66807. /**
  66808. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66809. * @param value1 defines the first control point
  66810. * @param value2 defines the second control point
  66811. * @param value3 defines the third control point
  66812. * @param value4 defines the fourth control point
  66813. * @param amount defines the amount on the spline to use
  66814. * @returns the new Vector3
  66815. */
  66816. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66817. /**
  66818. * 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"
  66819. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66820. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66821. * @param value defines the current value
  66822. * @param min defines the lower range value
  66823. * @param max defines the upper range value
  66824. * @returns the new Vector3
  66825. */
  66826. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66827. /**
  66828. * 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"
  66829. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66830. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66831. * @param value defines the current value
  66832. * @param min defines the lower range value
  66833. * @param max defines the upper range value
  66834. * @param result defines the Vector3 where to store the result
  66835. */
  66836. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66837. /**
  66838. * Checks if a given vector is inside a specific range
  66839. * @param v defines the vector to test
  66840. * @param min defines the minimum range
  66841. * @param max defines the maximum range
  66842. */
  66843. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66844. /**
  66845. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66846. * @param value1 defines the first control point
  66847. * @param tangent1 defines the first tangent vector
  66848. * @param value2 defines the second control point
  66849. * @param tangent2 defines the second tangent vector
  66850. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66851. * @returns the new Vector3
  66852. */
  66853. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66854. /**
  66855. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66856. * @param start defines the start value
  66857. * @param end defines the end value
  66858. * @param amount max defines amount between both (between 0 and 1)
  66859. * @returns the new Vector3
  66860. */
  66861. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66862. /**
  66863. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66864. * @param start defines the start value
  66865. * @param end defines the end value
  66866. * @param amount max defines amount between both (between 0 and 1)
  66867. * @param result defines the Vector3 where to store the result
  66868. */
  66869. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66870. /**
  66871. * Returns the dot product (float) between the vectors "left" and "right"
  66872. * @param left defines the left operand
  66873. * @param right defines the right operand
  66874. * @returns the dot product
  66875. */
  66876. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66877. /**
  66878. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66879. * The cross product is then orthogonal to both "left" and "right"
  66880. * @param left defines the left operand
  66881. * @param right defines the right operand
  66882. * @returns the cross product
  66883. */
  66884. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66885. /**
  66886. * Sets the given vector "result" with the cross product of "left" and "right"
  66887. * The cross product is then orthogonal to both "left" and "right"
  66888. * @param left defines the left operand
  66889. * @param right defines the right operand
  66890. * @param result defines the Vector3 where to store the result
  66891. */
  66892. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66893. /**
  66894. * Returns a new Vector3 as the normalization of the given vector
  66895. * @param vector defines the Vector3 to normalize
  66896. * @returns the new Vector3
  66897. */
  66898. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66899. /**
  66900. * Sets the given vector "result" with the normalization of the given first vector
  66901. * @param vector defines the Vector3 to normalize
  66902. * @param result defines the Vector3 where to store the result
  66903. */
  66904. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66905. /**
  66906. * Project a Vector3 onto screen space
  66907. * @param vector defines the Vector3 to project
  66908. * @param world defines the world matrix to use
  66909. * @param transform defines the transform (view x projection) matrix to use
  66910. * @param viewport defines the screen viewport to use
  66911. * @returns the new Vector3
  66912. */
  66913. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66914. /** @hidden */
  66915. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66916. /**
  66917. * Unproject from screen space to object space
  66918. * @param source defines the screen space Vector3 to use
  66919. * @param viewportWidth defines the current width of the viewport
  66920. * @param viewportHeight defines the current height of the viewport
  66921. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66922. * @param transform defines the transform (view x projection) matrix to use
  66923. * @returns the new Vector3
  66924. */
  66925. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66926. /**
  66927. * Unproject from screen space to object space
  66928. * @param source defines the screen space Vector3 to use
  66929. * @param viewportWidth defines the current width of the viewport
  66930. * @param viewportHeight defines the current height of the viewport
  66931. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66932. * @param view defines the view matrix to use
  66933. * @param projection defines the projection matrix to use
  66934. * @returns the new Vector3
  66935. */
  66936. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66937. /**
  66938. * Unproject from screen space to object space
  66939. * @param source defines the screen space Vector3 to use
  66940. * @param viewportWidth defines the current width of the viewport
  66941. * @param viewportHeight defines the current height of the viewport
  66942. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66943. * @param view defines the view matrix to use
  66944. * @param projection defines the projection matrix to use
  66945. * @param result defines the Vector3 where to store the result
  66946. */
  66947. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66948. /**
  66949. * Unproject from screen space to object space
  66950. * @param sourceX defines the screen space x coordinate to use
  66951. * @param sourceY defines the screen space y coordinate to use
  66952. * @param sourceZ defines the screen space z coordinate to use
  66953. * @param viewportWidth defines the current width of the viewport
  66954. * @param viewportHeight defines the current height of the viewport
  66955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66956. * @param view defines the view matrix to use
  66957. * @param projection defines the projection matrix to use
  66958. * @param result defines the Vector3 where to store the result
  66959. */
  66960. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66961. /**
  66962. * Gets the minimal coordinate values between two Vector3
  66963. * @param left defines the first operand
  66964. * @param right defines the second operand
  66965. * @returns the new Vector3
  66966. */
  66967. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66968. /**
  66969. * Gets the maximal coordinate values between two Vector3
  66970. * @param left defines the first operand
  66971. * @param right defines the second operand
  66972. * @returns the new Vector3
  66973. */
  66974. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66975. /**
  66976. * Returns the distance between the vectors "value1" and "value2"
  66977. * @param value1 defines the first operand
  66978. * @param value2 defines the second operand
  66979. * @returns the distance
  66980. */
  66981. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66982. /**
  66983. * Returns the squared distance between the vectors "value1" and "value2"
  66984. * @param value1 defines the first operand
  66985. * @param value2 defines the second operand
  66986. * @returns the squared distance
  66987. */
  66988. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66989. /**
  66990. * Returns a new Vector3 located at the center between "value1" and "value2"
  66991. * @param value1 defines the first operand
  66992. * @param value2 defines the second operand
  66993. * @returns the new Vector3
  66994. */
  66995. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66996. /**
  66997. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66998. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66999. * to something in order to rotate it from its local system to the given target system
  67000. * Note: axis1, axis2 and axis3 are normalized during this operation
  67001. * @param axis1 defines the first axis
  67002. * @param axis2 defines the second axis
  67003. * @param axis3 defines the third axis
  67004. * @returns a new Vector3
  67005. */
  67006. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67007. /**
  67008. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67009. * @param axis1 defines the first axis
  67010. * @param axis2 defines the second axis
  67011. * @param axis3 defines the third axis
  67012. * @param ref defines the Vector3 where to store the result
  67013. */
  67014. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67015. }
  67016. /**
  67017. * Vector4 class created for EulerAngle class conversion to Quaternion
  67018. */
  67019. export class Vector4 {
  67020. /** x value of the vector */
  67021. x: number;
  67022. /** y value of the vector */
  67023. y: number;
  67024. /** z value of the vector */
  67025. z: number;
  67026. /** w value of the vector */
  67027. w: number;
  67028. /**
  67029. * Creates a Vector4 object from the given floats.
  67030. * @param x x value of the vector
  67031. * @param y y value of the vector
  67032. * @param z z value of the vector
  67033. * @param w w value of the vector
  67034. */
  67035. constructor(
  67036. /** x value of the vector */
  67037. x: number,
  67038. /** y value of the vector */
  67039. y: number,
  67040. /** z value of the vector */
  67041. z: number,
  67042. /** w value of the vector */
  67043. w: number);
  67044. /**
  67045. * Returns the string with the Vector4 coordinates.
  67046. * @returns a string containing all the vector values
  67047. */
  67048. toString(): string;
  67049. /**
  67050. * Returns the string "Vector4".
  67051. * @returns "Vector4"
  67052. */
  67053. getClassName(): string;
  67054. /**
  67055. * Returns the Vector4 hash code.
  67056. * @returns a unique hash code
  67057. */
  67058. getHashCode(): number;
  67059. /**
  67060. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67061. * @returns the resulting array
  67062. */
  67063. asArray(): number[];
  67064. /**
  67065. * Populates the given array from the given index with the Vector4 coordinates.
  67066. * @param array array to populate
  67067. * @param index index of the array to start at (default: 0)
  67068. * @returns the Vector4.
  67069. */
  67070. toArray(array: FloatArray, index?: number): Vector4;
  67071. /**
  67072. * Adds the given vector to the current Vector4.
  67073. * @param otherVector the vector to add
  67074. * @returns the updated Vector4.
  67075. */
  67076. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67077. /**
  67078. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67079. * @param otherVector the vector to add
  67080. * @returns the resulting vector
  67081. */
  67082. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67083. /**
  67084. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67085. * @param otherVector the vector to add
  67086. * @param result the vector to store the result
  67087. * @returns the current Vector4.
  67088. */
  67089. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67090. /**
  67091. * Subtract in place the given vector from the current Vector4.
  67092. * @param otherVector the vector to subtract
  67093. * @returns the updated Vector4.
  67094. */
  67095. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67096. /**
  67097. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67098. * @param otherVector the vector to add
  67099. * @returns the new vector with the result
  67100. */
  67101. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67102. /**
  67103. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67104. * @param otherVector the vector to subtract
  67105. * @param result the vector to store the result
  67106. * @returns the current Vector4.
  67107. */
  67108. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67109. /**
  67110. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67111. */
  67112. /**
  67113. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67114. * @param x value to subtract
  67115. * @param y value to subtract
  67116. * @param z value to subtract
  67117. * @param w value to subtract
  67118. * @returns new vector containing the result
  67119. */
  67120. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67121. /**
  67122. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67123. * @param x value to subtract
  67124. * @param y value to subtract
  67125. * @param z value to subtract
  67126. * @param w value to subtract
  67127. * @param result the vector to store the result in
  67128. * @returns the current Vector4.
  67129. */
  67130. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67131. /**
  67132. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67133. * @returns a new vector with the negated values
  67134. */
  67135. negate(): Vector4;
  67136. /**
  67137. * Multiplies the current Vector4 coordinates by scale (float).
  67138. * @param scale the number to scale with
  67139. * @returns the updated Vector4.
  67140. */
  67141. scaleInPlace(scale: number): Vector4;
  67142. /**
  67143. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67144. * @param scale the number to scale with
  67145. * @returns a new vector with the result
  67146. */
  67147. scale(scale: number): Vector4;
  67148. /**
  67149. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67150. * @param scale the number to scale with
  67151. * @param result a vector to store the result in
  67152. * @returns the current Vector4.
  67153. */
  67154. scaleToRef(scale: number, result: Vector4): Vector4;
  67155. /**
  67156. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67157. * @param scale defines the scale factor
  67158. * @param result defines the Vector4 object where to store the result
  67159. * @returns the unmodified current Vector4
  67160. */
  67161. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67162. /**
  67163. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67164. * @param otherVector the vector to compare against
  67165. * @returns true if they are equal
  67166. */
  67167. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67168. /**
  67169. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67170. * @param otherVector vector to compare against
  67171. * @param epsilon (Default: very small number)
  67172. * @returns true if they are equal
  67173. */
  67174. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67175. /**
  67176. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67177. * @param x x value to compare against
  67178. * @param y y value to compare against
  67179. * @param z z value to compare against
  67180. * @param w w value to compare against
  67181. * @returns true if equal
  67182. */
  67183. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67184. /**
  67185. * Multiplies in place the current Vector4 by the given one.
  67186. * @param otherVector vector to multiple with
  67187. * @returns the updated Vector4.
  67188. */
  67189. multiplyInPlace(otherVector: Vector4): Vector4;
  67190. /**
  67191. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67192. * @param otherVector vector to multiple with
  67193. * @returns resulting new vector
  67194. */
  67195. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67196. /**
  67197. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67198. * @param otherVector vector to multiple with
  67199. * @param result vector to store the result
  67200. * @returns the current Vector4.
  67201. */
  67202. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67203. /**
  67204. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67205. * @param x x value multiply with
  67206. * @param y y value multiply with
  67207. * @param z z value multiply with
  67208. * @param w w value multiply with
  67209. * @returns resulting new vector
  67210. */
  67211. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67212. /**
  67213. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67214. * @param otherVector vector to devide with
  67215. * @returns resulting new vector
  67216. */
  67217. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67218. /**
  67219. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67220. * @param otherVector vector to devide with
  67221. * @param result vector to store the result
  67222. * @returns the current Vector4.
  67223. */
  67224. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67225. /**
  67226. * Divides the current Vector3 coordinates by the given ones.
  67227. * @param otherVector vector to devide with
  67228. * @returns the updated Vector3.
  67229. */
  67230. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67231. /**
  67232. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67233. * @param other defines the second operand
  67234. * @returns the current updated Vector4
  67235. */
  67236. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67237. /**
  67238. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67239. * @param other defines the second operand
  67240. * @returns the current updated Vector4
  67241. */
  67242. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67243. /**
  67244. * Gets a new Vector4 from current Vector4 floored values
  67245. * @returns a new Vector4
  67246. */
  67247. floor(): Vector4;
  67248. /**
  67249. * Gets a new Vector4 from current Vector3 floored values
  67250. * @returns a new Vector4
  67251. */
  67252. fract(): Vector4;
  67253. /**
  67254. * Returns the Vector4 length (float).
  67255. * @returns the length
  67256. */
  67257. length(): number;
  67258. /**
  67259. * Returns the Vector4 squared length (float).
  67260. * @returns the length squared
  67261. */
  67262. lengthSquared(): number;
  67263. /**
  67264. * Normalizes in place the Vector4.
  67265. * @returns the updated Vector4.
  67266. */
  67267. normalize(): Vector4;
  67268. /**
  67269. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67270. * @returns this converted to a new vector3
  67271. */
  67272. toVector3(): Vector3;
  67273. /**
  67274. * Returns a new Vector4 copied from the current one.
  67275. * @returns the new cloned vector
  67276. */
  67277. clone(): Vector4;
  67278. /**
  67279. * Updates the current Vector4 with the given one coordinates.
  67280. * @param source the source vector to copy from
  67281. * @returns the updated Vector4.
  67282. */
  67283. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67284. /**
  67285. * Updates the current Vector4 coordinates with the given floats.
  67286. * @param x float to copy from
  67287. * @param y float to copy from
  67288. * @param z float to copy from
  67289. * @param w float to copy from
  67290. * @returns the updated Vector4.
  67291. */
  67292. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67293. /**
  67294. * Updates the current Vector4 coordinates with the given floats.
  67295. * @param x float to set from
  67296. * @param y float to set from
  67297. * @param z float to set from
  67298. * @param w float to set from
  67299. * @returns the updated Vector4.
  67300. */
  67301. set(x: number, y: number, z: number, w: number): Vector4;
  67302. /**
  67303. * Copies the given float to the current Vector3 coordinates
  67304. * @param v defines the x, y, z and w coordinates of the operand
  67305. * @returns the current updated Vector3
  67306. */
  67307. setAll(v: number): Vector4;
  67308. /**
  67309. * Returns a new Vector4 set from the starting index of the given array.
  67310. * @param array the array to pull values from
  67311. * @param offset the offset into the array to start at
  67312. * @returns the new vector
  67313. */
  67314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67315. /**
  67316. * Updates the given vector "result" from the starting index of the given array.
  67317. * @param array the array to pull values from
  67318. * @param offset the offset into the array to start at
  67319. * @param result the vector to store the result in
  67320. */
  67321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67322. /**
  67323. * Updates the given vector "result" from the starting index of the given Float32Array.
  67324. * @param array the array to pull values from
  67325. * @param offset the offset into the array to start at
  67326. * @param result the vector to store the result in
  67327. */
  67328. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67329. /**
  67330. * Updates the given vector "result" coordinates from the given floats.
  67331. * @param x float to set from
  67332. * @param y float to set from
  67333. * @param z float to set from
  67334. * @param w float to set from
  67335. * @param result the vector to the floats in
  67336. */
  67337. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67338. /**
  67339. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67340. * @returns the new vector
  67341. */
  67342. static Zero(): Vector4;
  67343. /**
  67344. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67345. * @returns the new vector
  67346. */
  67347. static One(): Vector4;
  67348. /**
  67349. * Returns a new normalized Vector4 from the given one.
  67350. * @param vector the vector to normalize
  67351. * @returns the vector
  67352. */
  67353. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67354. /**
  67355. * Updates the given vector "result" from the normalization of the given one.
  67356. * @param vector the vector to normalize
  67357. * @param result the vector to store the result in
  67358. */
  67359. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67360. /**
  67361. * Returns a vector with the minimum values from the left and right vectors
  67362. * @param left left vector to minimize
  67363. * @param right right vector to minimize
  67364. * @returns a new vector with the minimum of the left and right vector values
  67365. */
  67366. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67367. /**
  67368. * Returns a vector with the maximum values from the left and right vectors
  67369. * @param left left vector to maximize
  67370. * @param right right vector to maximize
  67371. * @returns a new vector with the maximum of the left and right vector values
  67372. */
  67373. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67374. /**
  67375. * Returns the distance (float) between the vectors "value1" and "value2".
  67376. * @param value1 value to calulate the distance between
  67377. * @param value2 value to calulate the distance between
  67378. * @return the distance between the two vectors
  67379. */
  67380. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67381. /**
  67382. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67383. * @param value1 value to calulate the distance between
  67384. * @param value2 value to calulate the distance between
  67385. * @return the distance between the two vectors squared
  67386. */
  67387. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67388. /**
  67389. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67390. * @param value1 value to calulate the center between
  67391. * @param value2 value to calulate the center between
  67392. * @return the center between the two vectors
  67393. */
  67394. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67395. /**
  67396. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67397. * This methods computes transformed normalized direction vectors only.
  67398. * @param vector the vector to transform
  67399. * @param transformation the transformation matrix to apply
  67400. * @returns the new vector
  67401. */
  67402. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67403. /**
  67404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67405. * This methods computes transformed normalized direction vectors only.
  67406. * @param vector the vector to transform
  67407. * @param transformation the transformation matrix to apply
  67408. * @param result the vector to store the result in
  67409. */
  67410. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67411. /**
  67412. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67413. * This methods computes transformed normalized direction vectors only.
  67414. * @param x value to transform
  67415. * @param y value to transform
  67416. * @param z value to transform
  67417. * @param w value to transform
  67418. * @param transformation the transformation matrix to apply
  67419. * @param result the vector to store the results in
  67420. */
  67421. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67422. /**
  67423. * Creates a new Vector4 from a Vector3
  67424. * @param source defines the source data
  67425. * @param w defines the 4th component (default is 0)
  67426. * @returns a new Vector4
  67427. */
  67428. static FromVector3(source: Vector3, w?: number): Vector4;
  67429. }
  67430. /**
  67431. * Class used to store quaternion data
  67432. * @see https://en.wikipedia.org/wiki/Quaternion
  67433. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67434. */
  67435. export class Quaternion {
  67436. /** defines the first component (0 by default) */
  67437. x: number;
  67438. /** defines the second component (0 by default) */
  67439. y: number;
  67440. /** defines the third component (0 by default) */
  67441. z: number;
  67442. /** defines the fourth component (1.0 by default) */
  67443. w: number;
  67444. /**
  67445. * Creates a new Quaternion from the given floats
  67446. * @param x defines the first component (0 by default)
  67447. * @param y defines the second component (0 by default)
  67448. * @param z defines the third component (0 by default)
  67449. * @param w defines the fourth component (1.0 by default)
  67450. */
  67451. constructor(
  67452. /** defines the first component (0 by default) */
  67453. x?: number,
  67454. /** defines the second component (0 by default) */
  67455. y?: number,
  67456. /** defines the third component (0 by default) */
  67457. z?: number,
  67458. /** defines the fourth component (1.0 by default) */
  67459. w?: number);
  67460. /**
  67461. * Gets a string representation for the current quaternion
  67462. * @returns a string with the Quaternion coordinates
  67463. */
  67464. toString(): string;
  67465. /**
  67466. * Gets the class name of the quaternion
  67467. * @returns the string "Quaternion"
  67468. */
  67469. getClassName(): string;
  67470. /**
  67471. * Gets a hash code for this quaternion
  67472. * @returns the quaternion hash code
  67473. */
  67474. getHashCode(): number;
  67475. /**
  67476. * Copy the quaternion to an array
  67477. * @returns a new array populated with 4 elements from the quaternion coordinates
  67478. */
  67479. asArray(): number[];
  67480. /**
  67481. * Check if two quaternions are equals
  67482. * @param otherQuaternion defines the second operand
  67483. * @return true if the current quaternion and the given one coordinates are strictly equals
  67484. */
  67485. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67486. /**
  67487. * Clone the current quaternion
  67488. * @returns a new quaternion copied from the current one
  67489. */
  67490. clone(): Quaternion;
  67491. /**
  67492. * Copy a quaternion to the current one
  67493. * @param other defines the other quaternion
  67494. * @returns the updated current quaternion
  67495. */
  67496. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67497. /**
  67498. * Updates the current quaternion with the given float coordinates
  67499. * @param x defines the x coordinate
  67500. * @param y defines the y coordinate
  67501. * @param z defines the z coordinate
  67502. * @param w defines the w coordinate
  67503. * @returns the updated current quaternion
  67504. */
  67505. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67506. /**
  67507. * Updates the current quaternion from the given float coordinates
  67508. * @param x defines the x coordinate
  67509. * @param y defines the y coordinate
  67510. * @param z defines the z coordinate
  67511. * @param w defines the w coordinate
  67512. * @returns the updated current quaternion
  67513. */
  67514. set(x: number, y: number, z: number, w: number): Quaternion;
  67515. /**
  67516. * Adds two quaternions
  67517. * @param other defines the second operand
  67518. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67519. */
  67520. add(other: DeepImmutable<Quaternion>): Quaternion;
  67521. /**
  67522. * Add a quaternion to the current one
  67523. * @param other defines the quaternion to add
  67524. * @returns the current quaternion
  67525. */
  67526. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67527. /**
  67528. * Subtract two quaternions
  67529. * @param other defines the second operand
  67530. * @returns a new quaternion as the subtraction result of the given one from the current one
  67531. */
  67532. subtract(other: Quaternion): Quaternion;
  67533. /**
  67534. * Multiplies the current quaternion by a scale factor
  67535. * @param value defines the scale factor
  67536. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67537. */
  67538. scale(value: number): Quaternion;
  67539. /**
  67540. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67541. * @param scale defines the scale factor
  67542. * @param result defines the Quaternion object where to store the result
  67543. * @returns the unmodified current quaternion
  67544. */
  67545. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67546. /**
  67547. * Multiplies in place the current quaternion by a scale factor
  67548. * @param value defines the scale factor
  67549. * @returns the current modified quaternion
  67550. */
  67551. scaleInPlace(value: number): Quaternion;
  67552. /**
  67553. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67554. * @param scale defines the scale factor
  67555. * @param result defines the Quaternion object where to store the result
  67556. * @returns the unmodified current quaternion
  67557. */
  67558. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67559. /**
  67560. * Multiplies two quaternions
  67561. * @param q1 defines the second operand
  67562. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67563. */
  67564. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67565. /**
  67566. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67567. * @param q1 defines the second operand
  67568. * @param result defines the target quaternion
  67569. * @returns the current quaternion
  67570. */
  67571. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67572. /**
  67573. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67574. * @param q1 defines the second operand
  67575. * @returns the currentupdated quaternion
  67576. */
  67577. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67578. /**
  67579. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67580. * @param ref defines the target quaternion
  67581. * @returns the current quaternion
  67582. */
  67583. conjugateToRef(ref: Quaternion): Quaternion;
  67584. /**
  67585. * Conjugates in place (1-q) the current quaternion
  67586. * @returns the current updated quaternion
  67587. */
  67588. conjugateInPlace(): Quaternion;
  67589. /**
  67590. * Conjugates in place (1-q) the current quaternion
  67591. * @returns a new quaternion
  67592. */
  67593. conjugate(): Quaternion;
  67594. /**
  67595. * Gets length of current quaternion
  67596. * @returns the quaternion length (float)
  67597. */
  67598. length(): number;
  67599. /**
  67600. * Normalize in place the current quaternion
  67601. * @returns the current updated quaternion
  67602. */
  67603. normalize(): Quaternion;
  67604. /**
  67605. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67606. * @param order is a reserved parameter and is ignore for now
  67607. * @returns a new Vector3 containing the Euler angles
  67608. */
  67609. toEulerAngles(order?: string): Vector3;
  67610. /**
  67611. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67612. * @param result defines the vector which will be filled with the Euler angles
  67613. * @param order is a reserved parameter and is ignore for now
  67614. * @returns the current unchanged quaternion
  67615. */
  67616. toEulerAnglesToRef(result: Vector3): Quaternion;
  67617. /**
  67618. * Updates the given rotation matrix with the current quaternion values
  67619. * @param result defines the target matrix
  67620. * @returns the current unchanged quaternion
  67621. */
  67622. toRotationMatrix(result: Matrix): Quaternion;
  67623. /**
  67624. * Updates the current quaternion from the given rotation matrix values
  67625. * @param matrix defines the source matrix
  67626. * @returns the current updated quaternion
  67627. */
  67628. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67629. /**
  67630. * Creates a new quaternion from a rotation matrix
  67631. * @param matrix defines the source matrix
  67632. * @returns a new quaternion created from the given rotation matrix values
  67633. */
  67634. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67635. /**
  67636. * Updates the given quaternion with the given rotation matrix values
  67637. * @param matrix defines the source matrix
  67638. * @param result defines the target quaternion
  67639. */
  67640. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67641. /**
  67642. * Returns the dot product (float) between the quaternions "left" and "right"
  67643. * @param left defines the left operand
  67644. * @param right defines the right operand
  67645. * @returns the dot product
  67646. */
  67647. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67648. /**
  67649. * Checks if the two quaternions are close to each other
  67650. * @param quat0 defines the first quaternion to check
  67651. * @param quat1 defines the second quaternion to check
  67652. * @returns true if the two quaternions are close to each other
  67653. */
  67654. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67655. /**
  67656. * Creates an empty quaternion
  67657. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67658. */
  67659. static Zero(): Quaternion;
  67660. /**
  67661. * Inverse a given quaternion
  67662. * @param q defines the source quaternion
  67663. * @returns a new quaternion as the inverted current quaternion
  67664. */
  67665. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67666. /**
  67667. * Inverse a given quaternion
  67668. * @param q defines the source quaternion
  67669. * @param result the quaternion the result will be stored in
  67670. * @returns the result quaternion
  67671. */
  67672. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67673. /**
  67674. * Creates an identity quaternion
  67675. * @returns the identity quaternion
  67676. */
  67677. static Identity(): Quaternion;
  67678. /**
  67679. * Gets a boolean indicating if the given quaternion is identity
  67680. * @param quaternion defines the quaternion to check
  67681. * @returns true if the quaternion is identity
  67682. */
  67683. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67684. /**
  67685. * Creates a quaternion from a rotation around an axis
  67686. * @param axis defines the axis to use
  67687. * @param angle defines the angle to use
  67688. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67689. */
  67690. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67691. /**
  67692. * Creates a rotation around an axis and stores it into the given quaternion
  67693. * @param axis defines the axis to use
  67694. * @param angle defines the angle to use
  67695. * @param result defines the target quaternion
  67696. * @returns the target quaternion
  67697. */
  67698. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67699. /**
  67700. * Creates a new quaternion from data stored into an array
  67701. * @param array defines the data source
  67702. * @param offset defines the offset in the source array where the data starts
  67703. * @returns a new quaternion
  67704. */
  67705. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67706. /**
  67707. * Create a quaternion from Euler rotation angles
  67708. * @param x Pitch
  67709. * @param y Yaw
  67710. * @param z Roll
  67711. * @returns the new Quaternion
  67712. */
  67713. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67714. /**
  67715. * Updates a quaternion from Euler rotation angles
  67716. * @param x Pitch
  67717. * @param y Yaw
  67718. * @param z Roll
  67719. * @param result the quaternion to store the result
  67720. * @returns the updated quaternion
  67721. */
  67722. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67723. /**
  67724. * Create a quaternion from Euler rotation vector
  67725. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67726. * @returns the new Quaternion
  67727. */
  67728. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67729. /**
  67730. * Updates a quaternion from Euler rotation vector
  67731. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67732. * @param result the quaternion to store the result
  67733. * @returns the updated quaternion
  67734. */
  67735. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67736. /**
  67737. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67738. * @param yaw defines the rotation around Y axis
  67739. * @param pitch defines the rotation around X axis
  67740. * @param roll defines the rotation around Z axis
  67741. * @returns the new quaternion
  67742. */
  67743. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67744. /**
  67745. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67746. * @param yaw defines the rotation around Y axis
  67747. * @param pitch defines the rotation around X axis
  67748. * @param roll defines the rotation around Z axis
  67749. * @param result defines the target quaternion
  67750. */
  67751. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67752. /**
  67753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67754. * @param alpha defines the rotation around first axis
  67755. * @param beta defines the rotation around second axis
  67756. * @param gamma defines the rotation around third axis
  67757. * @returns the new quaternion
  67758. */
  67759. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67760. /**
  67761. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67762. * @param alpha defines the rotation around first axis
  67763. * @param beta defines the rotation around second axis
  67764. * @param gamma defines the rotation around third axis
  67765. * @param result defines the target quaternion
  67766. */
  67767. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67768. /**
  67769. * 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)
  67770. * @param axis1 defines the first axis
  67771. * @param axis2 defines the second axis
  67772. * @param axis3 defines the third axis
  67773. * @returns the new quaternion
  67774. */
  67775. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67776. /**
  67777. * 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
  67778. * @param axis1 defines the first axis
  67779. * @param axis2 defines the second axis
  67780. * @param axis3 defines the third axis
  67781. * @param ref defines the target quaternion
  67782. */
  67783. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67784. /**
  67785. * Interpolates between two quaternions
  67786. * @param left defines first quaternion
  67787. * @param right defines second quaternion
  67788. * @param amount defines the gradient to use
  67789. * @returns the new interpolated quaternion
  67790. */
  67791. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67792. /**
  67793. * Interpolates between two quaternions and stores it into a target quaternion
  67794. * @param left defines first quaternion
  67795. * @param right defines second quaternion
  67796. * @param amount defines the gradient to use
  67797. * @param result defines the target quaternion
  67798. */
  67799. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67800. /**
  67801. * Interpolate between two quaternions using Hermite interpolation
  67802. * @param value1 defines first quaternion
  67803. * @param tangent1 defines the incoming tangent
  67804. * @param value2 defines second quaternion
  67805. * @param tangent2 defines the outgoing tangent
  67806. * @param amount defines the target quaternion
  67807. * @returns the new interpolated quaternion
  67808. */
  67809. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67810. }
  67811. /**
  67812. * Class used to store matrix data (4x4)
  67813. */
  67814. export class Matrix {
  67815. private static _updateFlagSeed;
  67816. private static _identityReadOnly;
  67817. private _isIdentity;
  67818. private _isIdentityDirty;
  67819. private _isIdentity3x2;
  67820. private _isIdentity3x2Dirty;
  67821. /**
  67822. * Gets the update flag of the matrix which is an unique number for the matrix.
  67823. * It will be incremented every time the matrix data change.
  67824. * You can use it to speed the comparison between two versions of the same matrix.
  67825. */
  67826. updateFlag: number;
  67827. private readonly _m;
  67828. /**
  67829. * Gets the internal data of the matrix
  67830. */
  67831. readonly m: DeepImmutable<Float32Array>;
  67832. /** @hidden */
  67833. _markAsUpdated(): void;
  67834. /** @hidden */
  67835. private _updateIdentityStatus;
  67836. /**
  67837. * Creates an empty matrix (filled with zeros)
  67838. */
  67839. constructor();
  67840. /**
  67841. * Check if the current matrix is identity
  67842. * @returns true is the matrix is the identity matrix
  67843. */
  67844. isIdentity(): boolean;
  67845. /**
  67846. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67847. * @returns true is the matrix is the identity matrix
  67848. */
  67849. isIdentityAs3x2(): boolean;
  67850. /**
  67851. * Gets the determinant of the matrix
  67852. * @returns the matrix determinant
  67853. */
  67854. determinant(): number;
  67855. /**
  67856. * Returns the matrix as a Float32Array
  67857. * @returns the matrix underlying array
  67858. */
  67859. toArray(): DeepImmutable<Float32Array>;
  67860. /**
  67861. * Returns the matrix as a Float32Array
  67862. * @returns the matrix underlying array.
  67863. */
  67864. asArray(): DeepImmutable<Float32Array>;
  67865. /**
  67866. * Inverts the current matrix in place
  67867. * @returns the current inverted matrix
  67868. */
  67869. invert(): Matrix;
  67870. /**
  67871. * Sets all the matrix elements to zero
  67872. * @returns the current matrix
  67873. */
  67874. reset(): Matrix;
  67875. /**
  67876. * Adds the current matrix with a second one
  67877. * @param other defines the matrix to add
  67878. * @returns a new matrix as the addition of the current matrix and the given one
  67879. */
  67880. add(other: DeepImmutable<Matrix>): Matrix;
  67881. /**
  67882. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67883. * @param other defines the matrix to add
  67884. * @param result defines the target matrix
  67885. * @returns the current matrix
  67886. */
  67887. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67888. /**
  67889. * Adds in place the given matrix to the current matrix
  67890. * @param other defines the second operand
  67891. * @returns the current updated matrix
  67892. */
  67893. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67894. /**
  67895. * Sets the given matrix to the current inverted Matrix
  67896. * @param other defines the target matrix
  67897. * @returns the unmodified current matrix
  67898. */
  67899. invertToRef(other: Matrix): Matrix;
  67900. /**
  67901. * add a value at the specified position in the current Matrix
  67902. * @param index the index of the value within the matrix. between 0 and 15.
  67903. * @param value the value to be added
  67904. * @returns the current updated matrix
  67905. */
  67906. addAtIndex(index: number, value: number): Matrix;
  67907. /**
  67908. * mutiply the specified position in the current Matrix by a value
  67909. * @param index the index of the value within the matrix. between 0 and 15.
  67910. * @param value the value to be added
  67911. * @returns the current updated matrix
  67912. */
  67913. multiplyAtIndex(index: number, value: number): Matrix;
  67914. /**
  67915. * Inserts the translation vector (using 3 floats) in the current matrix
  67916. * @param x defines the 1st component of the translation
  67917. * @param y defines the 2nd component of the translation
  67918. * @param z defines the 3rd component of the translation
  67919. * @returns the current updated matrix
  67920. */
  67921. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67922. /**
  67923. * Adds the translation vector (using 3 floats) in the current matrix
  67924. * @param x defines the 1st component of the translation
  67925. * @param y defines the 2nd component of the translation
  67926. * @param z defines the 3rd component of the translation
  67927. * @returns the current updated matrix
  67928. */
  67929. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67930. /**
  67931. * Inserts the translation vector in the current matrix
  67932. * @param vector3 defines the translation to insert
  67933. * @returns the current updated matrix
  67934. */
  67935. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67936. /**
  67937. * Gets the translation value of the current matrix
  67938. * @returns a new Vector3 as the extracted translation from the matrix
  67939. */
  67940. getTranslation(): Vector3;
  67941. /**
  67942. * Fill a Vector3 with the extracted translation from the matrix
  67943. * @param result defines the Vector3 where to store the translation
  67944. * @returns the current matrix
  67945. */
  67946. getTranslationToRef(result: Vector3): Matrix;
  67947. /**
  67948. * Remove rotation and scaling part from the matrix
  67949. * @returns the updated matrix
  67950. */
  67951. removeRotationAndScaling(): Matrix;
  67952. /**
  67953. * Multiply two matrices
  67954. * @param other defines the second operand
  67955. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67956. */
  67957. multiply(other: DeepImmutable<Matrix>): Matrix;
  67958. /**
  67959. * Copy the current matrix from the given one
  67960. * @param other defines the source matrix
  67961. * @returns the current updated matrix
  67962. */
  67963. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67964. /**
  67965. * Populates the given array from the starting index with the current matrix values
  67966. * @param array defines the target array
  67967. * @param offset defines the offset in the target array where to start storing values
  67968. * @returns the current matrix
  67969. */
  67970. copyToArray(array: Float32Array, offset?: number): Matrix;
  67971. /**
  67972. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67973. * @param other defines the second operand
  67974. * @param result defines the matrix where to store the multiplication
  67975. * @returns the current matrix
  67976. */
  67977. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67978. /**
  67979. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67980. * @param other defines the second operand
  67981. * @param result defines the array where to store the multiplication
  67982. * @param offset defines the offset in the target array where to start storing values
  67983. * @returns the current matrix
  67984. */
  67985. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67986. /**
  67987. * Check equality between this matrix and a second one
  67988. * @param value defines the second matrix to compare
  67989. * @returns true is the current matrix and the given one values are strictly equal
  67990. */
  67991. equals(value: DeepImmutable<Matrix>): boolean;
  67992. /**
  67993. * Clone the current matrix
  67994. * @returns a new matrix from the current matrix
  67995. */
  67996. clone(): Matrix;
  67997. /**
  67998. * Returns the name of the current matrix class
  67999. * @returns the string "Matrix"
  68000. */
  68001. getClassName(): string;
  68002. /**
  68003. * Gets the hash code of the current matrix
  68004. * @returns the hash code
  68005. */
  68006. getHashCode(): number;
  68007. /**
  68008. * Decomposes the current Matrix into a translation, rotation and scaling components
  68009. * @param scale defines the scale vector3 given as a reference to update
  68010. * @param rotation defines the rotation quaternion given as a reference to update
  68011. * @param translation defines the translation vector3 given as a reference to update
  68012. * @returns true if operation was successful
  68013. */
  68014. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68015. /**
  68016. * Gets specific row of the matrix
  68017. * @param index defines the number of the row to get
  68018. * @returns the index-th row of the current matrix as a new Vector4
  68019. */
  68020. getRow(index: number): Nullable<Vector4>;
  68021. /**
  68022. * Sets the index-th row of the current matrix to the vector4 values
  68023. * @param index defines the number of the row to set
  68024. * @param row defines the target vector4
  68025. * @returns the updated current matrix
  68026. */
  68027. setRow(index: number, row: Vector4): Matrix;
  68028. /**
  68029. * Compute the transpose of the matrix
  68030. * @returns the new transposed matrix
  68031. */
  68032. transpose(): Matrix;
  68033. /**
  68034. * Compute the transpose of the matrix and store it in a given matrix
  68035. * @param result defines the target matrix
  68036. * @returns the current matrix
  68037. */
  68038. transposeToRef(result: Matrix): Matrix;
  68039. /**
  68040. * Sets the index-th row of the current matrix with the given 4 x float values
  68041. * @param index defines the row index
  68042. * @param x defines the x component to set
  68043. * @param y defines the y component to set
  68044. * @param z defines the z component to set
  68045. * @param w defines the w component to set
  68046. * @returns the updated current matrix
  68047. */
  68048. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68049. /**
  68050. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68051. * @param scale defines the scale factor
  68052. * @returns a new matrix
  68053. */
  68054. scale(scale: number): Matrix;
  68055. /**
  68056. * Scale the current matrix values by a factor to a given result matrix
  68057. * @param scale defines the scale factor
  68058. * @param result defines the matrix to store the result
  68059. * @returns the current matrix
  68060. */
  68061. scaleToRef(scale: number, result: Matrix): Matrix;
  68062. /**
  68063. * Scale the current matrix values by a factor and add the result to a given matrix
  68064. * @param scale defines the scale factor
  68065. * @param result defines the Matrix to store the result
  68066. * @returns the current matrix
  68067. */
  68068. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68069. /**
  68070. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68071. * @param ref matrix to store the result
  68072. */
  68073. toNormalMatrix(ref: Matrix): void;
  68074. /**
  68075. * Gets only rotation part of the current matrix
  68076. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68077. */
  68078. getRotationMatrix(): Matrix;
  68079. /**
  68080. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68081. * @param result defines the target matrix to store data to
  68082. * @returns the current matrix
  68083. */
  68084. getRotationMatrixToRef(result: Matrix): Matrix;
  68085. /**
  68086. * Toggles model matrix from being right handed to left handed in place and vice versa
  68087. */
  68088. toggleModelMatrixHandInPlace(): void;
  68089. /**
  68090. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68091. */
  68092. toggleProjectionMatrixHandInPlace(): void;
  68093. /**
  68094. * Creates a matrix from an array
  68095. * @param array defines the source array
  68096. * @param offset defines an offset in the source array
  68097. * @returns a new Matrix set from the starting index of the given array
  68098. */
  68099. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68100. /**
  68101. * Copy the content of an array into a given matrix
  68102. * @param array defines the source array
  68103. * @param offset defines an offset in the source array
  68104. * @param result defines the target matrix
  68105. */
  68106. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68107. /**
  68108. * Stores an array into a matrix after having multiplied each component by a given factor
  68109. * @param array defines the source array
  68110. * @param offset defines the offset in the source array
  68111. * @param scale defines the scaling factor
  68112. * @param result defines the target matrix
  68113. */
  68114. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68115. /**
  68116. * Gets an identity matrix that must not be updated
  68117. */
  68118. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68119. /**
  68120. * Stores a list of values (16) inside a given matrix
  68121. * @param initialM11 defines 1st value of 1st row
  68122. * @param initialM12 defines 2nd value of 1st row
  68123. * @param initialM13 defines 3rd value of 1st row
  68124. * @param initialM14 defines 4th value of 1st row
  68125. * @param initialM21 defines 1st value of 2nd row
  68126. * @param initialM22 defines 2nd value of 2nd row
  68127. * @param initialM23 defines 3rd value of 2nd row
  68128. * @param initialM24 defines 4th value of 2nd row
  68129. * @param initialM31 defines 1st value of 3rd row
  68130. * @param initialM32 defines 2nd value of 3rd row
  68131. * @param initialM33 defines 3rd value of 3rd row
  68132. * @param initialM34 defines 4th value of 3rd row
  68133. * @param initialM41 defines 1st value of 4th row
  68134. * @param initialM42 defines 2nd value of 4th row
  68135. * @param initialM43 defines 3rd value of 4th row
  68136. * @param initialM44 defines 4th value of 4th row
  68137. * @param result defines the target matrix
  68138. */
  68139. 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;
  68140. /**
  68141. * Creates new matrix from a list of values (16)
  68142. * @param initialM11 defines 1st value of 1st row
  68143. * @param initialM12 defines 2nd value of 1st row
  68144. * @param initialM13 defines 3rd value of 1st row
  68145. * @param initialM14 defines 4th value of 1st row
  68146. * @param initialM21 defines 1st value of 2nd row
  68147. * @param initialM22 defines 2nd value of 2nd row
  68148. * @param initialM23 defines 3rd value of 2nd row
  68149. * @param initialM24 defines 4th value of 2nd row
  68150. * @param initialM31 defines 1st value of 3rd row
  68151. * @param initialM32 defines 2nd value of 3rd row
  68152. * @param initialM33 defines 3rd value of 3rd row
  68153. * @param initialM34 defines 4th value of 3rd row
  68154. * @param initialM41 defines 1st value of 4th row
  68155. * @param initialM42 defines 2nd value of 4th row
  68156. * @param initialM43 defines 3rd value of 4th row
  68157. * @param initialM44 defines 4th value of 4th row
  68158. * @returns the new matrix
  68159. */
  68160. 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;
  68161. /**
  68162. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68163. * @param scale defines the scale vector3
  68164. * @param rotation defines the rotation quaternion
  68165. * @param translation defines the translation vector3
  68166. * @returns a new matrix
  68167. */
  68168. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68169. /**
  68170. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68171. * @param scale defines the scale vector3
  68172. * @param rotation defines the rotation quaternion
  68173. * @param translation defines the translation vector3
  68174. * @param result defines the target matrix
  68175. */
  68176. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68177. /**
  68178. * Creates a new identity matrix
  68179. * @returns a new identity matrix
  68180. */
  68181. static Identity(): Matrix;
  68182. /**
  68183. * Creates a new identity matrix and stores the result in a given matrix
  68184. * @param result defines the target matrix
  68185. */
  68186. static IdentityToRef(result: Matrix): void;
  68187. /**
  68188. * Creates a new zero matrix
  68189. * @returns a new zero matrix
  68190. */
  68191. static Zero(): Matrix;
  68192. /**
  68193. * Creates a new rotation matrix for "angle" radians around the X axis
  68194. * @param angle defines the angle (in radians) to use
  68195. * @return the new matrix
  68196. */
  68197. static RotationX(angle: number): Matrix;
  68198. /**
  68199. * Creates a new matrix as the invert of a given matrix
  68200. * @param source defines the source matrix
  68201. * @returns the new matrix
  68202. */
  68203. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68204. /**
  68205. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68206. * @param angle defines the angle (in radians) to use
  68207. * @param result defines the target matrix
  68208. */
  68209. static RotationXToRef(angle: number, result: Matrix): void;
  68210. /**
  68211. * Creates a new rotation matrix for "angle" radians around the Y axis
  68212. * @param angle defines the angle (in radians) to use
  68213. * @return the new matrix
  68214. */
  68215. static RotationY(angle: number): Matrix;
  68216. /**
  68217. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68218. * @param angle defines the angle (in radians) to use
  68219. * @param result defines the target matrix
  68220. */
  68221. static RotationYToRef(angle: number, result: Matrix): void;
  68222. /**
  68223. * Creates a new rotation matrix for "angle" radians around the Z axis
  68224. * @param angle defines the angle (in radians) to use
  68225. * @return the new matrix
  68226. */
  68227. static RotationZ(angle: number): Matrix;
  68228. /**
  68229. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68230. * @param angle defines the angle (in radians) to use
  68231. * @param result defines the target matrix
  68232. */
  68233. static RotationZToRef(angle: number, result: Matrix): void;
  68234. /**
  68235. * Creates a new rotation matrix for "angle" radians around the given axis
  68236. * @param axis defines the axis to use
  68237. * @param angle defines the angle (in radians) to use
  68238. * @return the new matrix
  68239. */
  68240. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68241. /**
  68242. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68243. * @param axis defines the axis to use
  68244. * @param angle defines the angle (in radians) to use
  68245. * @param result defines the target matrix
  68246. */
  68247. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68248. /**
  68249. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68250. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68251. * @param from defines the vector to align
  68252. * @param to defines the vector to align to
  68253. * @param result defines the target matrix
  68254. */
  68255. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68256. /**
  68257. * Creates a rotation matrix
  68258. * @param yaw defines the yaw angle in radians (Y axis)
  68259. * @param pitch defines the pitch angle in radians (X axis)
  68260. * @param roll defines the roll angle in radians (X axis)
  68261. * @returns the new rotation matrix
  68262. */
  68263. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68264. /**
  68265. * Creates a rotation matrix and stores it in a given matrix
  68266. * @param yaw defines the yaw angle in radians (Y axis)
  68267. * @param pitch defines the pitch angle in radians (X axis)
  68268. * @param roll defines the roll angle in radians (X axis)
  68269. * @param result defines the target matrix
  68270. */
  68271. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68272. /**
  68273. * Creates a scaling matrix
  68274. * @param x defines the scale factor on X axis
  68275. * @param y defines the scale factor on Y axis
  68276. * @param z defines the scale factor on Z axis
  68277. * @returns the new matrix
  68278. */
  68279. static Scaling(x: number, y: number, z: number): Matrix;
  68280. /**
  68281. * Creates a scaling matrix and stores it in a given matrix
  68282. * @param x defines the scale factor on X axis
  68283. * @param y defines the scale factor on Y axis
  68284. * @param z defines the scale factor on Z axis
  68285. * @param result defines the target matrix
  68286. */
  68287. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68288. /**
  68289. * Creates a translation matrix
  68290. * @param x defines the translation on X axis
  68291. * @param y defines the translation on Y axis
  68292. * @param z defines the translationon Z axis
  68293. * @returns the new matrix
  68294. */
  68295. static Translation(x: number, y: number, z: number): Matrix;
  68296. /**
  68297. * Creates a translation matrix and stores it in a given matrix
  68298. * @param x defines the translation on X axis
  68299. * @param y defines the translation on Y axis
  68300. * @param z defines the translationon Z axis
  68301. * @param result defines the target matrix
  68302. */
  68303. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68304. /**
  68305. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68306. * @param startValue defines the start value
  68307. * @param endValue defines the end value
  68308. * @param gradient defines the gradient factor
  68309. * @returns the new matrix
  68310. */
  68311. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68312. /**
  68313. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68314. * @param startValue defines the start value
  68315. * @param endValue defines the end value
  68316. * @param gradient defines the gradient factor
  68317. * @param result defines the Matrix object where to store data
  68318. */
  68319. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68320. /**
  68321. * Builds a new matrix whose values are computed by:
  68322. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68323. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68324. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68325. * @param startValue defines the first matrix
  68326. * @param endValue defines the second matrix
  68327. * @param gradient defines the gradient between the two matrices
  68328. * @returns the new matrix
  68329. */
  68330. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68331. /**
  68332. * Update a matrix to values which are computed by:
  68333. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68334. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68335. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68336. * @param startValue defines the first matrix
  68337. * @param endValue defines the second matrix
  68338. * @param gradient defines the gradient between the two matrices
  68339. * @param result defines the target matrix
  68340. */
  68341. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68342. /**
  68343. * 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"
  68344. * This function works in left handed mode
  68345. * @param eye defines the final position of the entity
  68346. * @param target defines where the entity should look at
  68347. * @param up defines the up vector for the entity
  68348. * @returns the new matrix
  68349. */
  68350. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68351. /**
  68352. * 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".
  68353. * This function works in left handed mode
  68354. * @param eye defines the final position of the entity
  68355. * @param target defines where the entity should look at
  68356. * @param up defines the up vector for the entity
  68357. * @param result defines the target matrix
  68358. */
  68359. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68360. /**
  68361. * 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"
  68362. * This function works in right handed mode
  68363. * @param eye defines the final position of the entity
  68364. * @param target defines where the entity should look at
  68365. * @param up defines the up vector for the entity
  68366. * @returns the new matrix
  68367. */
  68368. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68369. /**
  68370. * 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".
  68371. * This function works in right handed mode
  68372. * @param eye defines the final position of the entity
  68373. * @param target defines where the entity should look at
  68374. * @param up defines the up vector for the entity
  68375. * @param result defines the target matrix
  68376. */
  68377. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68378. /**
  68379. * Create a left-handed orthographic projection matrix
  68380. * @param width defines the viewport width
  68381. * @param height defines the viewport height
  68382. * @param znear defines the near clip plane
  68383. * @param zfar defines the far clip plane
  68384. * @returns a new matrix as a left-handed orthographic projection matrix
  68385. */
  68386. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68387. /**
  68388. * Store a left-handed orthographic projection to a given matrix
  68389. * @param width defines the viewport width
  68390. * @param height defines the viewport height
  68391. * @param znear defines the near clip plane
  68392. * @param zfar defines the far clip plane
  68393. * @param result defines the target matrix
  68394. */
  68395. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68396. /**
  68397. * Create a left-handed orthographic projection matrix
  68398. * @param left defines the viewport left coordinate
  68399. * @param right defines the viewport right coordinate
  68400. * @param bottom defines the viewport bottom coordinate
  68401. * @param top defines the viewport top coordinate
  68402. * @param znear defines the near clip plane
  68403. * @param zfar defines the far clip plane
  68404. * @returns a new matrix as a left-handed orthographic projection matrix
  68405. */
  68406. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68407. /**
  68408. * Stores a left-handed orthographic projection into a given matrix
  68409. * @param left defines the viewport left coordinate
  68410. * @param right defines the viewport right coordinate
  68411. * @param bottom defines the viewport bottom coordinate
  68412. * @param top defines the viewport top coordinate
  68413. * @param znear defines the near clip plane
  68414. * @param zfar defines the far clip plane
  68415. * @param result defines the target matrix
  68416. */
  68417. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68418. /**
  68419. * Creates a right-handed orthographic projection matrix
  68420. * @param left defines the viewport left coordinate
  68421. * @param right defines the viewport right coordinate
  68422. * @param bottom defines the viewport bottom coordinate
  68423. * @param top defines the viewport top coordinate
  68424. * @param znear defines the near clip plane
  68425. * @param zfar defines the far clip plane
  68426. * @returns a new matrix as a right-handed orthographic projection matrix
  68427. */
  68428. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68429. /**
  68430. * Stores a right-handed orthographic projection into a given matrix
  68431. * @param left defines the viewport left coordinate
  68432. * @param right defines the viewport right coordinate
  68433. * @param bottom defines the viewport bottom coordinate
  68434. * @param top defines the viewport top coordinate
  68435. * @param znear defines the near clip plane
  68436. * @param zfar defines the far clip plane
  68437. * @param result defines the target matrix
  68438. */
  68439. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68440. /**
  68441. * Creates a left-handed perspective projection matrix
  68442. * @param width defines the viewport width
  68443. * @param height defines the viewport height
  68444. * @param znear defines the near clip plane
  68445. * @param zfar defines the far clip plane
  68446. * @returns a new matrix as a left-handed perspective projection matrix
  68447. */
  68448. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68449. /**
  68450. * Creates a left-handed perspective projection matrix
  68451. * @param fov defines the horizontal field of view
  68452. * @param aspect defines the aspect ratio
  68453. * @param znear defines the near clip plane
  68454. * @param zfar defines the far clip plane
  68455. * @returns a new matrix as a left-handed perspective projection matrix
  68456. */
  68457. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68458. /**
  68459. * Stores a left-handed perspective projection into a given matrix
  68460. * @param fov defines the horizontal field of view
  68461. * @param aspect defines the aspect ratio
  68462. * @param znear defines the near clip plane
  68463. * @param zfar defines the far clip plane
  68464. * @param result defines the target matrix
  68465. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68466. */
  68467. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68468. /**
  68469. * Creates a right-handed perspective projection matrix
  68470. * @param fov defines the horizontal field of view
  68471. * @param aspect defines the aspect ratio
  68472. * @param znear defines the near clip plane
  68473. * @param zfar defines the far clip plane
  68474. * @returns a new matrix as a right-handed perspective projection matrix
  68475. */
  68476. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68477. /**
  68478. * Stores a right-handed perspective projection into a given matrix
  68479. * @param fov defines the horizontal field of view
  68480. * @param aspect defines the aspect ratio
  68481. * @param znear defines the near clip plane
  68482. * @param zfar defines the far clip plane
  68483. * @param result defines the target matrix
  68484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68485. */
  68486. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68487. /**
  68488. * Stores a perspective projection for WebVR info a given matrix
  68489. * @param fov defines the field of view
  68490. * @param znear defines the near clip plane
  68491. * @param zfar defines the far clip plane
  68492. * @param result defines the target matrix
  68493. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68494. */
  68495. static PerspectiveFovWebVRToRef(fov: {
  68496. upDegrees: number;
  68497. downDegrees: number;
  68498. leftDegrees: number;
  68499. rightDegrees: number;
  68500. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68501. /**
  68502. * Computes a complete transformation matrix
  68503. * @param viewport defines the viewport to use
  68504. * @param world defines the world matrix
  68505. * @param view defines the view matrix
  68506. * @param projection defines the projection matrix
  68507. * @param zmin defines the near clip plane
  68508. * @param zmax defines the far clip plane
  68509. * @returns the transformation matrix
  68510. */
  68511. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68512. /**
  68513. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68514. * @param matrix defines the matrix to use
  68515. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68516. */
  68517. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68518. /**
  68519. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68520. * @param matrix defines the matrix to use
  68521. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68522. */
  68523. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68524. /**
  68525. * Compute the transpose of a given matrix
  68526. * @param matrix defines the matrix to transpose
  68527. * @returns the new matrix
  68528. */
  68529. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68530. /**
  68531. * Compute the transpose of a matrix and store it in a target matrix
  68532. * @param matrix defines the matrix to transpose
  68533. * @param result defines the target matrix
  68534. */
  68535. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68536. /**
  68537. * Computes a reflection matrix from a plane
  68538. * @param plane defines the reflection plane
  68539. * @returns a new matrix
  68540. */
  68541. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68542. /**
  68543. * Computes a reflection matrix from a plane
  68544. * @param plane defines the reflection plane
  68545. * @param result defines the target matrix
  68546. */
  68547. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68548. /**
  68549. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68550. * @param xaxis defines the value of the 1st axis
  68551. * @param yaxis defines the value of the 2nd axis
  68552. * @param zaxis defines the value of the 3rd axis
  68553. * @param result defines the target matrix
  68554. */
  68555. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68556. /**
  68557. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68558. * @param quat defines the quaternion to use
  68559. * @param result defines the target matrix
  68560. */
  68561. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68562. }
  68563. /**
  68564. * @hidden
  68565. */
  68566. export class TmpVectors {
  68567. static Vector2: Vector2[];
  68568. static Vector3: Vector3[];
  68569. static Vector4: Vector4[];
  68570. static Quaternion: Quaternion[];
  68571. static Matrix: Matrix[];
  68572. }
  68573. }
  68574. declare module BABYLON {
  68575. /** Defines the cross module used constants to avoid circular dependncies */
  68576. export class Constants {
  68577. /** Defines that alpha blending is disabled */
  68578. static readonly ALPHA_DISABLE: number;
  68579. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68580. static readonly ALPHA_ADD: number;
  68581. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68582. static readonly ALPHA_COMBINE: number;
  68583. /** Defines that alpha blending to DEST - SRC * DEST */
  68584. static readonly ALPHA_SUBTRACT: number;
  68585. /** Defines that alpha blending to SRC * DEST */
  68586. static readonly ALPHA_MULTIPLY: number;
  68587. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68588. static readonly ALPHA_MAXIMIZED: number;
  68589. /** Defines that alpha blending to SRC + DEST */
  68590. static readonly ALPHA_ONEONE: number;
  68591. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68592. static readonly ALPHA_PREMULTIPLIED: number;
  68593. /**
  68594. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68595. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68596. */
  68597. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68598. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68599. static readonly ALPHA_INTERPOLATE: number;
  68600. /**
  68601. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68602. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68603. */
  68604. static readonly ALPHA_SCREENMODE: number;
  68605. /** Defines that the ressource is not delayed*/
  68606. static readonly DELAYLOADSTATE_NONE: number;
  68607. /** Defines that the ressource was successfully delay loaded */
  68608. static readonly DELAYLOADSTATE_LOADED: number;
  68609. /** Defines that the ressource is currently delay loading */
  68610. static readonly DELAYLOADSTATE_LOADING: number;
  68611. /** Defines that the ressource is delayed and has not started loading */
  68612. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68613. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68614. static readonly NEVER: number;
  68615. /** 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 */
  68616. static readonly ALWAYS: number;
  68617. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68618. static readonly LESS: number;
  68619. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68620. static readonly EQUAL: number;
  68621. /** 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 */
  68622. static readonly LEQUAL: number;
  68623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68624. static readonly GREATER: number;
  68625. /** 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 */
  68626. static readonly GEQUAL: number;
  68627. /** 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 */
  68628. static readonly NOTEQUAL: number;
  68629. /** Passed to stencilOperation to specify that stencil value must be kept */
  68630. static readonly KEEP: number;
  68631. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68632. static readonly REPLACE: number;
  68633. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68634. static readonly INCR: number;
  68635. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68636. static readonly DECR: number;
  68637. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68638. static readonly INVERT: number;
  68639. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68640. static readonly INCR_WRAP: number;
  68641. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68642. static readonly DECR_WRAP: number;
  68643. /** Texture is not repeating outside of 0..1 UVs */
  68644. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68645. /** Texture is repeating outside of 0..1 UVs */
  68646. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68647. /** Texture is repeating and mirrored */
  68648. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68649. /** ALPHA */
  68650. static readonly TEXTUREFORMAT_ALPHA: number;
  68651. /** LUMINANCE */
  68652. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68653. /** LUMINANCE_ALPHA */
  68654. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68655. /** RGB */
  68656. static readonly TEXTUREFORMAT_RGB: number;
  68657. /** RGBA */
  68658. static readonly TEXTUREFORMAT_RGBA: number;
  68659. /** RED */
  68660. static readonly TEXTUREFORMAT_RED: number;
  68661. /** RED (2nd reference) */
  68662. static readonly TEXTUREFORMAT_R: number;
  68663. /** RG */
  68664. static readonly TEXTUREFORMAT_RG: number;
  68665. /** RED_INTEGER */
  68666. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68667. /** RED_INTEGER (2nd reference) */
  68668. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68669. /** RG_INTEGER */
  68670. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68671. /** RGB_INTEGER */
  68672. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68673. /** RGBA_INTEGER */
  68674. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68675. /** UNSIGNED_BYTE */
  68676. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68677. /** UNSIGNED_BYTE (2nd reference) */
  68678. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68679. /** FLOAT */
  68680. static readonly TEXTURETYPE_FLOAT: number;
  68681. /** HALF_FLOAT */
  68682. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68683. /** BYTE */
  68684. static readonly TEXTURETYPE_BYTE: number;
  68685. /** SHORT */
  68686. static readonly TEXTURETYPE_SHORT: number;
  68687. /** UNSIGNED_SHORT */
  68688. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68689. /** INT */
  68690. static readonly TEXTURETYPE_INT: number;
  68691. /** UNSIGNED_INT */
  68692. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68693. /** UNSIGNED_SHORT_4_4_4_4 */
  68694. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68695. /** UNSIGNED_SHORT_5_5_5_1 */
  68696. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68697. /** UNSIGNED_SHORT_5_6_5 */
  68698. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68699. /** UNSIGNED_INT_2_10_10_10_REV */
  68700. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68701. /** UNSIGNED_INT_24_8 */
  68702. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68703. /** UNSIGNED_INT_10F_11F_11F_REV */
  68704. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68705. /** UNSIGNED_INT_5_9_9_9_REV */
  68706. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68707. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68708. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68709. /** nearest is mag = nearest and min = nearest and mip = linear */
  68710. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68711. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68712. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68713. /** Trilinear is mag = linear and min = linear and mip = linear */
  68714. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68715. /** nearest is mag = nearest and min = nearest and mip = linear */
  68716. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68717. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68718. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68719. /** Trilinear is mag = linear and min = linear and mip = linear */
  68720. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68721. /** mag = nearest and min = nearest and mip = nearest */
  68722. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68723. /** mag = nearest and min = linear and mip = nearest */
  68724. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68725. /** mag = nearest and min = linear and mip = linear */
  68726. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68727. /** mag = nearest and min = linear and mip = none */
  68728. static readonly TEXTURE_NEAREST_LINEAR: number;
  68729. /** mag = nearest and min = nearest and mip = none */
  68730. static readonly TEXTURE_NEAREST_NEAREST: number;
  68731. /** mag = linear and min = nearest and mip = nearest */
  68732. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68733. /** mag = linear and min = nearest and mip = linear */
  68734. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68735. /** mag = linear and min = linear and mip = none */
  68736. static readonly TEXTURE_LINEAR_LINEAR: number;
  68737. /** mag = linear and min = nearest and mip = none */
  68738. static readonly TEXTURE_LINEAR_NEAREST: number;
  68739. /** Explicit coordinates mode */
  68740. static readonly TEXTURE_EXPLICIT_MODE: number;
  68741. /** Spherical coordinates mode */
  68742. static readonly TEXTURE_SPHERICAL_MODE: number;
  68743. /** Planar coordinates mode */
  68744. static readonly TEXTURE_PLANAR_MODE: number;
  68745. /** Cubic coordinates mode */
  68746. static readonly TEXTURE_CUBIC_MODE: number;
  68747. /** Projection coordinates mode */
  68748. static readonly TEXTURE_PROJECTION_MODE: number;
  68749. /** Skybox coordinates mode */
  68750. static readonly TEXTURE_SKYBOX_MODE: number;
  68751. /** Inverse Cubic coordinates mode */
  68752. static readonly TEXTURE_INVCUBIC_MODE: number;
  68753. /** Equirectangular coordinates mode */
  68754. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68755. /** Equirectangular Fixed coordinates mode */
  68756. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68757. /** Equirectangular Fixed Mirrored coordinates mode */
  68758. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68759. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68760. static readonly SCALEMODE_FLOOR: number;
  68761. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68762. static readonly SCALEMODE_NEAREST: number;
  68763. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68764. static readonly SCALEMODE_CEILING: number;
  68765. /**
  68766. * The dirty texture flag value
  68767. */
  68768. static readonly MATERIAL_TextureDirtyFlag: number;
  68769. /**
  68770. * The dirty light flag value
  68771. */
  68772. static readonly MATERIAL_LightDirtyFlag: number;
  68773. /**
  68774. * The dirty fresnel flag value
  68775. */
  68776. static readonly MATERIAL_FresnelDirtyFlag: number;
  68777. /**
  68778. * The dirty attribute flag value
  68779. */
  68780. static readonly MATERIAL_AttributesDirtyFlag: number;
  68781. /**
  68782. * The dirty misc flag value
  68783. */
  68784. static readonly MATERIAL_MiscDirtyFlag: number;
  68785. /**
  68786. * The all dirty flag value
  68787. */
  68788. static readonly MATERIAL_AllDirtyFlag: number;
  68789. /**
  68790. * Returns the triangle fill mode
  68791. */
  68792. static readonly MATERIAL_TriangleFillMode: number;
  68793. /**
  68794. * Returns the wireframe mode
  68795. */
  68796. static readonly MATERIAL_WireFrameFillMode: number;
  68797. /**
  68798. * Returns the point fill mode
  68799. */
  68800. static readonly MATERIAL_PointFillMode: number;
  68801. /**
  68802. * Returns the point list draw mode
  68803. */
  68804. static readonly MATERIAL_PointListDrawMode: number;
  68805. /**
  68806. * Returns the line list draw mode
  68807. */
  68808. static readonly MATERIAL_LineListDrawMode: number;
  68809. /**
  68810. * Returns the line loop draw mode
  68811. */
  68812. static readonly MATERIAL_LineLoopDrawMode: number;
  68813. /**
  68814. * Returns the line strip draw mode
  68815. */
  68816. static readonly MATERIAL_LineStripDrawMode: number;
  68817. /**
  68818. * Returns the triangle strip draw mode
  68819. */
  68820. static readonly MATERIAL_TriangleStripDrawMode: number;
  68821. /**
  68822. * Returns the triangle fan draw mode
  68823. */
  68824. static readonly MATERIAL_TriangleFanDrawMode: number;
  68825. /**
  68826. * Stores the clock-wise side orientation
  68827. */
  68828. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68829. /**
  68830. * Stores the counter clock-wise side orientation
  68831. */
  68832. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68833. /**
  68834. * Nothing
  68835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68836. */
  68837. static readonly ACTION_NothingTrigger: number;
  68838. /**
  68839. * On pick
  68840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68841. */
  68842. static readonly ACTION_OnPickTrigger: number;
  68843. /**
  68844. * On left pick
  68845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68846. */
  68847. static readonly ACTION_OnLeftPickTrigger: number;
  68848. /**
  68849. * On right pick
  68850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68851. */
  68852. static readonly ACTION_OnRightPickTrigger: number;
  68853. /**
  68854. * On center pick
  68855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68856. */
  68857. static readonly ACTION_OnCenterPickTrigger: number;
  68858. /**
  68859. * On pick down
  68860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68861. */
  68862. static readonly ACTION_OnPickDownTrigger: number;
  68863. /**
  68864. * On double pick
  68865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68866. */
  68867. static readonly ACTION_OnDoublePickTrigger: number;
  68868. /**
  68869. * On pick up
  68870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68871. */
  68872. static readonly ACTION_OnPickUpTrigger: number;
  68873. /**
  68874. * On pick out.
  68875. * This trigger will only be raised if you also declared a OnPickDown
  68876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68877. */
  68878. static readonly ACTION_OnPickOutTrigger: number;
  68879. /**
  68880. * On long press
  68881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68882. */
  68883. static readonly ACTION_OnLongPressTrigger: number;
  68884. /**
  68885. * On pointer over
  68886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68887. */
  68888. static readonly ACTION_OnPointerOverTrigger: number;
  68889. /**
  68890. * On pointer out
  68891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68892. */
  68893. static readonly ACTION_OnPointerOutTrigger: number;
  68894. /**
  68895. * On every frame
  68896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68897. */
  68898. static readonly ACTION_OnEveryFrameTrigger: number;
  68899. /**
  68900. * On intersection enter
  68901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68902. */
  68903. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68904. /**
  68905. * On intersection exit
  68906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68907. */
  68908. static readonly ACTION_OnIntersectionExitTrigger: number;
  68909. /**
  68910. * On key down
  68911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68912. */
  68913. static readonly ACTION_OnKeyDownTrigger: number;
  68914. /**
  68915. * On key up
  68916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68917. */
  68918. static readonly ACTION_OnKeyUpTrigger: number;
  68919. /**
  68920. * Billboard mode will only apply to Y axis
  68921. */
  68922. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68923. /**
  68924. * Billboard mode will apply to all axes
  68925. */
  68926. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68927. /**
  68928. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68929. */
  68930. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68931. /**
  68932. * Gets or sets base Assets URL
  68933. */
  68934. static PARTICLES_BaseAssetsUrl: string;
  68935. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68936. * Test order :
  68937. * Is the bounding sphere outside the frustum ?
  68938. * If not, are the bounding box vertices outside the frustum ?
  68939. * It not, then the cullable object is in the frustum.
  68940. */
  68941. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68942. /** Culling strategy : Bounding Sphere Only.
  68943. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68944. * It's also less accurate than the standard because some not visible objects can still be selected.
  68945. * Test : is the bounding sphere outside the frustum ?
  68946. * If not, then the cullable object is in the frustum.
  68947. */
  68948. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68949. /** Culling strategy : Optimistic Inclusion.
  68950. * This in an inclusion test first, then the standard exclusion test.
  68951. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68952. * 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.
  68953. * Anyway, it's as accurate as the standard strategy.
  68954. * Test :
  68955. * Is the cullable object bounding sphere center in the frustum ?
  68956. * If not, apply the default culling strategy.
  68957. */
  68958. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68959. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68960. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68961. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68962. * 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.
  68963. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68964. * Test :
  68965. * Is the cullable object bounding sphere center in the frustum ?
  68966. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68967. */
  68968. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68969. /**
  68970. * No logging while loading
  68971. */
  68972. static readonly SCENELOADER_NO_LOGGING: number;
  68973. /**
  68974. * Minimal logging while loading
  68975. */
  68976. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68977. /**
  68978. * Summary logging while loading
  68979. */
  68980. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68981. /**
  68982. * Detailled logging while loading
  68983. */
  68984. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68985. }
  68986. }
  68987. declare module BABYLON {
  68988. /**
  68989. * Class used to store and describe the pipeline context associated with an effect
  68990. */
  68991. export interface IPipelineContext {
  68992. /**
  68993. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68994. */
  68995. isAsync: boolean;
  68996. /**
  68997. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68998. */
  68999. isReady: boolean;
  69000. /** @hidden */
  69001. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69002. }
  69003. }
  69004. declare module BABYLON {
  69005. /** @hidden */
  69006. export interface IShaderProcessor {
  69007. attributeProcessor?: (attribute: string) => string;
  69008. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69009. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69010. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69011. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69012. lineProcessor?: (line: string, isFragment: boolean) => string;
  69013. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69014. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69015. }
  69016. }
  69017. declare module BABYLON {
  69018. /** @hidden */
  69019. export interface ProcessingOptions {
  69020. defines: string[];
  69021. indexParameters: any;
  69022. isFragment: boolean;
  69023. shouldUseHighPrecisionShader: boolean;
  69024. supportsUniformBuffers: boolean;
  69025. shadersRepository: string;
  69026. includesShadersStore: {
  69027. [key: string]: string;
  69028. };
  69029. processor?: IShaderProcessor;
  69030. version: string;
  69031. platformName: string;
  69032. lookForClosingBracketForUniformBuffer?: boolean;
  69033. }
  69034. }
  69035. declare module BABYLON {
  69036. /**
  69037. * Helper to manipulate strings
  69038. */
  69039. export class StringTools {
  69040. /**
  69041. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69042. * @param str Source string
  69043. * @param suffix Suffix to search for in the source string
  69044. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69045. */
  69046. static EndsWith(str: string, suffix: string): boolean;
  69047. /**
  69048. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69049. * @param str Source string
  69050. * @param suffix Suffix to search for in the source string
  69051. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69052. */
  69053. static StartsWith(str: string, suffix: string): boolean;
  69054. }
  69055. }
  69056. declare module BABYLON {
  69057. /** @hidden */
  69058. export class ShaderCodeNode {
  69059. line: string;
  69060. children: ShaderCodeNode[];
  69061. additionalDefineKey?: string;
  69062. additionalDefineValue?: string;
  69063. isValid(preprocessors: {
  69064. [key: string]: string;
  69065. }): boolean;
  69066. process(preprocessors: {
  69067. [key: string]: string;
  69068. }, options: ProcessingOptions): string;
  69069. }
  69070. }
  69071. declare module BABYLON {
  69072. /** @hidden */
  69073. export class ShaderCodeCursor {
  69074. private _lines;
  69075. lineIndex: number;
  69076. readonly currentLine: string;
  69077. readonly canRead: boolean;
  69078. lines: string[];
  69079. }
  69080. }
  69081. declare module BABYLON {
  69082. /** @hidden */
  69083. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69084. process(preprocessors: {
  69085. [key: string]: string;
  69086. }, options: ProcessingOptions): string;
  69087. }
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export class ShaderDefineExpression {
  69092. isTrue(preprocessors: {
  69093. [key: string]: string;
  69094. }): boolean;
  69095. }
  69096. }
  69097. declare module BABYLON {
  69098. /** @hidden */
  69099. export class ShaderCodeTestNode extends ShaderCodeNode {
  69100. testExpression: ShaderDefineExpression;
  69101. isValid(preprocessors: {
  69102. [key: string]: string;
  69103. }): boolean;
  69104. }
  69105. }
  69106. declare module BABYLON {
  69107. /** @hidden */
  69108. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69109. define: string;
  69110. not: boolean;
  69111. constructor(define: string, not?: boolean);
  69112. isTrue(preprocessors: {
  69113. [key: string]: string;
  69114. }): boolean;
  69115. }
  69116. }
  69117. declare module BABYLON {
  69118. /** @hidden */
  69119. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69120. leftOperand: ShaderDefineExpression;
  69121. rightOperand: ShaderDefineExpression;
  69122. isTrue(preprocessors: {
  69123. [key: string]: string;
  69124. }): boolean;
  69125. }
  69126. }
  69127. declare module BABYLON {
  69128. /** @hidden */
  69129. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69130. leftOperand: ShaderDefineExpression;
  69131. rightOperand: ShaderDefineExpression;
  69132. isTrue(preprocessors: {
  69133. [key: string]: string;
  69134. }): boolean;
  69135. }
  69136. }
  69137. declare module BABYLON {
  69138. /** @hidden */
  69139. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69140. define: string;
  69141. operand: string;
  69142. testValue: string;
  69143. constructor(define: string, operand: string, testValue: string);
  69144. isTrue(preprocessors: {
  69145. [key: string]: string;
  69146. }): boolean;
  69147. }
  69148. }
  69149. declare module BABYLON {
  69150. /**
  69151. * @ignore
  69152. * Application error to support additional information when loading a file
  69153. */
  69154. export class LoadFileError extends Error {
  69155. /** defines the optional web request */
  69156. request?: WebRequest | undefined;
  69157. private static _setPrototypeOf;
  69158. /**
  69159. * Creates a new LoadFileError
  69160. * @param message defines the message of the error
  69161. * @param request defines the optional web request
  69162. */
  69163. constructor(message: string,
  69164. /** defines the optional web request */
  69165. request?: WebRequest | undefined);
  69166. }
  69167. }
  69168. declare module BABYLON {
  69169. /**
  69170. * Class used to enable access to offline support
  69171. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69172. */
  69173. export interface IOfflineProvider {
  69174. /**
  69175. * Gets a boolean indicating if scene must be saved in the database
  69176. */
  69177. enableSceneOffline: boolean;
  69178. /**
  69179. * Gets a boolean indicating if textures must be saved in the database
  69180. */
  69181. enableTexturesOffline: boolean;
  69182. /**
  69183. * Open the offline support and make it available
  69184. * @param successCallback defines the callback to call on success
  69185. * @param errorCallback defines the callback to call on error
  69186. */
  69187. open(successCallback: () => void, errorCallback: () => void): void;
  69188. /**
  69189. * Loads an image from the offline support
  69190. * @param url defines the url to load from
  69191. * @param image defines the target DOM image
  69192. */
  69193. loadImage(url: string, image: HTMLImageElement): void;
  69194. /**
  69195. * Loads a file from offline support
  69196. * @param url defines the URL to load from
  69197. * @param sceneLoaded defines a callback to call on success
  69198. * @param progressCallBack defines a callback to call when progress changed
  69199. * @param errorCallback defines a callback to call on error
  69200. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69201. */
  69202. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69203. }
  69204. }
  69205. declare module BABYLON {
  69206. /**
  69207. * Class used to help managing file picking and drag'n'drop
  69208. * File Storage
  69209. */
  69210. export class FilesInputStore {
  69211. /**
  69212. * List of files ready to be loaded
  69213. */
  69214. static FilesToLoad: {
  69215. [key: string]: File;
  69216. };
  69217. }
  69218. }
  69219. declare module BABYLON {
  69220. /**
  69221. * Class used to define a retry strategy when error happens while loading assets
  69222. */
  69223. export class RetryStrategy {
  69224. /**
  69225. * Function used to defines an exponential back off strategy
  69226. * @param maxRetries defines the maximum number of retries (3 by default)
  69227. * @param baseInterval defines the interval between retries
  69228. * @returns the strategy function to use
  69229. */
  69230. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /**
  69235. * @hidden
  69236. */
  69237. export class FileTools {
  69238. /**
  69239. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69240. */
  69241. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69242. /**
  69243. * Gets or sets the base URL to use to load assets
  69244. */
  69245. static BaseUrl: string;
  69246. /**
  69247. * Default behaviour for cors in the application.
  69248. * It can be a string if the expected behavior is identical in the entire app.
  69249. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69250. */
  69251. static CorsBehavior: string | ((url: string | string[]) => string);
  69252. /**
  69253. * Gets or sets a function used to pre-process url before using them to load assets
  69254. */
  69255. static PreprocessUrl: (url: string) => string;
  69256. /**
  69257. * Removes unwanted characters from an url
  69258. * @param url defines the url to clean
  69259. * @returns the cleaned url
  69260. */
  69261. private static _CleanUrl;
  69262. /**
  69263. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69264. * @param url define the url we are trying
  69265. * @param element define the dom element where to configure the cors policy
  69266. */
  69267. static SetCorsBehavior(url: string | string[], element: {
  69268. crossOrigin: string | null;
  69269. }): void;
  69270. /**
  69271. * Loads an image as an HTMLImageElement.
  69272. * @param input url string, ArrayBuffer, or Blob to load
  69273. * @param onLoad callback called when the image successfully loads
  69274. * @param onError callback called when the image fails to load
  69275. * @param offlineProvider offline provider for caching
  69276. * @returns the HTMLImageElement of the loaded image
  69277. */
  69278. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69279. /**
  69280. * Loads a file
  69281. * @param fileToLoad defines the file to load
  69282. * @param callback defines the callback to call when data is loaded
  69283. * @param progressCallBack defines the callback to call during loading process
  69284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69285. * @returns a file request object
  69286. */
  69287. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69288. /**
  69289. * Loads a file
  69290. * @param url url string, ArrayBuffer, or Blob to load
  69291. * @param onSuccess callback called when the file successfully loads
  69292. * @param onProgress callback called while file is loading (if the server supports this mode)
  69293. * @param offlineProvider defines the offline provider for caching
  69294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69295. * @param onError callback called when the file fails to load
  69296. * @returns a file request object
  69297. */
  69298. 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;
  69299. /**
  69300. * Checks if the loaded document was accessed via `file:`-Protocol.
  69301. * @returns boolean
  69302. */
  69303. static IsFileURL(): boolean;
  69304. }
  69305. }
  69306. declare module BABYLON {
  69307. /** @hidden */
  69308. export class ShaderProcessor {
  69309. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69310. private static _ProcessPrecision;
  69311. private static _ExtractOperation;
  69312. private static _BuildSubExpression;
  69313. private static _BuildExpression;
  69314. private static _MoveCursorWithinIf;
  69315. private static _MoveCursor;
  69316. private static _EvaluatePreProcessors;
  69317. private static _PreparePreProcessors;
  69318. private static _ProcessShaderConversion;
  69319. private static _ProcessIncludes;
  69320. }
  69321. }
  69322. declare module BABYLON {
  69323. /**
  69324. * Class used to hold a RBG color
  69325. */
  69326. export class Color3 {
  69327. /**
  69328. * Defines the red component (between 0 and 1, default is 0)
  69329. */
  69330. r: number;
  69331. /**
  69332. * Defines the green component (between 0 and 1, default is 0)
  69333. */
  69334. g: number;
  69335. /**
  69336. * Defines the blue component (between 0 and 1, default is 0)
  69337. */
  69338. b: number;
  69339. /**
  69340. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69341. * @param r defines the red component (between 0 and 1, default is 0)
  69342. * @param g defines the green component (between 0 and 1, default is 0)
  69343. * @param b defines the blue component (between 0 and 1, default is 0)
  69344. */
  69345. constructor(
  69346. /**
  69347. * Defines the red component (between 0 and 1, default is 0)
  69348. */
  69349. r?: number,
  69350. /**
  69351. * Defines the green component (between 0 and 1, default is 0)
  69352. */
  69353. g?: number,
  69354. /**
  69355. * Defines the blue component (between 0 and 1, default is 0)
  69356. */
  69357. b?: number);
  69358. /**
  69359. * Creates a string with the Color3 current values
  69360. * @returns the string representation of the Color3 object
  69361. */
  69362. toString(): string;
  69363. /**
  69364. * Returns the string "Color3"
  69365. * @returns "Color3"
  69366. */
  69367. getClassName(): string;
  69368. /**
  69369. * Compute the Color3 hash code
  69370. * @returns an unique number that can be used to hash Color3 objects
  69371. */
  69372. getHashCode(): number;
  69373. /**
  69374. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69375. * @param array defines the array where to store the r,g,b components
  69376. * @param index defines an optional index in the target array to define where to start storing values
  69377. * @returns the current Color3 object
  69378. */
  69379. toArray(array: FloatArray, index?: number): Color3;
  69380. /**
  69381. * Returns a new Color4 object from the current Color3 and the given alpha
  69382. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69383. * @returns a new Color4 object
  69384. */
  69385. toColor4(alpha?: number): Color4;
  69386. /**
  69387. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69388. * @returns the new array
  69389. */
  69390. asArray(): number[];
  69391. /**
  69392. * Returns the luminance value
  69393. * @returns a float value
  69394. */
  69395. toLuminance(): number;
  69396. /**
  69397. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69398. * @param otherColor defines the second operand
  69399. * @returns the new Color3 object
  69400. */
  69401. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69402. /**
  69403. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69404. * @param otherColor defines the second operand
  69405. * @param result defines the Color3 object where to store the result
  69406. * @returns the current Color3
  69407. */
  69408. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69409. /**
  69410. * Determines equality between Color3 objects
  69411. * @param otherColor defines the second operand
  69412. * @returns true if the rgb values are equal to the given ones
  69413. */
  69414. equals(otherColor: DeepImmutable<Color3>): boolean;
  69415. /**
  69416. * Determines equality between the current Color3 object and a set of r,b,g values
  69417. * @param r defines the red component to check
  69418. * @param g defines the green component to check
  69419. * @param b defines the blue component to check
  69420. * @returns true if the rgb values are equal to the given ones
  69421. */
  69422. equalsFloats(r: number, g: number, b: number): boolean;
  69423. /**
  69424. * Multiplies in place each rgb value by scale
  69425. * @param scale defines the scaling factor
  69426. * @returns the updated Color3
  69427. */
  69428. scale(scale: number): Color3;
  69429. /**
  69430. * Multiplies the rgb values by scale and stores the result into "result"
  69431. * @param scale defines the scaling factor
  69432. * @param result defines the Color3 object where to store the result
  69433. * @returns the unmodified current Color3
  69434. */
  69435. scaleToRef(scale: number, result: Color3): Color3;
  69436. /**
  69437. * Scale the current Color3 values by a factor and add the result to a given Color3
  69438. * @param scale defines the scale factor
  69439. * @param result defines color to store the result into
  69440. * @returns the unmodified current Color3
  69441. */
  69442. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69443. /**
  69444. * Clamps the rgb values by the min and max values and stores the result into "result"
  69445. * @param min defines minimum clamping value (default is 0)
  69446. * @param max defines maximum clamping value (default is 1)
  69447. * @param result defines color to store the result into
  69448. * @returns the original Color3
  69449. */
  69450. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69451. /**
  69452. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69453. * @param otherColor defines the second operand
  69454. * @returns the new Color3
  69455. */
  69456. add(otherColor: DeepImmutable<Color3>): Color3;
  69457. /**
  69458. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69459. * @param otherColor defines the second operand
  69460. * @param result defines Color3 object to store the result into
  69461. * @returns the unmodified current Color3
  69462. */
  69463. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69464. /**
  69465. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69466. * @param otherColor defines the second operand
  69467. * @returns the new Color3
  69468. */
  69469. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69470. /**
  69471. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69472. * @param otherColor defines the second operand
  69473. * @param result defines Color3 object to store the result into
  69474. * @returns the unmodified current Color3
  69475. */
  69476. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69477. /**
  69478. * Copy the current object
  69479. * @returns a new Color3 copied the current one
  69480. */
  69481. clone(): Color3;
  69482. /**
  69483. * Copies the rgb values from the source in the current Color3
  69484. * @param source defines the source Color3 object
  69485. * @returns the updated Color3 object
  69486. */
  69487. copyFrom(source: DeepImmutable<Color3>): Color3;
  69488. /**
  69489. * Updates the Color3 rgb values from the given floats
  69490. * @param r defines the red component to read from
  69491. * @param g defines the green component to read from
  69492. * @param b defines the blue component to read from
  69493. * @returns the current Color3 object
  69494. */
  69495. copyFromFloats(r: number, g: number, b: number): Color3;
  69496. /**
  69497. * Updates the Color3 rgb values from the given floats
  69498. * @param r defines the red component to read from
  69499. * @param g defines the green component to read from
  69500. * @param b defines the blue component to read from
  69501. * @returns the current Color3 object
  69502. */
  69503. set(r: number, g: number, b: number): Color3;
  69504. /**
  69505. * Compute the Color3 hexadecimal code as a string
  69506. * @returns a string containing the hexadecimal representation of the Color3 object
  69507. */
  69508. toHexString(): string;
  69509. /**
  69510. * Computes a new Color3 converted from the current one to linear space
  69511. * @returns a new Color3 object
  69512. */
  69513. toLinearSpace(): Color3;
  69514. /**
  69515. * Converts current color in rgb space to HSV values
  69516. * @returns a new color3 representing the HSV values
  69517. */
  69518. toHSV(): Color3;
  69519. /**
  69520. * Converts current color in rgb space to HSV values
  69521. * @param result defines the Color3 where to store the HSV values
  69522. */
  69523. toHSVToRef(result: Color3): void;
  69524. /**
  69525. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69526. * @param convertedColor defines the Color3 object where to store the linear space version
  69527. * @returns the unmodified Color3
  69528. */
  69529. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69530. /**
  69531. * Computes a new Color3 converted from the current one to gamma space
  69532. * @returns a new Color3 object
  69533. */
  69534. toGammaSpace(): Color3;
  69535. /**
  69536. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69537. * @param convertedColor defines the Color3 object where to store the gamma space version
  69538. * @returns the unmodified Color3
  69539. */
  69540. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69541. private static _BlackReadOnly;
  69542. /**
  69543. * Convert Hue, saturation and value to a Color3 (RGB)
  69544. * @param hue defines the hue
  69545. * @param saturation defines the saturation
  69546. * @param value defines the value
  69547. * @param result defines the Color3 where to store the RGB values
  69548. */
  69549. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69550. /**
  69551. * Creates a new Color3 from the string containing valid hexadecimal values
  69552. * @param hex defines a string containing valid hexadecimal values
  69553. * @returns a new Color3 object
  69554. */
  69555. static FromHexString(hex: string): Color3;
  69556. /**
  69557. * Creates a new Color3 from the starting index of the given array
  69558. * @param array defines the source array
  69559. * @param offset defines an offset in the source array
  69560. * @returns a new Color3 object
  69561. */
  69562. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69563. /**
  69564. * Creates a new Color3 from integer values (< 256)
  69565. * @param r defines the red component to read from (value between 0 and 255)
  69566. * @param g defines the green component to read from (value between 0 and 255)
  69567. * @param b defines the blue component to read from (value between 0 and 255)
  69568. * @returns a new Color3 object
  69569. */
  69570. static FromInts(r: number, g: number, b: number): Color3;
  69571. /**
  69572. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69573. * @param start defines the start Color3 value
  69574. * @param end defines the end Color3 value
  69575. * @param amount defines the gradient value between start and end
  69576. * @returns a new Color3 object
  69577. */
  69578. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69579. /**
  69580. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69581. * @param left defines the start value
  69582. * @param right defines the end value
  69583. * @param amount defines the gradient factor
  69584. * @param result defines the Color3 object where to store the result
  69585. */
  69586. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69587. /**
  69588. * Returns a Color3 value containing a red color
  69589. * @returns a new Color3 object
  69590. */
  69591. static Red(): Color3;
  69592. /**
  69593. * Returns a Color3 value containing a green color
  69594. * @returns a new Color3 object
  69595. */
  69596. static Green(): Color3;
  69597. /**
  69598. * Returns a Color3 value containing a blue color
  69599. * @returns a new Color3 object
  69600. */
  69601. static Blue(): Color3;
  69602. /**
  69603. * Returns a Color3 value containing a black color
  69604. * @returns a new Color3 object
  69605. */
  69606. static Black(): Color3;
  69607. /**
  69608. * Gets a Color3 value containing a black color that must not be updated
  69609. */
  69610. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69611. /**
  69612. * Returns a Color3 value containing a white color
  69613. * @returns a new Color3 object
  69614. */
  69615. static White(): Color3;
  69616. /**
  69617. * Returns a Color3 value containing a purple color
  69618. * @returns a new Color3 object
  69619. */
  69620. static Purple(): Color3;
  69621. /**
  69622. * Returns a Color3 value containing a magenta color
  69623. * @returns a new Color3 object
  69624. */
  69625. static Magenta(): Color3;
  69626. /**
  69627. * Returns a Color3 value containing a yellow color
  69628. * @returns a new Color3 object
  69629. */
  69630. static Yellow(): Color3;
  69631. /**
  69632. * Returns a Color3 value containing a gray color
  69633. * @returns a new Color3 object
  69634. */
  69635. static Gray(): Color3;
  69636. /**
  69637. * Returns a Color3 value containing a teal color
  69638. * @returns a new Color3 object
  69639. */
  69640. static Teal(): Color3;
  69641. /**
  69642. * Returns a Color3 value containing a random color
  69643. * @returns a new Color3 object
  69644. */
  69645. static Random(): Color3;
  69646. }
  69647. /**
  69648. * Class used to hold a RBGA color
  69649. */
  69650. export class Color4 {
  69651. /**
  69652. * Defines the red component (between 0 and 1, default is 0)
  69653. */
  69654. r: number;
  69655. /**
  69656. * Defines the green component (between 0 and 1, default is 0)
  69657. */
  69658. g: number;
  69659. /**
  69660. * Defines the blue component (between 0 and 1, default is 0)
  69661. */
  69662. b: number;
  69663. /**
  69664. * Defines the alpha component (between 0 and 1, default is 1)
  69665. */
  69666. a: number;
  69667. /**
  69668. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69669. * @param r defines the red component (between 0 and 1, default is 0)
  69670. * @param g defines the green component (between 0 and 1, default is 0)
  69671. * @param b defines the blue component (between 0 and 1, default is 0)
  69672. * @param a defines the alpha component (between 0 and 1, default is 1)
  69673. */
  69674. constructor(
  69675. /**
  69676. * Defines the red component (between 0 and 1, default is 0)
  69677. */
  69678. r?: number,
  69679. /**
  69680. * Defines the green component (between 0 and 1, default is 0)
  69681. */
  69682. g?: number,
  69683. /**
  69684. * Defines the blue component (between 0 and 1, default is 0)
  69685. */
  69686. b?: number,
  69687. /**
  69688. * Defines the alpha component (between 0 and 1, default is 1)
  69689. */
  69690. a?: number);
  69691. /**
  69692. * Adds in place the given Color4 values to the current Color4 object
  69693. * @param right defines the second operand
  69694. * @returns the current updated Color4 object
  69695. */
  69696. addInPlace(right: DeepImmutable<Color4>): Color4;
  69697. /**
  69698. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69699. * @returns the new array
  69700. */
  69701. asArray(): number[];
  69702. /**
  69703. * Stores from the starting index in the given array the Color4 successive values
  69704. * @param array defines the array where to store the r,g,b components
  69705. * @param index defines an optional index in the target array to define where to start storing values
  69706. * @returns the current Color4 object
  69707. */
  69708. toArray(array: number[], index?: number): Color4;
  69709. /**
  69710. * Determines equality between Color4 objects
  69711. * @param otherColor defines the second operand
  69712. * @returns true if the rgba values are equal to the given ones
  69713. */
  69714. equals(otherColor: DeepImmutable<Color4>): boolean;
  69715. /**
  69716. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69717. * @param right defines the second operand
  69718. * @returns a new Color4 object
  69719. */
  69720. add(right: DeepImmutable<Color4>): Color4;
  69721. /**
  69722. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69723. * @param right defines the second operand
  69724. * @returns a new Color4 object
  69725. */
  69726. subtract(right: DeepImmutable<Color4>): Color4;
  69727. /**
  69728. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69729. * @param right defines the second operand
  69730. * @param result defines the Color4 object where to store the result
  69731. * @returns the current Color4 object
  69732. */
  69733. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69734. /**
  69735. * Creates a new Color4 with the current Color4 values multiplied by scale
  69736. * @param scale defines the scaling factor to apply
  69737. * @returns a new Color4 object
  69738. */
  69739. scale(scale: number): Color4;
  69740. /**
  69741. * Multiplies the current Color4 values by scale and stores the result in "result"
  69742. * @param scale defines the scaling factor to apply
  69743. * @param result defines the Color4 object where to store the result
  69744. * @returns the current unmodified Color4
  69745. */
  69746. scaleToRef(scale: number, result: Color4): Color4;
  69747. /**
  69748. * Scale the current Color4 values by a factor and add the result to a given Color4
  69749. * @param scale defines the scale factor
  69750. * @param result defines the Color4 object where to store the result
  69751. * @returns the unmodified current Color4
  69752. */
  69753. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69754. /**
  69755. * Clamps the rgb values by the min and max values and stores the result into "result"
  69756. * @param min defines minimum clamping value (default is 0)
  69757. * @param max defines maximum clamping value (default is 1)
  69758. * @param result defines color to store the result into.
  69759. * @returns the cuurent Color4
  69760. */
  69761. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69762. /**
  69763. * Multipy an Color4 value by another and return a new Color4 object
  69764. * @param color defines the Color4 value to multiply by
  69765. * @returns a new Color4 object
  69766. */
  69767. multiply(color: Color4): Color4;
  69768. /**
  69769. * Multipy a Color4 value by another and push the result in a reference value
  69770. * @param color defines the Color4 value to multiply by
  69771. * @param result defines the Color4 to fill the result in
  69772. * @returns the result Color4
  69773. */
  69774. multiplyToRef(color: Color4, result: Color4): Color4;
  69775. /**
  69776. * Creates a string with the Color4 current values
  69777. * @returns the string representation of the Color4 object
  69778. */
  69779. toString(): string;
  69780. /**
  69781. * Returns the string "Color4"
  69782. * @returns "Color4"
  69783. */
  69784. getClassName(): string;
  69785. /**
  69786. * Compute the Color4 hash code
  69787. * @returns an unique number that can be used to hash Color4 objects
  69788. */
  69789. getHashCode(): number;
  69790. /**
  69791. * Creates a new Color4 copied from the current one
  69792. * @returns a new Color4 object
  69793. */
  69794. clone(): Color4;
  69795. /**
  69796. * Copies the given Color4 values into the current one
  69797. * @param source defines the source Color4 object
  69798. * @returns the current updated Color4 object
  69799. */
  69800. copyFrom(source: Color4): Color4;
  69801. /**
  69802. * Copies the given float values into the current one
  69803. * @param r defines the red component to read from
  69804. * @param g defines the green component to read from
  69805. * @param b defines the blue component to read from
  69806. * @param a defines the alpha component to read from
  69807. * @returns the current updated Color4 object
  69808. */
  69809. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69810. /**
  69811. * Copies the given float values into the current one
  69812. * @param r defines the red component to read from
  69813. * @param g defines the green component to read from
  69814. * @param b defines the blue component to read from
  69815. * @param a defines the alpha component to read from
  69816. * @returns the current updated Color4 object
  69817. */
  69818. set(r: number, g: number, b: number, a: number): Color4;
  69819. /**
  69820. * Compute the Color4 hexadecimal code as a string
  69821. * @returns a string containing the hexadecimal representation of the Color4 object
  69822. */
  69823. toHexString(): string;
  69824. /**
  69825. * Computes a new Color4 converted from the current one to linear space
  69826. * @returns a new Color4 object
  69827. */
  69828. toLinearSpace(): Color4;
  69829. /**
  69830. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69831. * @param convertedColor defines the Color4 object where to store the linear space version
  69832. * @returns the unmodified Color4
  69833. */
  69834. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69835. /**
  69836. * Computes a new Color4 converted from the current one to gamma space
  69837. * @returns a new Color4 object
  69838. */
  69839. toGammaSpace(): Color4;
  69840. /**
  69841. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69842. * @param convertedColor defines the Color4 object where to store the gamma space version
  69843. * @returns the unmodified Color4
  69844. */
  69845. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69846. /**
  69847. * Creates a new Color4 from the string containing valid hexadecimal values
  69848. * @param hex defines a string containing valid hexadecimal values
  69849. * @returns a new Color4 object
  69850. */
  69851. static FromHexString(hex: string): Color4;
  69852. /**
  69853. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69854. * @param left defines the start value
  69855. * @param right defines the end value
  69856. * @param amount defines the gradient factor
  69857. * @returns a new Color4 object
  69858. */
  69859. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69860. /**
  69861. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69862. * @param left defines the start value
  69863. * @param right defines the end value
  69864. * @param amount defines the gradient factor
  69865. * @param result defines the Color4 object where to store data
  69866. */
  69867. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69868. /**
  69869. * Creates a new Color4 from a Color3 and an alpha value
  69870. * @param color3 defines the source Color3 to read from
  69871. * @param alpha defines the alpha component (1.0 by default)
  69872. * @returns a new Color4 object
  69873. */
  69874. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69875. /**
  69876. * Creates a new Color4 from the starting index element of the given array
  69877. * @param array defines the source array to read from
  69878. * @param offset defines the offset in the source array
  69879. * @returns a new Color4 object
  69880. */
  69881. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69882. /**
  69883. * Creates a new Color3 from integer values (< 256)
  69884. * @param r defines the red component to read from (value between 0 and 255)
  69885. * @param g defines the green component to read from (value between 0 and 255)
  69886. * @param b defines the blue component to read from (value between 0 and 255)
  69887. * @param a defines the alpha component to read from (value between 0 and 255)
  69888. * @returns a new Color3 object
  69889. */
  69890. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69891. /**
  69892. * Check the content of a given array and convert it to an array containing RGBA data
  69893. * If the original array was already containing count * 4 values then it is returned directly
  69894. * @param colors defines the array to check
  69895. * @param count defines the number of RGBA data to expect
  69896. * @returns an array containing count * 4 values (RGBA)
  69897. */
  69898. static CheckColors4(colors: number[], count: number): number[];
  69899. }
  69900. /**
  69901. * @hidden
  69902. */
  69903. export class TmpColors {
  69904. static Color3: Color3[];
  69905. static Color4: Color4[];
  69906. }
  69907. }
  69908. declare module BABYLON {
  69909. /**
  69910. * Class representing spherical harmonics coefficients to the 3rd degree
  69911. */
  69912. export class SphericalHarmonics {
  69913. /**
  69914. * Defines whether or not the harmonics have been prescaled for rendering.
  69915. */
  69916. preScaled: boolean;
  69917. /**
  69918. * The l0,0 coefficients of the spherical harmonics
  69919. */
  69920. l00: Vector3;
  69921. /**
  69922. * The l1,-1 coefficients of the spherical harmonics
  69923. */
  69924. l1_1: Vector3;
  69925. /**
  69926. * The l1,0 coefficients of the spherical harmonics
  69927. */
  69928. l10: Vector3;
  69929. /**
  69930. * The l1,1 coefficients of the spherical harmonics
  69931. */
  69932. l11: Vector3;
  69933. /**
  69934. * The l2,-2 coefficients of the spherical harmonics
  69935. */
  69936. l2_2: Vector3;
  69937. /**
  69938. * The l2,-1 coefficients of the spherical harmonics
  69939. */
  69940. l2_1: Vector3;
  69941. /**
  69942. * The l2,0 coefficients of the spherical harmonics
  69943. */
  69944. l20: Vector3;
  69945. /**
  69946. * The l2,1 coefficients of the spherical harmonics
  69947. */
  69948. l21: Vector3;
  69949. /**
  69950. * The l2,2 coefficients of the spherical harmonics
  69951. */
  69952. l22: Vector3;
  69953. /**
  69954. * Adds a light to the spherical harmonics
  69955. * @param direction the direction of the light
  69956. * @param color the color of the light
  69957. * @param deltaSolidAngle the delta solid angle of the light
  69958. */
  69959. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69960. /**
  69961. * Scales the spherical harmonics by the given amount
  69962. * @param scale the amount to scale
  69963. */
  69964. scaleInPlace(scale: number): void;
  69965. /**
  69966. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69967. *
  69968. * ```
  69969. * E_lm = A_l * L_lm
  69970. * ```
  69971. *
  69972. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69973. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69974. * the scaling factors are given in equation 9.
  69975. */
  69976. convertIncidentRadianceToIrradiance(): void;
  69977. /**
  69978. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69979. *
  69980. * ```
  69981. * L = (1/pi) * E * rho
  69982. * ```
  69983. *
  69984. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69985. */
  69986. convertIrradianceToLambertianRadiance(): void;
  69987. /**
  69988. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69989. * required operations at run time.
  69990. *
  69991. * This is simply done by scaling back the SH with Ylm constants parameter.
  69992. * The trigonometric part being applied by the shader at run time.
  69993. */
  69994. preScaleForRendering(): void;
  69995. /**
  69996. * Constructs a spherical harmonics from an array.
  69997. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69998. * @returns the spherical harmonics
  69999. */
  70000. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70001. /**
  70002. * Gets the spherical harmonics from polynomial
  70003. * @param polynomial the spherical polynomial
  70004. * @returns the spherical harmonics
  70005. */
  70006. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70007. }
  70008. /**
  70009. * Class representing spherical polynomial coefficients to the 3rd degree
  70010. */
  70011. export class SphericalPolynomial {
  70012. private _harmonics;
  70013. /**
  70014. * The spherical harmonics used to create the polynomials.
  70015. */
  70016. readonly preScaledHarmonics: SphericalHarmonics;
  70017. /**
  70018. * The x coefficients of the spherical polynomial
  70019. */
  70020. x: Vector3;
  70021. /**
  70022. * The y coefficients of the spherical polynomial
  70023. */
  70024. y: Vector3;
  70025. /**
  70026. * The z coefficients of the spherical polynomial
  70027. */
  70028. z: Vector3;
  70029. /**
  70030. * The xx coefficients of the spherical polynomial
  70031. */
  70032. xx: Vector3;
  70033. /**
  70034. * The yy coefficients of the spherical polynomial
  70035. */
  70036. yy: Vector3;
  70037. /**
  70038. * The zz coefficients of the spherical polynomial
  70039. */
  70040. zz: Vector3;
  70041. /**
  70042. * The xy coefficients of the spherical polynomial
  70043. */
  70044. xy: Vector3;
  70045. /**
  70046. * The yz coefficients of the spherical polynomial
  70047. */
  70048. yz: Vector3;
  70049. /**
  70050. * The zx coefficients of the spherical polynomial
  70051. */
  70052. zx: Vector3;
  70053. /**
  70054. * Adds an ambient color to the spherical polynomial
  70055. * @param color the color to add
  70056. */
  70057. addAmbient(color: Color3): void;
  70058. /**
  70059. * Scales the spherical polynomial by the given amount
  70060. * @param scale the amount to scale
  70061. */
  70062. scaleInPlace(scale: number): void;
  70063. /**
  70064. * Gets the spherical polynomial from harmonics
  70065. * @param harmonics the spherical harmonics
  70066. * @returns the spherical polynomial
  70067. */
  70068. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70069. /**
  70070. * Constructs a spherical polynomial from an array.
  70071. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70072. * @returns the spherical polynomial
  70073. */
  70074. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /**
  70079. * Define options used to create a render target texture
  70080. */
  70081. export class RenderTargetCreationOptions {
  70082. /**
  70083. * Specifies is mipmaps must be generated
  70084. */
  70085. generateMipMaps?: boolean;
  70086. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70087. generateDepthBuffer?: boolean;
  70088. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70089. generateStencilBuffer?: boolean;
  70090. /** Defines texture type (int by default) */
  70091. type?: number;
  70092. /** Defines sampling mode (trilinear by default) */
  70093. samplingMode?: number;
  70094. /** Defines format (RGBA by default) */
  70095. format?: number;
  70096. }
  70097. }
  70098. declare module BABYLON {
  70099. /**
  70100. * @hidden
  70101. **/
  70102. export class _AlphaState {
  70103. private _isAlphaBlendDirty;
  70104. private _isBlendFunctionParametersDirty;
  70105. private _isBlendEquationParametersDirty;
  70106. private _isBlendConstantsDirty;
  70107. private _alphaBlend;
  70108. private _blendFunctionParameters;
  70109. private _blendEquationParameters;
  70110. private _blendConstants;
  70111. /**
  70112. * Initializes the state.
  70113. */
  70114. constructor();
  70115. readonly isDirty: boolean;
  70116. alphaBlend: boolean;
  70117. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70118. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70119. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70120. reset(): void;
  70121. apply(gl: WebGLRenderingContext): void;
  70122. }
  70123. }
  70124. declare module BABYLON {
  70125. /**
  70126. * @hidden
  70127. **/
  70128. export class _DepthCullingState {
  70129. private _isDepthTestDirty;
  70130. private _isDepthMaskDirty;
  70131. private _isDepthFuncDirty;
  70132. private _isCullFaceDirty;
  70133. private _isCullDirty;
  70134. private _isZOffsetDirty;
  70135. private _isFrontFaceDirty;
  70136. private _depthTest;
  70137. private _depthMask;
  70138. private _depthFunc;
  70139. private _cull;
  70140. private _cullFace;
  70141. private _zOffset;
  70142. private _frontFace;
  70143. /**
  70144. * Initializes the state.
  70145. */
  70146. constructor();
  70147. readonly isDirty: boolean;
  70148. zOffset: number;
  70149. cullFace: Nullable<number>;
  70150. cull: Nullable<boolean>;
  70151. depthFunc: Nullable<number>;
  70152. depthMask: boolean;
  70153. depthTest: boolean;
  70154. frontFace: Nullable<number>;
  70155. reset(): void;
  70156. apply(gl: WebGLRenderingContext): void;
  70157. }
  70158. }
  70159. declare module BABYLON {
  70160. /**
  70161. * @hidden
  70162. **/
  70163. export class _StencilState {
  70164. /** 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 */
  70165. static readonly ALWAYS: number;
  70166. /** Passed to stencilOperation to specify that stencil value must be kept */
  70167. static readonly KEEP: number;
  70168. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70169. static readonly REPLACE: number;
  70170. private _isStencilTestDirty;
  70171. private _isStencilMaskDirty;
  70172. private _isStencilFuncDirty;
  70173. private _isStencilOpDirty;
  70174. private _stencilTest;
  70175. private _stencilMask;
  70176. private _stencilFunc;
  70177. private _stencilFuncRef;
  70178. private _stencilFuncMask;
  70179. private _stencilOpStencilFail;
  70180. private _stencilOpDepthFail;
  70181. private _stencilOpStencilDepthPass;
  70182. readonly isDirty: boolean;
  70183. stencilFunc: number;
  70184. stencilFuncRef: number;
  70185. stencilFuncMask: number;
  70186. stencilOpStencilFail: number;
  70187. stencilOpDepthFail: number;
  70188. stencilOpStencilDepthPass: number;
  70189. stencilMask: number;
  70190. stencilTest: boolean;
  70191. constructor();
  70192. reset(): void;
  70193. apply(gl: WebGLRenderingContext): void;
  70194. }
  70195. }
  70196. declare module BABYLON {
  70197. /**
  70198. * @hidden
  70199. **/
  70200. export class _TimeToken {
  70201. _startTimeQuery: Nullable<WebGLQuery>;
  70202. _endTimeQuery: Nullable<WebGLQuery>;
  70203. _timeElapsedQuery: Nullable<WebGLQuery>;
  70204. _timeElapsedQueryEnded: boolean;
  70205. }
  70206. }
  70207. declare module BABYLON {
  70208. /**
  70209. * Class used to evalaute queries containing `and` and `or` operators
  70210. */
  70211. export class AndOrNotEvaluator {
  70212. /**
  70213. * Evaluate a query
  70214. * @param query defines the query to evaluate
  70215. * @param evaluateCallback defines the callback used to filter result
  70216. * @returns true if the query matches
  70217. */
  70218. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70219. private static _HandleParenthesisContent;
  70220. private static _SimplifyNegation;
  70221. }
  70222. }
  70223. declare module BABYLON {
  70224. /**
  70225. * Class used to store custom tags
  70226. */
  70227. export class Tags {
  70228. /**
  70229. * Adds support for tags on the given object
  70230. * @param obj defines the object to use
  70231. */
  70232. static EnableFor(obj: any): void;
  70233. /**
  70234. * Removes tags support
  70235. * @param obj defines the object to use
  70236. */
  70237. static DisableFor(obj: any): void;
  70238. /**
  70239. * Gets a boolean indicating if the given object has tags
  70240. * @param obj defines the object to use
  70241. * @returns a boolean
  70242. */
  70243. static HasTags(obj: any): boolean;
  70244. /**
  70245. * Gets the tags available on a given object
  70246. * @param obj defines the object to use
  70247. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70248. * @returns the tags
  70249. */
  70250. static GetTags(obj: any, asString?: boolean): any;
  70251. /**
  70252. * Adds tags to an object
  70253. * @param obj defines the object to use
  70254. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70255. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70256. */
  70257. static AddTagsTo(obj: any, tagsString: string): void;
  70258. /**
  70259. * @hidden
  70260. */
  70261. static _AddTagTo(obj: any, tag: string): void;
  70262. /**
  70263. * Removes specific tags from a specific object
  70264. * @param obj defines the object to use
  70265. * @param tagsString defines the tags to remove
  70266. */
  70267. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70268. /**
  70269. * @hidden
  70270. */
  70271. static _RemoveTagFrom(obj: any, tag: string): void;
  70272. /**
  70273. * Defines if tags hosted on an object match a given query
  70274. * @param obj defines the object to use
  70275. * @param tagsQuery defines the tag query
  70276. * @returns a boolean
  70277. */
  70278. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70279. }
  70280. }
  70281. declare module BABYLON {
  70282. /**
  70283. * Defines potential orientation for back face culling
  70284. */
  70285. export enum Orientation {
  70286. /**
  70287. * Clockwise
  70288. */
  70289. CW = 0,
  70290. /** Counter clockwise */
  70291. CCW = 1
  70292. }
  70293. /** Class used to represent a Bezier curve */
  70294. export class BezierCurve {
  70295. /**
  70296. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70297. * @param t defines the time
  70298. * @param x1 defines the left coordinate on X axis
  70299. * @param y1 defines the left coordinate on Y axis
  70300. * @param x2 defines the right coordinate on X axis
  70301. * @param y2 defines the right coordinate on Y axis
  70302. * @returns the interpolated value
  70303. */
  70304. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70305. }
  70306. /**
  70307. * Defines angle representation
  70308. */
  70309. export class Angle {
  70310. private _radians;
  70311. /**
  70312. * Creates an Angle object of "radians" radians (float).
  70313. * @param radians the angle in radians
  70314. */
  70315. constructor(radians: number);
  70316. /**
  70317. * Get value in degrees
  70318. * @returns the Angle value in degrees (float)
  70319. */
  70320. degrees(): number;
  70321. /**
  70322. * Get value in radians
  70323. * @returns the Angle value in radians (float)
  70324. */
  70325. radians(): number;
  70326. /**
  70327. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70328. * @param a defines first vector
  70329. * @param b defines second vector
  70330. * @returns a new Angle
  70331. */
  70332. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70333. /**
  70334. * Gets a new Angle object from the given float in radians
  70335. * @param radians defines the angle value in radians
  70336. * @returns a new Angle
  70337. */
  70338. static FromRadians(radians: number): Angle;
  70339. /**
  70340. * Gets a new Angle object from the given float in degrees
  70341. * @param degrees defines the angle value in degrees
  70342. * @returns a new Angle
  70343. */
  70344. static FromDegrees(degrees: number): Angle;
  70345. }
  70346. /**
  70347. * This represents an arc in a 2d space.
  70348. */
  70349. export class Arc2 {
  70350. /** Defines the start point of the arc */
  70351. startPoint: Vector2;
  70352. /** Defines the mid point of the arc */
  70353. midPoint: Vector2;
  70354. /** Defines the end point of the arc */
  70355. endPoint: Vector2;
  70356. /**
  70357. * Defines the center point of the arc.
  70358. */
  70359. centerPoint: Vector2;
  70360. /**
  70361. * Defines the radius of the arc.
  70362. */
  70363. radius: number;
  70364. /**
  70365. * Defines the angle of the arc (from mid point to end point).
  70366. */
  70367. angle: Angle;
  70368. /**
  70369. * Defines the start angle of the arc (from start point to middle point).
  70370. */
  70371. startAngle: Angle;
  70372. /**
  70373. * Defines the orientation of the arc (clock wise/counter clock wise).
  70374. */
  70375. orientation: Orientation;
  70376. /**
  70377. * Creates an Arc object from the three given points : start, middle and end.
  70378. * @param startPoint Defines the start point of the arc
  70379. * @param midPoint Defines the midlle point of the arc
  70380. * @param endPoint Defines the end point of the arc
  70381. */
  70382. constructor(
  70383. /** Defines the start point of the arc */
  70384. startPoint: Vector2,
  70385. /** Defines the mid point of the arc */
  70386. midPoint: Vector2,
  70387. /** Defines the end point of the arc */
  70388. endPoint: Vector2);
  70389. }
  70390. /**
  70391. * Represents a 2D path made up of multiple 2D points
  70392. */
  70393. export class Path2 {
  70394. private _points;
  70395. private _length;
  70396. /**
  70397. * If the path start and end point are the same
  70398. */
  70399. closed: boolean;
  70400. /**
  70401. * Creates a Path2 object from the starting 2D coordinates x and y.
  70402. * @param x the starting points x value
  70403. * @param y the starting points y value
  70404. */
  70405. constructor(x: number, y: number);
  70406. /**
  70407. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70408. * @param x the added points x value
  70409. * @param y the added points y value
  70410. * @returns the updated Path2.
  70411. */
  70412. addLineTo(x: number, y: number): Path2;
  70413. /**
  70414. * 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.
  70415. * @param midX middle point x value
  70416. * @param midY middle point y value
  70417. * @param endX end point x value
  70418. * @param endY end point y value
  70419. * @param numberOfSegments (default: 36)
  70420. * @returns the updated Path2.
  70421. */
  70422. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70423. /**
  70424. * Closes the Path2.
  70425. * @returns the Path2.
  70426. */
  70427. close(): Path2;
  70428. /**
  70429. * Gets the sum of the distance between each sequential point in the path
  70430. * @returns the Path2 total length (float).
  70431. */
  70432. length(): number;
  70433. /**
  70434. * Gets the points which construct the path
  70435. * @returns the Path2 internal array of points.
  70436. */
  70437. getPoints(): Vector2[];
  70438. /**
  70439. * Retreives the point at the distance aways from the starting point
  70440. * @param normalizedLengthPosition the length along the path to retreive the point from
  70441. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70442. */
  70443. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70444. /**
  70445. * Creates a new path starting from an x and y position
  70446. * @param x starting x value
  70447. * @param y starting y value
  70448. * @returns a new Path2 starting at the coordinates (x, y).
  70449. */
  70450. static StartingAt(x: number, y: number): Path2;
  70451. }
  70452. /**
  70453. * Represents a 3D path made up of multiple 3D points
  70454. */
  70455. export class Path3D {
  70456. /**
  70457. * an array of Vector3, the curve axis of the Path3D
  70458. */
  70459. path: Vector3[];
  70460. private _curve;
  70461. private _distances;
  70462. private _tangents;
  70463. private _normals;
  70464. private _binormals;
  70465. private _raw;
  70466. /**
  70467. * new Path3D(path, normal, raw)
  70468. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70469. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70470. * @param path an array of Vector3, the curve axis of the Path3D
  70471. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70472. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70473. */
  70474. constructor(
  70475. /**
  70476. * an array of Vector3, the curve axis of the Path3D
  70477. */
  70478. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70479. /**
  70480. * Returns the Path3D array of successive Vector3 designing its curve.
  70481. * @returns the Path3D array of successive Vector3 designing its curve.
  70482. */
  70483. getCurve(): Vector3[];
  70484. /**
  70485. * Returns an array populated with tangent vectors on each Path3D curve point.
  70486. * @returns an array populated with tangent vectors on each Path3D curve point.
  70487. */
  70488. getTangents(): Vector3[];
  70489. /**
  70490. * Returns an array populated with normal vectors on each Path3D curve point.
  70491. * @returns an array populated with normal vectors on each Path3D curve point.
  70492. */
  70493. getNormals(): Vector3[];
  70494. /**
  70495. * Returns an array populated with binormal vectors on each Path3D curve point.
  70496. * @returns an array populated with binormal vectors on each Path3D curve point.
  70497. */
  70498. getBinormals(): Vector3[];
  70499. /**
  70500. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70501. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70502. */
  70503. getDistances(): number[];
  70504. /**
  70505. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70506. * @param path path which all values are copied into the curves points
  70507. * @param firstNormal which should be projected onto the curve
  70508. * @returns the same object updated.
  70509. */
  70510. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70511. private _compute;
  70512. private _getFirstNonNullVector;
  70513. private _getLastNonNullVector;
  70514. private _normalVector;
  70515. }
  70516. /**
  70517. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70518. * A Curve3 is designed from a series of successive Vector3.
  70519. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70520. */
  70521. export class Curve3 {
  70522. private _points;
  70523. private _length;
  70524. /**
  70525. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70526. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70527. * @param v1 (Vector3) the control point
  70528. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70529. * @param nbPoints (integer) the wanted number of points in the curve
  70530. * @returns the created Curve3
  70531. */
  70532. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70533. /**
  70534. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70535. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70536. * @param v1 (Vector3) the first control point
  70537. * @param v2 (Vector3) the second control point
  70538. * @param v3 (Vector3) the end point of the Cubic Bezier
  70539. * @param nbPoints (integer) the wanted number of points in the curve
  70540. * @returns the created Curve3
  70541. */
  70542. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70543. /**
  70544. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70545. * @param p1 (Vector3) the origin point of the Hermite Spline
  70546. * @param t1 (Vector3) the tangent vector at the origin point
  70547. * @param p2 (Vector3) the end point of the Hermite Spline
  70548. * @param t2 (Vector3) the tangent vector at the end point
  70549. * @param nbPoints (integer) the wanted number of points in the curve
  70550. * @returns the created Curve3
  70551. */
  70552. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70553. /**
  70554. * Returns a Curve3 object along a CatmullRom Spline curve :
  70555. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70556. * @param nbPoints (integer) the wanted number of points between each curve control points
  70557. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70558. * @returns the created Curve3
  70559. */
  70560. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70561. /**
  70562. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70563. * A Curve3 is designed from a series of successive Vector3.
  70564. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70565. * @param points points which make up the curve
  70566. */
  70567. constructor(points: Vector3[]);
  70568. /**
  70569. * @returns the Curve3 stored array of successive Vector3
  70570. */
  70571. getPoints(): Vector3[];
  70572. /**
  70573. * @returns the computed length (float) of the curve.
  70574. */
  70575. length(): number;
  70576. /**
  70577. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70578. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70579. * curveA and curveB keep unchanged.
  70580. * @param curve the curve to continue from this curve
  70581. * @returns the newly constructed curve
  70582. */
  70583. continue(curve: DeepImmutable<Curve3>): Curve3;
  70584. private _computeLength;
  70585. }
  70586. }
  70587. declare module BABYLON {
  70588. /**
  70589. * This represents the main contract an easing function should follow.
  70590. * Easing functions are used throughout the animation system.
  70591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70592. */
  70593. export interface IEasingFunction {
  70594. /**
  70595. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70596. * of the easing function.
  70597. * The link below provides some of the most common examples of easing functions.
  70598. * @see https://easings.net/
  70599. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70600. * @returns the corresponding value on the curve defined by the easing function
  70601. */
  70602. ease(gradient: number): number;
  70603. }
  70604. /**
  70605. * Base class used for every default easing function.
  70606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70607. */
  70608. export class EasingFunction implements IEasingFunction {
  70609. /**
  70610. * Interpolation follows the mathematical formula associated with the easing function.
  70611. */
  70612. static readonly EASINGMODE_EASEIN: number;
  70613. /**
  70614. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70615. */
  70616. static readonly EASINGMODE_EASEOUT: number;
  70617. /**
  70618. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70619. */
  70620. static readonly EASINGMODE_EASEINOUT: number;
  70621. private _easingMode;
  70622. /**
  70623. * Sets the easing mode of the current function.
  70624. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70625. */
  70626. setEasingMode(easingMode: number): void;
  70627. /**
  70628. * Gets the current easing mode.
  70629. * @returns the easing mode
  70630. */
  70631. getEasingMode(): number;
  70632. /**
  70633. * @hidden
  70634. */
  70635. easeInCore(gradient: number): number;
  70636. /**
  70637. * Given an input gradient between 0 and 1, this returns the corresponding value
  70638. * of the easing function.
  70639. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70640. * @returns the corresponding value on the curve defined by the easing function
  70641. */
  70642. ease(gradient: number): number;
  70643. }
  70644. /**
  70645. * Easing function with a circle shape (see link below).
  70646. * @see https://easings.net/#easeInCirc
  70647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70648. */
  70649. export class CircleEase extends EasingFunction implements IEasingFunction {
  70650. /** @hidden */
  70651. easeInCore(gradient: number): number;
  70652. }
  70653. /**
  70654. * Easing function with a ease back shape (see link below).
  70655. * @see https://easings.net/#easeInBack
  70656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70657. */
  70658. export class BackEase extends EasingFunction implements IEasingFunction {
  70659. /** Defines the amplitude of the function */
  70660. amplitude: number;
  70661. /**
  70662. * Instantiates a back ease easing
  70663. * @see https://easings.net/#easeInBack
  70664. * @param amplitude Defines the amplitude of the function
  70665. */
  70666. constructor(
  70667. /** Defines the amplitude of the function */
  70668. amplitude?: number);
  70669. /** @hidden */
  70670. easeInCore(gradient: number): number;
  70671. }
  70672. /**
  70673. * Easing function with a bouncing shape (see link below).
  70674. * @see https://easings.net/#easeInBounce
  70675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70676. */
  70677. export class BounceEase extends EasingFunction implements IEasingFunction {
  70678. /** Defines the number of bounces */
  70679. bounces: number;
  70680. /** Defines the amplitude of the bounce */
  70681. bounciness: number;
  70682. /**
  70683. * Instantiates a bounce easing
  70684. * @see https://easings.net/#easeInBounce
  70685. * @param bounces Defines the number of bounces
  70686. * @param bounciness Defines the amplitude of the bounce
  70687. */
  70688. constructor(
  70689. /** Defines the number of bounces */
  70690. bounces?: number,
  70691. /** Defines the amplitude of the bounce */
  70692. bounciness?: number);
  70693. /** @hidden */
  70694. easeInCore(gradient: number): number;
  70695. }
  70696. /**
  70697. * Easing function with a power of 3 shape (see link below).
  70698. * @see https://easings.net/#easeInCubic
  70699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70700. */
  70701. export class CubicEase extends EasingFunction implements IEasingFunction {
  70702. /** @hidden */
  70703. easeInCore(gradient: number): number;
  70704. }
  70705. /**
  70706. * Easing function with an elastic shape (see link below).
  70707. * @see https://easings.net/#easeInElastic
  70708. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70709. */
  70710. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70711. /** Defines the number of oscillations*/
  70712. oscillations: number;
  70713. /** Defines the amplitude of the oscillations*/
  70714. springiness: number;
  70715. /**
  70716. * Instantiates an elastic easing function
  70717. * @see https://easings.net/#easeInElastic
  70718. * @param oscillations Defines the number of oscillations
  70719. * @param springiness Defines the amplitude of the oscillations
  70720. */
  70721. constructor(
  70722. /** Defines the number of oscillations*/
  70723. oscillations?: number,
  70724. /** Defines the amplitude of the oscillations*/
  70725. springiness?: number);
  70726. /** @hidden */
  70727. easeInCore(gradient: number): number;
  70728. }
  70729. /**
  70730. * Easing function with an exponential shape (see link below).
  70731. * @see https://easings.net/#easeInExpo
  70732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70733. */
  70734. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70735. /** Defines the exponent of the function */
  70736. exponent: number;
  70737. /**
  70738. * Instantiates an exponential easing function
  70739. * @see https://easings.net/#easeInExpo
  70740. * @param exponent Defines the exponent of the function
  70741. */
  70742. constructor(
  70743. /** Defines the exponent of the function */
  70744. exponent?: number);
  70745. /** @hidden */
  70746. easeInCore(gradient: number): number;
  70747. }
  70748. /**
  70749. * Easing function with a power shape (see link below).
  70750. * @see https://easings.net/#easeInQuad
  70751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70752. */
  70753. export class PowerEase extends EasingFunction implements IEasingFunction {
  70754. /** Defines the power of the function */
  70755. power: number;
  70756. /**
  70757. * Instantiates an power base easing function
  70758. * @see https://easings.net/#easeInQuad
  70759. * @param power Defines the power of the function
  70760. */
  70761. constructor(
  70762. /** Defines the power of the function */
  70763. power?: number);
  70764. /** @hidden */
  70765. easeInCore(gradient: number): number;
  70766. }
  70767. /**
  70768. * Easing function with a power of 2 shape (see link below).
  70769. * @see https://easings.net/#easeInQuad
  70770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70771. */
  70772. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70773. /** @hidden */
  70774. easeInCore(gradient: number): number;
  70775. }
  70776. /**
  70777. * Easing function with a power of 4 shape (see link below).
  70778. * @see https://easings.net/#easeInQuart
  70779. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70780. */
  70781. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70782. /** @hidden */
  70783. easeInCore(gradient: number): number;
  70784. }
  70785. /**
  70786. * Easing function with a power of 5 shape (see link below).
  70787. * @see https://easings.net/#easeInQuint
  70788. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70789. */
  70790. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70791. /** @hidden */
  70792. easeInCore(gradient: number): number;
  70793. }
  70794. /**
  70795. * Easing function with a sin shape (see link below).
  70796. * @see https://easings.net/#easeInSine
  70797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70798. */
  70799. export class SineEase extends EasingFunction implements IEasingFunction {
  70800. /** @hidden */
  70801. easeInCore(gradient: number): number;
  70802. }
  70803. /**
  70804. * Easing function with a bezier shape (see link below).
  70805. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70807. */
  70808. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70809. /** Defines the x component of the start tangent in the bezier curve */
  70810. x1: number;
  70811. /** Defines the y component of the start tangent in the bezier curve */
  70812. y1: number;
  70813. /** Defines the x component of the end tangent in the bezier curve */
  70814. x2: number;
  70815. /** Defines the y component of the end tangent in the bezier curve */
  70816. y2: number;
  70817. /**
  70818. * Instantiates a bezier function
  70819. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70820. * @param x1 Defines the x component of the start tangent in the bezier curve
  70821. * @param y1 Defines the y component of the start tangent in the bezier curve
  70822. * @param x2 Defines the x component of the end tangent in the bezier curve
  70823. * @param y2 Defines the y component of the end tangent in the bezier curve
  70824. */
  70825. constructor(
  70826. /** Defines the x component of the start tangent in the bezier curve */
  70827. x1?: number,
  70828. /** Defines the y component of the start tangent in the bezier curve */
  70829. y1?: number,
  70830. /** Defines the x component of the end tangent in the bezier curve */
  70831. x2?: number,
  70832. /** Defines the y component of the end tangent in the bezier curve */
  70833. y2?: number);
  70834. /** @hidden */
  70835. easeInCore(gradient: number): number;
  70836. }
  70837. }
  70838. declare module BABYLON {
  70839. /**
  70840. * Defines an interface which represents an animation key frame
  70841. */
  70842. export interface IAnimationKey {
  70843. /**
  70844. * Frame of the key frame
  70845. */
  70846. frame: number;
  70847. /**
  70848. * Value at the specifies key frame
  70849. */
  70850. value: any;
  70851. /**
  70852. * The input tangent for the cubic hermite spline
  70853. */
  70854. inTangent?: any;
  70855. /**
  70856. * The output tangent for the cubic hermite spline
  70857. */
  70858. outTangent?: any;
  70859. /**
  70860. * The animation interpolation type
  70861. */
  70862. interpolation?: AnimationKeyInterpolation;
  70863. }
  70864. /**
  70865. * Enum for the animation key frame interpolation type
  70866. */
  70867. export enum AnimationKeyInterpolation {
  70868. /**
  70869. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70870. */
  70871. STEP = 1
  70872. }
  70873. }
  70874. declare module BABYLON {
  70875. /**
  70876. * Represents the range of an animation
  70877. */
  70878. export class AnimationRange {
  70879. /**The name of the animation range**/
  70880. name: string;
  70881. /**The starting frame of the animation */
  70882. from: number;
  70883. /**The ending frame of the animation*/
  70884. to: number;
  70885. /**
  70886. * Initializes the range of an animation
  70887. * @param name The name of the animation range
  70888. * @param from The starting frame of the animation
  70889. * @param to The ending frame of the animation
  70890. */
  70891. constructor(
  70892. /**The name of the animation range**/
  70893. name: string,
  70894. /**The starting frame of the animation */
  70895. from: number,
  70896. /**The ending frame of the animation*/
  70897. to: number);
  70898. /**
  70899. * Makes a copy of the animation range
  70900. * @returns A copy of the animation range
  70901. */
  70902. clone(): AnimationRange;
  70903. }
  70904. }
  70905. declare module BABYLON {
  70906. /**
  70907. * Composed of a frame, and an action function
  70908. */
  70909. export class AnimationEvent {
  70910. /** The frame for which the event is triggered **/
  70911. frame: number;
  70912. /** The event to perform when triggered **/
  70913. action: (currentFrame: number) => void;
  70914. /** Specifies if the event should be triggered only once**/
  70915. onlyOnce?: boolean | undefined;
  70916. /**
  70917. * Specifies if the animation event is done
  70918. */
  70919. isDone: boolean;
  70920. /**
  70921. * Initializes the animation event
  70922. * @param frame The frame for which the event is triggered
  70923. * @param action The event to perform when triggered
  70924. * @param onlyOnce Specifies if the event should be triggered only once
  70925. */
  70926. constructor(
  70927. /** The frame for which the event is triggered **/
  70928. frame: number,
  70929. /** The event to perform when triggered **/
  70930. action: (currentFrame: number) => void,
  70931. /** Specifies if the event should be triggered only once**/
  70932. onlyOnce?: boolean | undefined);
  70933. /** @hidden */
  70934. _clone(): AnimationEvent;
  70935. }
  70936. }
  70937. declare module BABYLON {
  70938. /**
  70939. * Interface used to define a behavior
  70940. */
  70941. export interface Behavior<T> {
  70942. /** gets or sets behavior's name */
  70943. name: string;
  70944. /**
  70945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70946. */
  70947. init(): void;
  70948. /**
  70949. * Called when the behavior is attached to a target
  70950. * @param target defines the target where the behavior is attached to
  70951. */
  70952. attach(target: T): void;
  70953. /**
  70954. * Called when the behavior is detached from its target
  70955. */
  70956. detach(): void;
  70957. }
  70958. /**
  70959. * Interface implemented by classes supporting behaviors
  70960. */
  70961. export interface IBehaviorAware<T> {
  70962. /**
  70963. * Attach a behavior
  70964. * @param behavior defines the behavior to attach
  70965. * @returns the current host
  70966. */
  70967. addBehavior(behavior: Behavior<T>): T;
  70968. /**
  70969. * Remove a behavior from the current object
  70970. * @param behavior defines the behavior to detach
  70971. * @returns the current host
  70972. */
  70973. removeBehavior(behavior: Behavior<T>): T;
  70974. /**
  70975. * Gets a behavior using its name to search
  70976. * @param name defines the name to search
  70977. * @returns the behavior or null if not found
  70978. */
  70979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70980. }
  70981. }
  70982. declare module BABYLON {
  70983. /**
  70984. * Defines an array and its length.
  70985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70986. */
  70987. export interface ISmartArrayLike<T> {
  70988. /**
  70989. * The data of the array.
  70990. */
  70991. data: Array<T>;
  70992. /**
  70993. * The active length of the array.
  70994. */
  70995. length: number;
  70996. }
  70997. /**
  70998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70999. */
  71000. export class SmartArray<T> implements ISmartArrayLike<T> {
  71001. /**
  71002. * The full set of data from the array.
  71003. */
  71004. data: Array<T>;
  71005. /**
  71006. * The active length of the array.
  71007. */
  71008. length: number;
  71009. protected _id: number;
  71010. /**
  71011. * Instantiates a Smart Array.
  71012. * @param capacity defines the default capacity of the array.
  71013. */
  71014. constructor(capacity: number);
  71015. /**
  71016. * Pushes a value at the end of the active data.
  71017. * @param value defines the object to push in the array.
  71018. */
  71019. push(value: T): void;
  71020. /**
  71021. * Iterates over the active data and apply the lambda to them.
  71022. * @param func defines the action to apply on each value.
  71023. */
  71024. forEach(func: (content: T) => void): void;
  71025. /**
  71026. * Sorts the full sets of data.
  71027. * @param compareFn defines the comparison function to apply.
  71028. */
  71029. sort(compareFn: (a: T, b: T) => number): void;
  71030. /**
  71031. * Resets the active data to an empty array.
  71032. */
  71033. reset(): void;
  71034. /**
  71035. * Releases all the data from the array as well as the array.
  71036. */
  71037. dispose(): void;
  71038. /**
  71039. * Concats the active data with a given array.
  71040. * @param array defines the data to concatenate with.
  71041. */
  71042. concat(array: any): void;
  71043. /**
  71044. * Returns the position of a value in the active data.
  71045. * @param value defines the value to find the index for
  71046. * @returns the index if found in the active data otherwise -1
  71047. */
  71048. indexOf(value: T): number;
  71049. /**
  71050. * Returns whether an element is part of the active data.
  71051. * @param value defines the value to look for
  71052. * @returns true if found in the active data otherwise false
  71053. */
  71054. contains(value: T): boolean;
  71055. private static _GlobalId;
  71056. }
  71057. /**
  71058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71059. * The data in this array can only be present once
  71060. */
  71061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71062. private _duplicateId;
  71063. /**
  71064. * Pushes a value at the end of the active data.
  71065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71066. * @param value defines the object to push in the array.
  71067. */
  71068. push(value: T): void;
  71069. /**
  71070. * Pushes a value at the end of the active data.
  71071. * If the data is already present, it won t be added again
  71072. * @param value defines the object to push in the array.
  71073. * @returns true if added false if it was already present
  71074. */
  71075. pushNoDuplicate(value: T): boolean;
  71076. /**
  71077. * Resets the active data to an empty array.
  71078. */
  71079. reset(): void;
  71080. /**
  71081. * Concats the active data with a given array.
  71082. * This ensures no dupplicate will be present in the result.
  71083. * @param array defines the data to concatenate with.
  71084. */
  71085. concatWithNoDuplicate(array: any): void;
  71086. }
  71087. }
  71088. declare module BABYLON {
  71089. /**
  71090. * @ignore
  71091. * This is a list of all the different input types that are available in the application.
  71092. * Fo instance: ArcRotateCameraGamepadInput...
  71093. */
  71094. export var CameraInputTypes: {};
  71095. /**
  71096. * This is the contract to implement in order to create a new input class.
  71097. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71098. */
  71099. export interface ICameraInput<TCamera extends Camera> {
  71100. /**
  71101. * Defines the camera the input is attached to.
  71102. */
  71103. camera: Nullable<TCamera>;
  71104. /**
  71105. * Gets the class name of the current intput.
  71106. * @returns the class name
  71107. */
  71108. getClassName(): string;
  71109. /**
  71110. * Get the friendly name associated with the input class.
  71111. * @returns the input friendly name
  71112. */
  71113. getSimpleName(): string;
  71114. /**
  71115. * Attach the input controls to a specific dom element to get the input from.
  71116. * @param element Defines the element the controls should be listened from
  71117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71118. */
  71119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71120. /**
  71121. * Detach the current controls from the specified dom element.
  71122. * @param element Defines the element to stop listening the inputs from
  71123. */
  71124. detachControl(element: Nullable<HTMLElement>): void;
  71125. /**
  71126. * Update the current camera state depending on the inputs that have been used this frame.
  71127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71128. */
  71129. checkInputs?: () => void;
  71130. }
  71131. /**
  71132. * Represents a map of input types to input instance or input index to input instance.
  71133. */
  71134. export interface CameraInputsMap<TCamera extends Camera> {
  71135. /**
  71136. * Accessor to the input by input type.
  71137. */
  71138. [name: string]: ICameraInput<TCamera>;
  71139. /**
  71140. * Accessor to the input by input index.
  71141. */
  71142. [idx: number]: ICameraInput<TCamera>;
  71143. }
  71144. /**
  71145. * This represents the input manager used within a camera.
  71146. * It helps dealing with all the different kind of input attached to a camera.
  71147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71148. */
  71149. export class CameraInputsManager<TCamera extends Camera> {
  71150. /**
  71151. * Defines the list of inputs attahed to the camera.
  71152. */
  71153. attached: CameraInputsMap<TCamera>;
  71154. /**
  71155. * Defines the dom element the camera is collecting inputs from.
  71156. * This is null if the controls have not been attached.
  71157. */
  71158. attachedElement: Nullable<HTMLElement>;
  71159. /**
  71160. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71161. */
  71162. noPreventDefault: boolean;
  71163. /**
  71164. * Defined the camera the input manager belongs to.
  71165. */
  71166. camera: TCamera;
  71167. /**
  71168. * Update the current camera state depending on the inputs that have been used this frame.
  71169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71170. */
  71171. checkInputs: () => void;
  71172. /**
  71173. * Instantiate a new Camera Input Manager.
  71174. * @param camera Defines the camera the input manager blongs to
  71175. */
  71176. constructor(camera: TCamera);
  71177. /**
  71178. * Add an input method to a camera
  71179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71180. * @param input camera input method
  71181. */
  71182. add(input: ICameraInput<TCamera>): void;
  71183. /**
  71184. * Remove a specific input method from a camera
  71185. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71186. * @param inputToRemove camera input method
  71187. */
  71188. remove(inputToRemove: ICameraInput<TCamera>): void;
  71189. /**
  71190. * Remove a specific input type from a camera
  71191. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71192. * @param inputType the type of the input to remove
  71193. */
  71194. removeByType(inputType: string): void;
  71195. private _addCheckInputs;
  71196. /**
  71197. * Attach the input controls to the currently attached dom element to listen the events from.
  71198. * @param input Defines the input to attach
  71199. */
  71200. attachInput(input: ICameraInput<TCamera>): void;
  71201. /**
  71202. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71203. * @param element Defines the dom element to collect the events from
  71204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71205. */
  71206. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71207. /**
  71208. * Detach the current manager inputs controls from a specific dom element.
  71209. * @param element Defines the dom element to collect the events from
  71210. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71211. */
  71212. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71213. /**
  71214. * Rebuild the dynamic inputCheck function from the current list of
  71215. * defined inputs in the manager.
  71216. */
  71217. rebuildInputCheck(): void;
  71218. /**
  71219. * Remove all attached input methods from a camera
  71220. */
  71221. clear(): void;
  71222. /**
  71223. * Serialize the current input manager attached to a camera.
  71224. * This ensures than once parsed,
  71225. * the input associated to the camera will be identical to the current ones
  71226. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71227. */
  71228. serialize(serializedCamera: any): void;
  71229. /**
  71230. * Parses an input manager serialized JSON to restore the previous list of inputs
  71231. * and states associated to a camera.
  71232. * @param parsedCamera Defines the JSON to parse
  71233. */
  71234. parse(parsedCamera: any): void;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * @hidden
  71240. */
  71241. export class IntersectionInfo {
  71242. bu: Nullable<number>;
  71243. bv: Nullable<number>;
  71244. distance: number;
  71245. faceId: number;
  71246. subMeshId: number;
  71247. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71248. }
  71249. }
  71250. declare module BABYLON {
  71251. /**
  71252. * Represens a plane by the equation ax + by + cz + d = 0
  71253. */
  71254. export class Plane {
  71255. private static _TmpMatrix;
  71256. /**
  71257. * Normal of the plane (a,b,c)
  71258. */
  71259. normal: Vector3;
  71260. /**
  71261. * d component of the plane
  71262. */
  71263. d: number;
  71264. /**
  71265. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71266. * @param a a component of the plane
  71267. * @param b b component of the plane
  71268. * @param c c component of the plane
  71269. * @param d d component of the plane
  71270. */
  71271. constructor(a: number, b: number, c: number, d: number);
  71272. /**
  71273. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71274. */
  71275. asArray(): number[];
  71276. /**
  71277. * @returns a new plane copied from the current Plane.
  71278. */
  71279. clone(): Plane;
  71280. /**
  71281. * @returns the string "Plane".
  71282. */
  71283. getClassName(): string;
  71284. /**
  71285. * @returns the Plane hash code.
  71286. */
  71287. getHashCode(): number;
  71288. /**
  71289. * Normalize the current Plane in place.
  71290. * @returns the updated Plane.
  71291. */
  71292. normalize(): Plane;
  71293. /**
  71294. * Applies a transformation the plane and returns the result
  71295. * @param transformation the transformation matrix to be applied to the plane
  71296. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71297. */
  71298. transform(transformation: DeepImmutable<Matrix>): Plane;
  71299. /**
  71300. * Calcualtte the dot product between the point and the plane normal
  71301. * @param point point to calculate the dot product with
  71302. * @returns the dot product (float) of the point coordinates and the plane normal.
  71303. */
  71304. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71305. /**
  71306. * Updates the current Plane from the plane defined by the three given points.
  71307. * @param point1 one of the points used to contruct the plane
  71308. * @param point2 one of the points used to contruct the plane
  71309. * @param point3 one of the points used to contruct the plane
  71310. * @returns the updated Plane.
  71311. */
  71312. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71313. /**
  71314. * Checks if the plane is facing a given direction
  71315. * @param direction the direction to check if the plane is facing
  71316. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71317. * @returns True is the vector "direction" is the same side than the plane normal.
  71318. */
  71319. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71320. /**
  71321. * Calculates the distance to a point
  71322. * @param point point to calculate distance to
  71323. * @returns the signed distance (float) from the given point to the Plane.
  71324. */
  71325. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71326. /**
  71327. * Creates a plane from an array
  71328. * @param array the array to create a plane from
  71329. * @returns a new Plane from the given array.
  71330. */
  71331. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71332. /**
  71333. * Creates a plane from three points
  71334. * @param point1 point used to create the plane
  71335. * @param point2 point used to create the plane
  71336. * @param point3 point used to create the plane
  71337. * @returns a new Plane defined by the three given points.
  71338. */
  71339. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71340. /**
  71341. * Creates a plane from an origin point and a normal
  71342. * @param origin origin of the plane to be constructed
  71343. * @param normal normal of the plane to be constructed
  71344. * @returns a new Plane the normal vector to this plane at the given origin point.
  71345. * Note : the vector "normal" is updated because normalized.
  71346. */
  71347. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71348. /**
  71349. * Calculates the distance from a plane and a point
  71350. * @param origin origin of the plane to be constructed
  71351. * @param normal normal of the plane to be constructed
  71352. * @param point point to calculate distance to
  71353. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71354. */
  71355. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71356. }
  71357. }
  71358. declare module BABYLON {
  71359. /**
  71360. * Class used to store bounding sphere information
  71361. */
  71362. export class BoundingSphere {
  71363. /**
  71364. * Gets the center of the bounding sphere in local space
  71365. */
  71366. readonly center: Vector3;
  71367. /**
  71368. * Radius of the bounding sphere in local space
  71369. */
  71370. radius: number;
  71371. /**
  71372. * Gets the center of the bounding sphere in world space
  71373. */
  71374. readonly centerWorld: Vector3;
  71375. /**
  71376. * Radius of the bounding sphere in world space
  71377. */
  71378. radiusWorld: number;
  71379. /**
  71380. * Gets the minimum vector in local space
  71381. */
  71382. readonly minimum: Vector3;
  71383. /**
  71384. * Gets the maximum vector in local space
  71385. */
  71386. readonly maximum: Vector3;
  71387. private _worldMatrix;
  71388. private static readonly TmpVector3;
  71389. /**
  71390. * Creates a new bounding sphere
  71391. * @param min defines the minimum vector (in local space)
  71392. * @param max defines the maximum vector (in local space)
  71393. * @param worldMatrix defines the new world matrix
  71394. */
  71395. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71396. /**
  71397. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71398. * @param min defines the new minimum vector (in local space)
  71399. * @param max defines the new maximum vector (in local space)
  71400. * @param worldMatrix defines the new world matrix
  71401. */
  71402. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71403. /**
  71404. * Scale the current bounding sphere by applying a scale factor
  71405. * @param factor defines the scale factor to apply
  71406. * @returns the current bounding box
  71407. */
  71408. scale(factor: number): BoundingSphere;
  71409. /**
  71410. * Gets the world matrix of the bounding box
  71411. * @returns a matrix
  71412. */
  71413. getWorldMatrix(): DeepImmutable<Matrix>;
  71414. /** @hidden */
  71415. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71416. /**
  71417. * Tests if the bounding sphere is intersecting the frustum planes
  71418. * @param frustumPlanes defines the frustum planes to test
  71419. * @returns true if there is an intersection
  71420. */
  71421. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71422. /**
  71423. * Tests if the bounding sphere center is in between the frustum planes.
  71424. * Used for optimistic fast inclusion.
  71425. * @param frustumPlanes defines the frustum planes to test
  71426. * @returns true if the sphere center is in between the frustum planes
  71427. */
  71428. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71429. /**
  71430. * Tests if a point is inside the bounding sphere
  71431. * @param point defines the point to test
  71432. * @returns true if the point is inside the bounding sphere
  71433. */
  71434. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71435. /**
  71436. * Checks if two sphere intersct
  71437. * @param sphere0 sphere 0
  71438. * @param sphere1 sphere 1
  71439. * @returns true if the speres intersect
  71440. */
  71441. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71442. }
  71443. }
  71444. declare module BABYLON {
  71445. /**
  71446. * Class used to store bounding box information
  71447. */
  71448. export class BoundingBox implements ICullable {
  71449. /**
  71450. * Gets the 8 vectors representing the bounding box in local space
  71451. */
  71452. readonly vectors: Vector3[];
  71453. /**
  71454. * Gets the center of the bounding box in local space
  71455. */
  71456. readonly center: Vector3;
  71457. /**
  71458. * Gets the center of the bounding box in world space
  71459. */
  71460. readonly centerWorld: Vector3;
  71461. /**
  71462. * Gets the extend size in local space
  71463. */
  71464. readonly extendSize: Vector3;
  71465. /**
  71466. * Gets the extend size in world space
  71467. */
  71468. readonly extendSizeWorld: Vector3;
  71469. /**
  71470. * Gets the OBB (object bounding box) directions
  71471. */
  71472. readonly directions: Vector3[];
  71473. /**
  71474. * Gets the 8 vectors representing the bounding box in world space
  71475. */
  71476. readonly vectorsWorld: Vector3[];
  71477. /**
  71478. * Gets the minimum vector in world space
  71479. */
  71480. readonly minimumWorld: Vector3;
  71481. /**
  71482. * Gets the maximum vector in world space
  71483. */
  71484. readonly maximumWorld: Vector3;
  71485. /**
  71486. * Gets the minimum vector in local space
  71487. */
  71488. readonly minimum: Vector3;
  71489. /**
  71490. * Gets the maximum vector in local space
  71491. */
  71492. readonly maximum: Vector3;
  71493. private _worldMatrix;
  71494. private static readonly TmpVector3;
  71495. /**
  71496. * @hidden
  71497. */
  71498. _tag: number;
  71499. /**
  71500. * Creates a new bounding box
  71501. * @param min defines the minimum vector (in local space)
  71502. * @param max defines the maximum vector (in local space)
  71503. * @param worldMatrix defines the new world matrix
  71504. */
  71505. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71506. /**
  71507. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71508. * @param min defines the new minimum vector (in local space)
  71509. * @param max defines the new maximum vector (in local space)
  71510. * @param worldMatrix defines the new world matrix
  71511. */
  71512. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71513. /**
  71514. * Scale the current bounding box by applying a scale factor
  71515. * @param factor defines the scale factor to apply
  71516. * @returns the current bounding box
  71517. */
  71518. scale(factor: number): BoundingBox;
  71519. /**
  71520. * Gets the world matrix of the bounding box
  71521. * @returns a matrix
  71522. */
  71523. getWorldMatrix(): DeepImmutable<Matrix>;
  71524. /** @hidden */
  71525. _update(world: DeepImmutable<Matrix>): void;
  71526. /**
  71527. * Tests if the bounding box is intersecting the frustum planes
  71528. * @param frustumPlanes defines the frustum planes to test
  71529. * @returns true if there is an intersection
  71530. */
  71531. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71532. /**
  71533. * Tests if the bounding box is entirely inside the frustum planes
  71534. * @param frustumPlanes defines the frustum planes to test
  71535. * @returns true if there is an inclusion
  71536. */
  71537. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71538. /**
  71539. * Tests if a point is inside the bounding box
  71540. * @param point defines the point to test
  71541. * @returns true if the point is inside the bounding box
  71542. */
  71543. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71544. /**
  71545. * Tests if the bounding box intersects with a bounding sphere
  71546. * @param sphere defines the sphere to test
  71547. * @returns true if there is an intersection
  71548. */
  71549. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71550. /**
  71551. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71552. * @param min defines the min vector to use
  71553. * @param max defines the max vector to use
  71554. * @returns true if there is an intersection
  71555. */
  71556. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71557. /**
  71558. * Tests if two bounding boxes are intersections
  71559. * @param box0 defines the first box to test
  71560. * @param box1 defines the second box to test
  71561. * @returns true if there is an intersection
  71562. */
  71563. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71564. /**
  71565. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71566. * @param minPoint defines the minimum vector of the bounding box
  71567. * @param maxPoint defines the maximum vector of the bounding box
  71568. * @param sphereCenter defines the sphere center
  71569. * @param sphereRadius defines the sphere radius
  71570. * @returns true if there is an intersection
  71571. */
  71572. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71573. /**
  71574. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71575. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71576. * @param frustumPlanes defines the frustum planes to test
  71577. * @return true if there is an inclusion
  71578. */
  71579. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71580. /**
  71581. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71582. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71583. * @param frustumPlanes defines the frustum planes to test
  71584. * @return true if there is an intersection
  71585. */
  71586. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71587. }
  71588. }
  71589. declare module BABYLON {
  71590. /** @hidden */
  71591. export class Collider {
  71592. /** Define if a collision was found */
  71593. collisionFound: boolean;
  71594. /**
  71595. * Define last intersection point in local space
  71596. */
  71597. intersectionPoint: Vector3;
  71598. /**
  71599. * Define last collided mesh
  71600. */
  71601. collidedMesh: Nullable<AbstractMesh>;
  71602. private _collisionPoint;
  71603. private _planeIntersectionPoint;
  71604. private _tempVector;
  71605. private _tempVector2;
  71606. private _tempVector3;
  71607. private _tempVector4;
  71608. private _edge;
  71609. private _baseToVertex;
  71610. private _destinationPoint;
  71611. private _slidePlaneNormal;
  71612. private _displacementVector;
  71613. /** @hidden */
  71614. _radius: Vector3;
  71615. /** @hidden */
  71616. _retry: number;
  71617. private _velocity;
  71618. private _basePoint;
  71619. private _epsilon;
  71620. /** @hidden */
  71621. _velocityWorldLength: number;
  71622. /** @hidden */
  71623. _basePointWorld: Vector3;
  71624. private _velocityWorld;
  71625. private _normalizedVelocity;
  71626. /** @hidden */
  71627. _initialVelocity: Vector3;
  71628. /** @hidden */
  71629. _initialPosition: Vector3;
  71630. private _nearestDistance;
  71631. private _collisionMask;
  71632. collisionMask: number;
  71633. /**
  71634. * Gets the plane normal used to compute the sliding response (in local space)
  71635. */
  71636. readonly slidePlaneNormal: Vector3;
  71637. /** @hidden */
  71638. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71639. /** @hidden */
  71640. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71641. /** @hidden */
  71642. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71643. /** @hidden */
  71644. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71645. /** @hidden */
  71646. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71647. /** @hidden */
  71648. _getResponse(pos: Vector3, vel: Vector3): void;
  71649. }
  71650. }
  71651. declare module BABYLON {
  71652. /**
  71653. * Interface for cullable objects
  71654. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71655. */
  71656. export interface ICullable {
  71657. /**
  71658. * Checks if the object or part of the object is in the frustum
  71659. * @param frustumPlanes Camera near/planes
  71660. * @returns true if the object is in frustum otherwise false
  71661. */
  71662. isInFrustum(frustumPlanes: Plane[]): boolean;
  71663. /**
  71664. * Checks if a cullable object (mesh...) is in the camera frustum
  71665. * Unlike isInFrustum this cheks the full bounding box
  71666. * @param frustumPlanes Camera near/planes
  71667. * @returns true if the object is in frustum otherwise false
  71668. */
  71669. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71670. }
  71671. /**
  71672. * Info for a bounding data of a mesh
  71673. */
  71674. export class BoundingInfo implements ICullable {
  71675. /**
  71676. * Bounding box for the mesh
  71677. */
  71678. readonly boundingBox: BoundingBox;
  71679. /**
  71680. * Bounding sphere for the mesh
  71681. */
  71682. readonly boundingSphere: BoundingSphere;
  71683. private _isLocked;
  71684. private static readonly TmpVector3;
  71685. /**
  71686. * Constructs bounding info
  71687. * @param minimum min vector of the bounding box/sphere
  71688. * @param maximum max vector of the bounding box/sphere
  71689. * @param worldMatrix defines the new world matrix
  71690. */
  71691. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71692. /**
  71693. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71694. * @param min defines the new minimum vector (in local space)
  71695. * @param max defines the new maximum vector (in local space)
  71696. * @param worldMatrix defines the new world matrix
  71697. */
  71698. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71699. /**
  71700. * min vector of the bounding box/sphere
  71701. */
  71702. readonly minimum: Vector3;
  71703. /**
  71704. * max vector of the bounding box/sphere
  71705. */
  71706. readonly maximum: Vector3;
  71707. /**
  71708. * If the info is locked and won't be updated to avoid perf overhead
  71709. */
  71710. isLocked: boolean;
  71711. /**
  71712. * Updates the bounding sphere and box
  71713. * @param world world matrix to be used to update
  71714. */
  71715. update(world: DeepImmutable<Matrix>): void;
  71716. /**
  71717. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71718. * @param center New center of the bounding info
  71719. * @param extend New extend of the bounding info
  71720. * @returns the current bounding info
  71721. */
  71722. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71723. /**
  71724. * Scale the current bounding info by applying a scale factor
  71725. * @param factor defines the scale factor to apply
  71726. * @returns the current bounding info
  71727. */
  71728. scale(factor: number): BoundingInfo;
  71729. /**
  71730. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71731. * @param frustumPlanes defines the frustum to test
  71732. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71733. * @returns true if the bounding info is in the frustum planes
  71734. */
  71735. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71736. /**
  71737. * Gets the world distance between the min and max points of the bounding box
  71738. */
  71739. readonly diagonalLength: number;
  71740. /**
  71741. * Checks if a cullable object (mesh...) is in the camera frustum
  71742. * Unlike isInFrustum this cheks the full bounding box
  71743. * @param frustumPlanes Camera near/planes
  71744. * @returns true if the object is in frustum otherwise false
  71745. */
  71746. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71747. /** @hidden */
  71748. _checkCollision(collider: Collider): boolean;
  71749. /**
  71750. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71751. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71752. * @param point the point to check intersection with
  71753. * @returns if the point intersects
  71754. */
  71755. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71756. /**
  71757. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71758. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71759. * @param boundingInfo the bounding info to check intersection with
  71760. * @param precise if the intersection should be done using OBB
  71761. * @returns if the bounding info intersects
  71762. */
  71763. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71764. }
  71765. }
  71766. declare module BABYLON {
  71767. /**
  71768. * Extracts minimum and maximum values from a list of indexed positions
  71769. * @param positions defines the positions to use
  71770. * @param indices defines the indices to the positions
  71771. * @param indexStart defines the start index
  71772. * @param indexCount defines the end index
  71773. * @param bias defines bias value to add to the result
  71774. * @return minimum and maximum values
  71775. */
  71776. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71777. minimum: Vector3;
  71778. maximum: Vector3;
  71779. };
  71780. /**
  71781. * Extracts minimum and maximum values from a list of positions
  71782. * @param positions defines the positions to use
  71783. * @param start defines the start index in the positions array
  71784. * @param count defines the number of positions to handle
  71785. * @param bias defines bias value to add to the result
  71786. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71787. * @return minimum and maximum values
  71788. */
  71789. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71790. minimum: Vector3;
  71791. maximum: Vector3;
  71792. };
  71793. }
  71794. declare module BABYLON {
  71795. /**
  71796. * Enum that determines the text-wrapping mode to use.
  71797. */
  71798. export enum InspectableType {
  71799. /**
  71800. * Checkbox for booleans
  71801. */
  71802. Checkbox = 0,
  71803. /**
  71804. * Sliders for numbers
  71805. */
  71806. Slider = 1,
  71807. /**
  71808. * Vector3
  71809. */
  71810. Vector3 = 2,
  71811. /**
  71812. * Quaternions
  71813. */
  71814. Quaternion = 3,
  71815. /**
  71816. * Color3
  71817. */
  71818. Color3 = 4,
  71819. /**
  71820. * String
  71821. */
  71822. String = 5
  71823. }
  71824. /**
  71825. * Interface used to define custom inspectable properties.
  71826. * This interface is used by the inspector to display custom property grids
  71827. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71828. */
  71829. export interface IInspectable {
  71830. /**
  71831. * Gets the label to display
  71832. */
  71833. label: string;
  71834. /**
  71835. * Gets the name of the property to edit
  71836. */
  71837. propertyName: string;
  71838. /**
  71839. * Gets the type of the editor to use
  71840. */
  71841. type: InspectableType;
  71842. /**
  71843. * Gets the minimum value of the property when using in "slider" mode
  71844. */
  71845. min?: number;
  71846. /**
  71847. * Gets the maximum value of the property when using in "slider" mode
  71848. */
  71849. max?: number;
  71850. /**
  71851. * Gets the setp to use when using in "slider" mode
  71852. */
  71853. step?: number;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /**
  71858. * Class used to provide helper for timing
  71859. */
  71860. export class TimingTools {
  71861. /**
  71862. * Polyfill for setImmediate
  71863. * @param action defines the action to execute after the current execution block
  71864. */
  71865. static SetImmediate(action: () => void): void;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /**
  71870. * Class used to enable instatition of objects by class name
  71871. */
  71872. export class InstantiationTools {
  71873. /**
  71874. * Use this object to register external classes like custom textures or material
  71875. * to allow the laoders to instantiate them
  71876. */
  71877. static RegisteredExternalClasses: {
  71878. [key: string]: Object;
  71879. };
  71880. /**
  71881. * Tries to instantiate a new object from a given class name
  71882. * @param className defines the class name to instantiate
  71883. * @returns the new object or null if the system was not able to do the instantiation
  71884. */
  71885. static Instantiate(className: string): any;
  71886. }
  71887. }
  71888. declare module BABYLON {
  71889. /**
  71890. * This represents the required contract to create a new type of texture loader.
  71891. */
  71892. export interface IInternalTextureLoader {
  71893. /**
  71894. * Defines wether the loader supports cascade loading the different faces.
  71895. */
  71896. supportCascades: boolean;
  71897. /**
  71898. * This returns if the loader support the current file information.
  71899. * @param extension defines the file extension of the file being loaded
  71900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71901. * @param fallback defines the fallback internal texture if any
  71902. * @param isBase64 defines whether the texture is encoded as a base64
  71903. * @param isBuffer defines whether the texture data are stored as a buffer
  71904. * @returns true if the loader can load the specified file
  71905. */
  71906. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71907. /**
  71908. * Transform the url before loading if required.
  71909. * @param rootUrl the url of the texture
  71910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71911. * @returns the transformed texture
  71912. */
  71913. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71914. /**
  71915. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71916. * @param rootUrl the url of the texture
  71917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71918. * @returns the fallback texture
  71919. */
  71920. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71921. /**
  71922. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71923. * @param data contains the texture data
  71924. * @param texture defines the BabylonJS internal texture
  71925. * @param createPolynomials will be true if polynomials have been requested
  71926. * @param onLoad defines the callback to trigger once the texture is ready
  71927. * @param onError defines the callback to trigger in case of error
  71928. */
  71929. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71930. /**
  71931. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71932. * @param data contains the texture data
  71933. * @param texture defines the BabylonJS internal texture
  71934. * @param callback defines the method to call once ready to upload
  71935. */
  71936. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71937. }
  71938. }
  71939. declare module BABYLON {
  71940. interface Engine {
  71941. /**
  71942. * Creates a depth stencil cube texture.
  71943. * This is only available in WebGL 2.
  71944. * @param size The size of face edge in the cube texture.
  71945. * @param options The options defining the cube texture.
  71946. * @returns The cube texture
  71947. */
  71948. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71949. /**
  71950. * Creates a cube texture
  71951. * @param rootUrl defines the url where the files to load is located
  71952. * @param scene defines the current scene
  71953. * @param files defines the list of files to load (1 per face)
  71954. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71955. * @param onLoad defines an optional callback raised when the texture is loaded
  71956. * @param onError defines an optional callback raised if there is an issue to load the texture
  71957. * @param format defines the format of the data
  71958. * @param forcedExtension defines the extension to use to pick the right loader
  71959. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71960. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71961. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71962. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71963. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71964. * @returns the cube texture as an InternalTexture
  71965. */
  71966. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  71967. /**
  71968. * Creates a cube texture
  71969. * @param rootUrl defines the url where the files to load is located
  71970. * @param scene defines the current scene
  71971. * @param files defines the list of files to load (1 per face)
  71972. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71973. * @param onLoad defines an optional callback raised when the texture is loaded
  71974. * @param onError defines an optional callback raised if there is an issue to load the texture
  71975. * @param format defines the format of the data
  71976. * @param forcedExtension defines the extension to use to pick the right loader
  71977. * @returns the cube texture as an InternalTexture
  71978. */
  71979. 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;
  71980. /**
  71981. * Creates a cube texture
  71982. * @param rootUrl defines the url where the files to load is located
  71983. * @param scene defines the current scene
  71984. * @param files defines the list of files to load (1 per face)
  71985. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71986. * @param onLoad defines an optional callback raised when the texture is loaded
  71987. * @param onError defines an optional callback raised if there is an issue to load the texture
  71988. * @param format defines the format of the data
  71989. * @param forcedExtension defines the extension to use to pick the right loader
  71990. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71991. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71992. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71993. * @returns the cube texture as an InternalTexture
  71994. */
  71995. 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;
  71996. /** @hidden */
  71997. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71998. /** @hidden */
  71999. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72000. /** @hidden */
  72001. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72002. /** @hidden */
  72003. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /**
  72008. * Class for creating a cube texture
  72009. */
  72010. export class CubeTexture extends BaseTexture {
  72011. private _delayedOnLoad;
  72012. /**
  72013. * The url of the texture
  72014. */
  72015. url: string;
  72016. /**
  72017. * Gets or sets the center of the bounding box associated with the cube texture.
  72018. * It must define where the camera used to render the texture was set
  72019. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72020. */
  72021. boundingBoxPosition: Vector3;
  72022. private _boundingBoxSize;
  72023. /**
  72024. * Gets or sets the size of the bounding box associated with the cube texture
  72025. * When defined, the cubemap will switch to local mode
  72026. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72027. * @example https://www.babylonjs-playground.com/#RNASML
  72028. */
  72029. /**
  72030. * Returns the bounding box size
  72031. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72032. */
  72033. boundingBoxSize: Vector3;
  72034. protected _rotationY: number;
  72035. /**
  72036. * Sets texture matrix rotation angle around Y axis in radians.
  72037. */
  72038. /**
  72039. * Gets texture matrix rotation angle around Y axis radians.
  72040. */
  72041. rotationY: number;
  72042. /**
  72043. * Are mip maps generated for this texture or not.
  72044. */
  72045. readonly noMipmap: boolean;
  72046. private _noMipmap;
  72047. private _files;
  72048. private _extensions;
  72049. private _textureMatrix;
  72050. private _format;
  72051. private _createPolynomials;
  72052. /** @hidden */
  72053. _prefiltered: boolean;
  72054. /**
  72055. * Creates a cube texture from an array of image urls
  72056. * @param files defines an array of image urls
  72057. * @param scene defines the hosting scene
  72058. * @param noMipmap specifies if mip maps are not used
  72059. * @returns a cube texture
  72060. */
  72061. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72062. /**
  72063. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72064. * @param url defines the url of the prefiltered texture
  72065. * @param scene defines the scene the texture is attached to
  72066. * @param forcedExtension defines the extension of the file if different from the url
  72067. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72068. * @return the prefiltered texture
  72069. */
  72070. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72071. /**
  72072. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72073. * as prefiltered data.
  72074. * @param rootUrl defines the url of the texture or the root name of the six images
  72075. * @param scene defines the scene the texture is attached to
  72076. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72077. * @param noMipmap defines if mipmaps should be created or not
  72078. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72079. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72080. * @param onError defines a callback triggered in case of error during load
  72081. * @param format defines the internal format to use for the texture once loaded
  72082. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72083. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72084. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72085. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72086. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72087. * @return the cube texture
  72088. */
  72089. 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);
  72090. /**
  72091. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72092. */
  72093. readonly isPrefiltered: boolean;
  72094. /**
  72095. * Get the current class name of the texture useful for serialization or dynamic coding.
  72096. * @returns "CubeTexture"
  72097. */
  72098. getClassName(): string;
  72099. /**
  72100. * Update the url (and optional buffer) of this texture if url was null during construction.
  72101. * @param url the url of the texture
  72102. * @param forcedExtension defines the extension to use
  72103. * @param onLoad callback called when the texture is loaded (defaults to null)
  72104. */
  72105. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72106. /**
  72107. * Delays loading of the cube texture
  72108. * @param forcedExtension defines the extension to use
  72109. */
  72110. delayLoad(forcedExtension?: string): void;
  72111. /**
  72112. * Returns the reflection texture matrix
  72113. * @returns the reflection texture matrix
  72114. */
  72115. getReflectionTextureMatrix(): Matrix;
  72116. /**
  72117. * Sets the reflection texture matrix
  72118. * @param value Reflection texture matrix
  72119. */
  72120. setReflectionTextureMatrix(value: Matrix): void;
  72121. /**
  72122. * Parses text to create a cube texture
  72123. * @param parsedTexture define the serialized text to read from
  72124. * @param scene defines the hosting scene
  72125. * @param rootUrl defines the root url of the cube texture
  72126. * @returns a cube texture
  72127. */
  72128. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72129. /**
  72130. * Makes a clone, or deep copy, of the cube texture
  72131. * @returns a new cube texture
  72132. */
  72133. clone(): CubeTexture;
  72134. }
  72135. }
  72136. declare module BABYLON {
  72137. /**
  72138. * Manages the defines for the Material
  72139. */
  72140. export class MaterialDefines {
  72141. /** @hidden */
  72142. protected _keys: string[];
  72143. private _isDirty;
  72144. /** @hidden */
  72145. _renderId: number;
  72146. /** @hidden */
  72147. _areLightsDirty: boolean;
  72148. /** @hidden */
  72149. _areAttributesDirty: boolean;
  72150. /** @hidden */
  72151. _areTexturesDirty: boolean;
  72152. /** @hidden */
  72153. _areFresnelDirty: boolean;
  72154. /** @hidden */
  72155. _areMiscDirty: boolean;
  72156. /** @hidden */
  72157. _areImageProcessingDirty: boolean;
  72158. /** @hidden */
  72159. _normals: boolean;
  72160. /** @hidden */
  72161. _uvs: boolean;
  72162. /** @hidden */
  72163. _needNormals: boolean;
  72164. /** @hidden */
  72165. _needUVs: boolean;
  72166. [id: string]: any;
  72167. /**
  72168. * Specifies if the material needs to be re-calculated
  72169. */
  72170. readonly isDirty: boolean;
  72171. /**
  72172. * Marks the material to indicate that it has been re-calculated
  72173. */
  72174. markAsProcessed(): void;
  72175. /**
  72176. * Marks the material to indicate that it needs to be re-calculated
  72177. */
  72178. markAsUnprocessed(): void;
  72179. /**
  72180. * Marks the material to indicate all of its defines need to be re-calculated
  72181. */
  72182. markAllAsDirty(): void;
  72183. /**
  72184. * Marks the material to indicate that image processing needs to be re-calculated
  72185. */
  72186. markAsImageProcessingDirty(): void;
  72187. /**
  72188. * Marks the material to indicate the lights need to be re-calculated
  72189. */
  72190. markAsLightDirty(): void;
  72191. /**
  72192. * Marks the attribute state as changed
  72193. */
  72194. markAsAttributesDirty(): void;
  72195. /**
  72196. * Marks the texture state as changed
  72197. */
  72198. markAsTexturesDirty(): void;
  72199. /**
  72200. * Marks the fresnel state as changed
  72201. */
  72202. markAsFresnelDirty(): void;
  72203. /**
  72204. * Marks the misc state as changed
  72205. */
  72206. markAsMiscDirty(): void;
  72207. /**
  72208. * Rebuilds the material defines
  72209. */
  72210. rebuild(): void;
  72211. /**
  72212. * Specifies if two material defines are equal
  72213. * @param other - A material define instance to compare to
  72214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72215. */
  72216. isEqual(other: MaterialDefines): boolean;
  72217. /**
  72218. * Clones this instance's defines to another instance
  72219. * @param other - material defines to clone values to
  72220. */
  72221. cloneTo(other: MaterialDefines): void;
  72222. /**
  72223. * Resets the material define values
  72224. */
  72225. reset(): void;
  72226. /**
  72227. * Converts the material define values to a string
  72228. * @returns - String of material define information
  72229. */
  72230. toString(): string;
  72231. }
  72232. }
  72233. declare module BABYLON {
  72234. /**
  72235. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72236. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72237. * 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;
  72238. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72239. */
  72240. export class ColorCurves {
  72241. private _dirty;
  72242. private _tempColor;
  72243. private _globalCurve;
  72244. private _highlightsCurve;
  72245. private _midtonesCurve;
  72246. private _shadowsCurve;
  72247. private _positiveCurve;
  72248. private _negativeCurve;
  72249. private _globalHue;
  72250. private _globalDensity;
  72251. private _globalSaturation;
  72252. private _globalExposure;
  72253. /**
  72254. * Gets the global Hue value.
  72255. * 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).
  72256. */
  72257. /**
  72258. * Sets the global Hue value.
  72259. * 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).
  72260. */
  72261. globalHue: number;
  72262. /**
  72263. * Gets the global Density value.
  72264. * 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.
  72265. * Values less than zero provide a filter of opposite hue.
  72266. */
  72267. /**
  72268. * Sets the global Density value.
  72269. * 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.
  72270. * Values less than zero provide a filter of opposite hue.
  72271. */
  72272. globalDensity: number;
  72273. /**
  72274. * Gets the global Saturation value.
  72275. * 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.
  72276. */
  72277. /**
  72278. * Sets the global Saturation value.
  72279. * 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.
  72280. */
  72281. globalSaturation: number;
  72282. /**
  72283. * Gets the global Exposure value.
  72284. * 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.
  72285. */
  72286. /**
  72287. * Sets the global Exposure value.
  72288. * 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.
  72289. */
  72290. globalExposure: number;
  72291. private _highlightsHue;
  72292. private _highlightsDensity;
  72293. private _highlightsSaturation;
  72294. private _highlightsExposure;
  72295. /**
  72296. * Gets the highlights Hue value.
  72297. * 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).
  72298. */
  72299. /**
  72300. * Sets the highlights Hue value.
  72301. * 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).
  72302. */
  72303. highlightsHue: number;
  72304. /**
  72305. * Gets the highlights Density value.
  72306. * 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.
  72307. * Values less than zero provide a filter of opposite hue.
  72308. */
  72309. /**
  72310. * Sets the highlights Density value.
  72311. * 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.
  72312. * Values less than zero provide a filter of opposite hue.
  72313. */
  72314. highlightsDensity: number;
  72315. /**
  72316. * Gets the highlights Saturation value.
  72317. * 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.
  72318. */
  72319. /**
  72320. * Sets the highlights Saturation value.
  72321. * 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.
  72322. */
  72323. highlightsSaturation: number;
  72324. /**
  72325. * Gets the highlights Exposure value.
  72326. * 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.
  72327. */
  72328. /**
  72329. * Sets the highlights Exposure value.
  72330. * 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.
  72331. */
  72332. highlightsExposure: number;
  72333. private _midtonesHue;
  72334. private _midtonesDensity;
  72335. private _midtonesSaturation;
  72336. private _midtonesExposure;
  72337. /**
  72338. * Gets the midtones Hue value.
  72339. * 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).
  72340. */
  72341. /**
  72342. * Sets the midtones Hue value.
  72343. * 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).
  72344. */
  72345. midtonesHue: number;
  72346. /**
  72347. * Gets the midtones Density value.
  72348. * 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.
  72349. * Values less than zero provide a filter of opposite hue.
  72350. */
  72351. /**
  72352. * Sets the midtones Density value.
  72353. * 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.
  72354. * Values less than zero provide a filter of opposite hue.
  72355. */
  72356. midtonesDensity: number;
  72357. /**
  72358. * Gets the midtones Saturation value.
  72359. * 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.
  72360. */
  72361. /**
  72362. * Sets the midtones Saturation value.
  72363. * 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.
  72364. */
  72365. midtonesSaturation: number;
  72366. /**
  72367. * Gets the midtones Exposure value.
  72368. * 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.
  72369. */
  72370. /**
  72371. * Sets the midtones Exposure value.
  72372. * 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.
  72373. */
  72374. midtonesExposure: number;
  72375. private _shadowsHue;
  72376. private _shadowsDensity;
  72377. private _shadowsSaturation;
  72378. private _shadowsExposure;
  72379. /**
  72380. * Gets the shadows Hue value.
  72381. * 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).
  72382. */
  72383. /**
  72384. * Sets the shadows Hue value.
  72385. * 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).
  72386. */
  72387. shadowsHue: number;
  72388. /**
  72389. * Gets the shadows Density value.
  72390. * 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.
  72391. * Values less than zero provide a filter of opposite hue.
  72392. */
  72393. /**
  72394. * Sets the shadows Density value.
  72395. * 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.
  72396. * Values less than zero provide a filter of opposite hue.
  72397. */
  72398. shadowsDensity: number;
  72399. /**
  72400. * Gets the shadows Saturation value.
  72401. * 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.
  72402. */
  72403. /**
  72404. * Sets the shadows Saturation value.
  72405. * 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.
  72406. */
  72407. shadowsSaturation: number;
  72408. /**
  72409. * Gets the shadows Exposure value.
  72410. * 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.
  72411. */
  72412. /**
  72413. * Sets the shadows Exposure value.
  72414. * 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.
  72415. */
  72416. shadowsExposure: number;
  72417. /**
  72418. * Returns the class name
  72419. * @returns The class name
  72420. */
  72421. getClassName(): string;
  72422. /**
  72423. * Binds the color curves to the shader.
  72424. * @param colorCurves The color curve to bind
  72425. * @param effect The effect to bind to
  72426. * @param positiveUniform The positive uniform shader parameter
  72427. * @param neutralUniform The neutral uniform shader parameter
  72428. * @param negativeUniform The negative uniform shader parameter
  72429. */
  72430. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72431. /**
  72432. * Prepare the list of uniforms associated with the ColorCurves effects.
  72433. * @param uniformsList The list of uniforms used in the effect
  72434. */
  72435. static PrepareUniforms(uniformsList: string[]): void;
  72436. /**
  72437. * Returns color grading data based on a hue, density, saturation and exposure value.
  72438. * @param filterHue The hue of the color filter.
  72439. * @param filterDensity The density of the color filter.
  72440. * @param saturation The saturation.
  72441. * @param exposure The exposure.
  72442. * @param result The result data container.
  72443. */
  72444. private getColorGradingDataToRef;
  72445. /**
  72446. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72447. * @param value The input slider value in range [-100,100].
  72448. * @returns Adjusted value.
  72449. */
  72450. private static applyColorGradingSliderNonlinear;
  72451. /**
  72452. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72453. * @param hue The hue (H) input.
  72454. * @param saturation The saturation (S) input.
  72455. * @param brightness The brightness (B) input.
  72456. * @result An RGBA color represented as Vector4.
  72457. */
  72458. private static fromHSBToRef;
  72459. /**
  72460. * Returns a value clamped between min and max
  72461. * @param value The value to clamp
  72462. * @param min The minimum of value
  72463. * @param max The maximum of value
  72464. * @returns The clamped value.
  72465. */
  72466. private static clamp;
  72467. /**
  72468. * Clones the current color curve instance.
  72469. * @return The cloned curves
  72470. */
  72471. clone(): ColorCurves;
  72472. /**
  72473. * Serializes the current color curve instance to a json representation.
  72474. * @return a JSON representation
  72475. */
  72476. serialize(): any;
  72477. /**
  72478. * Parses the color curve from a json representation.
  72479. * @param source the JSON source to parse
  72480. * @return The parsed curves
  72481. */
  72482. static Parse(source: any): ColorCurves;
  72483. }
  72484. }
  72485. declare module BABYLON {
  72486. /**
  72487. * Interface to follow in your material defines to integrate easily the
  72488. * Image proccessing functions.
  72489. * @hidden
  72490. */
  72491. export interface IImageProcessingConfigurationDefines {
  72492. IMAGEPROCESSING: boolean;
  72493. VIGNETTE: boolean;
  72494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72495. VIGNETTEBLENDMODEOPAQUE: boolean;
  72496. TONEMAPPING: boolean;
  72497. TONEMAPPING_ACES: boolean;
  72498. CONTRAST: boolean;
  72499. EXPOSURE: boolean;
  72500. COLORCURVES: boolean;
  72501. COLORGRADING: boolean;
  72502. COLORGRADING3D: boolean;
  72503. SAMPLER3DGREENDEPTH: boolean;
  72504. SAMPLER3DBGRMAP: boolean;
  72505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72506. }
  72507. /**
  72508. * @hidden
  72509. */
  72510. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72511. IMAGEPROCESSING: boolean;
  72512. VIGNETTE: boolean;
  72513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72514. VIGNETTEBLENDMODEOPAQUE: boolean;
  72515. TONEMAPPING: boolean;
  72516. TONEMAPPING_ACES: boolean;
  72517. CONTRAST: boolean;
  72518. COLORCURVES: boolean;
  72519. COLORGRADING: boolean;
  72520. COLORGRADING3D: boolean;
  72521. SAMPLER3DGREENDEPTH: boolean;
  72522. SAMPLER3DBGRMAP: boolean;
  72523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72524. EXPOSURE: boolean;
  72525. constructor();
  72526. }
  72527. /**
  72528. * This groups together the common properties used for image processing either in direct forward pass
  72529. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72530. * or not.
  72531. */
  72532. export class ImageProcessingConfiguration {
  72533. /**
  72534. * Default tone mapping applied in BabylonJS.
  72535. */
  72536. static readonly TONEMAPPING_STANDARD: number;
  72537. /**
  72538. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72539. * to other engines rendering to increase portability.
  72540. */
  72541. static readonly TONEMAPPING_ACES: number;
  72542. /**
  72543. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72544. */
  72545. colorCurves: Nullable<ColorCurves>;
  72546. private _colorCurvesEnabled;
  72547. /**
  72548. * Gets wether the color curves effect is enabled.
  72549. */
  72550. /**
  72551. * Sets wether the color curves effect is enabled.
  72552. */
  72553. colorCurvesEnabled: boolean;
  72554. private _colorGradingTexture;
  72555. /**
  72556. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72557. */
  72558. /**
  72559. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72560. */
  72561. colorGradingTexture: Nullable<BaseTexture>;
  72562. private _colorGradingEnabled;
  72563. /**
  72564. * Gets wether the color grading effect is enabled.
  72565. */
  72566. /**
  72567. * Sets wether the color grading effect is enabled.
  72568. */
  72569. colorGradingEnabled: boolean;
  72570. private _colorGradingWithGreenDepth;
  72571. /**
  72572. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72573. */
  72574. /**
  72575. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72576. */
  72577. colorGradingWithGreenDepth: boolean;
  72578. private _colorGradingBGR;
  72579. /**
  72580. * Gets wether the color grading texture contains BGR values.
  72581. */
  72582. /**
  72583. * Sets wether the color grading texture contains BGR values.
  72584. */
  72585. colorGradingBGR: boolean;
  72586. /** @hidden */
  72587. _exposure: number;
  72588. /**
  72589. * Gets the Exposure used in the effect.
  72590. */
  72591. /**
  72592. * Sets the Exposure used in the effect.
  72593. */
  72594. exposure: number;
  72595. private _toneMappingEnabled;
  72596. /**
  72597. * Gets wether the tone mapping effect is enabled.
  72598. */
  72599. /**
  72600. * Sets wether the tone mapping effect is enabled.
  72601. */
  72602. toneMappingEnabled: boolean;
  72603. private _toneMappingType;
  72604. /**
  72605. * Gets the type of tone mapping effect.
  72606. */
  72607. /**
  72608. * Sets the type of tone mapping effect used in BabylonJS.
  72609. */
  72610. toneMappingType: number;
  72611. protected _contrast: number;
  72612. /**
  72613. * Gets the contrast used in the effect.
  72614. */
  72615. /**
  72616. * Sets the contrast used in the effect.
  72617. */
  72618. contrast: number;
  72619. /**
  72620. * Vignette stretch size.
  72621. */
  72622. vignetteStretch: number;
  72623. /**
  72624. * Vignette centre X Offset.
  72625. */
  72626. vignetteCentreX: number;
  72627. /**
  72628. * Vignette centre Y Offset.
  72629. */
  72630. vignetteCentreY: number;
  72631. /**
  72632. * Vignette weight or intensity of the vignette effect.
  72633. */
  72634. vignetteWeight: number;
  72635. /**
  72636. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72637. * if vignetteEnabled is set to true.
  72638. */
  72639. vignetteColor: Color4;
  72640. /**
  72641. * Camera field of view used by the Vignette effect.
  72642. */
  72643. vignetteCameraFov: number;
  72644. private _vignetteBlendMode;
  72645. /**
  72646. * Gets the vignette blend mode allowing different kind of effect.
  72647. */
  72648. /**
  72649. * Sets the vignette blend mode allowing different kind of effect.
  72650. */
  72651. vignetteBlendMode: number;
  72652. private _vignetteEnabled;
  72653. /**
  72654. * Gets wether the vignette effect is enabled.
  72655. */
  72656. /**
  72657. * Sets wether the vignette effect is enabled.
  72658. */
  72659. vignetteEnabled: boolean;
  72660. private _applyByPostProcess;
  72661. /**
  72662. * Gets wether the image processing is applied through a post process or not.
  72663. */
  72664. /**
  72665. * Sets wether the image processing is applied through a post process or not.
  72666. */
  72667. applyByPostProcess: boolean;
  72668. private _isEnabled;
  72669. /**
  72670. * Gets wether the image processing is enabled or not.
  72671. */
  72672. /**
  72673. * Sets wether the image processing is enabled or not.
  72674. */
  72675. isEnabled: boolean;
  72676. /**
  72677. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72678. */
  72679. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72680. /**
  72681. * Method called each time the image processing information changes requires to recompile the effect.
  72682. */
  72683. protected _updateParameters(): void;
  72684. /**
  72685. * Gets the current class name.
  72686. * @return "ImageProcessingConfiguration"
  72687. */
  72688. getClassName(): string;
  72689. /**
  72690. * Prepare the list of uniforms associated with the Image Processing effects.
  72691. * @param uniforms The list of uniforms used in the effect
  72692. * @param defines the list of defines currently in use
  72693. */
  72694. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72695. /**
  72696. * Prepare the list of samplers associated with the Image Processing effects.
  72697. * @param samplersList The list of uniforms used in the effect
  72698. * @param defines the list of defines currently in use
  72699. */
  72700. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72701. /**
  72702. * Prepare the list of defines associated to the shader.
  72703. * @param defines the list of defines to complete
  72704. * @param forPostProcess Define if we are currently in post process mode or not
  72705. */
  72706. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72707. /**
  72708. * Returns true if all the image processing information are ready.
  72709. * @returns True if ready, otherwise, false
  72710. */
  72711. isReady(): boolean;
  72712. /**
  72713. * Binds the image processing to the shader.
  72714. * @param effect The effect to bind to
  72715. * @param aspectRatio Define the current aspect ratio of the effect
  72716. */
  72717. bind(effect: Effect, aspectRatio?: number): void;
  72718. /**
  72719. * Clones the current image processing instance.
  72720. * @return The cloned image processing
  72721. */
  72722. clone(): ImageProcessingConfiguration;
  72723. /**
  72724. * Serializes the current image processing instance to a json representation.
  72725. * @return a JSON representation
  72726. */
  72727. serialize(): any;
  72728. /**
  72729. * Parses the image processing from a json representation.
  72730. * @param source the JSON source to parse
  72731. * @return The parsed image processing
  72732. */
  72733. static Parse(source: any): ImageProcessingConfiguration;
  72734. private static _VIGNETTEMODE_MULTIPLY;
  72735. private static _VIGNETTEMODE_OPAQUE;
  72736. /**
  72737. * Used to apply the vignette as a mix with the pixel color.
  72738. */
  72739. static readonly VIGNETTEMODE_MULTIPLY: number;
  72740. /**
  72741. * Used to apply the vignette as a replacement of the pixel color.
  72742. */
  72743. static readonly VIGNETTEMODE_OPAQUE: number;
  72744. }
  72745. }
  72746. declare module BABYLON {
  72747. /** @hidden */
  72748. export var postprocessVertexShader: {
  72749. name: string;
  72750. shader: string;
  72751. };
  72752. }
  72753. declare module BABYLON {
  72754. /** Defines supported spaces */
  72755. export enum Space {
  72756. /** Local (object) space */
  72757. LOCAL = 0,
  72758. /** World space */
  72759. WORLD = 1,
  72760. /** Bone space */
  72761. BONE = 2
  72762. }
  72763. /** Defines the 3 main axes */
  72764. export class Axis {
  72765. /** X axis */
  72766. static X: Vector3;
  72767. /** Y axis */
  72768. static Y: Vector3;
  72769. /** Z axis */
  72770. static Z: Vector3;
  72771. }
  72772. }
  72773. declare module BABYLON {
  72774. /**
  72775. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72776. * This is the base of the follow, arc rotate cameras and Free camera
  72777. * @see http://doc.babylonjs.com/features/cameras
  72778. */
  72779. export class TargetCamera extends Camera {
  72780. private static _RigCamTransformMatrix;
  72781. private static _TargetTransformMatrix;
  72782. private static _TargetFocalPoint;
  72783. /**
  72784. * Define the current direction the camera is moving to
  72785. */
  72786. cameraDirection: Vector3;
  72787. /**
  72788. * Define the current rotation the camera is rotating to
  72789. */
  72790. cameraRotation: Vector2;
  72791. /**
  72792. * When set, the up vector of the camera will be updated by the rotation of the camera
  72793. */
  72794. updateUpVectorFromRotation: boolean;
  72795. private _tmpQuaternion;
  72796. /**
  72797. * Define the current rotation of the camera
  72798. */
  72799. rotation: Vector3;
  72800. /**
  72801. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72802. */
  72803. rotationQuaternion: Quaternion;
  72804. /**
  72805. * Define the current speed of the camera
  72806. */
  72807. speed: number;
  72808. /**
  72809. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72810. * around all axis.
  72811. */
  72812. noRotationConstraint: boolean;
  72813. /**
  72814. * Define the current target of the camera as an object or a position.
  72815. */
  72816. lockedTarget: any;
  72817. /** @hidden */
  72818. _currentTarget: Vector3;
  72819. /** @hidden */
  72820. _initialFocalDistance: number;
  72821. /** @hidden */
  72822. _viewMatrix: Matrix;
  72823. /** @hidden */
  72824. _camMatrix: Matrix;
  72825. /** @hidden */
  72826. _cameraTransformMatrix: Matrix;
  72827. /** @hidden */
  72828. _cameraRotationMatrix: Matrix;
  72829. /** @hidden */
  72830. _referencePoint: Vector3;
  72831. /** @hidden */
  72832. _transformedReferencePoint: Vector3;
  72833. protected _globalCurrentTarget: Vector3;
  72834. protected _globalCurrentUpVector: Vector3;
  72835. /** @hidden */
  72836. _reset: () => void;
  72837. private _defaultUp;
  72838. /**
  72839. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72840. * This is the base of the follow, arc rotate cameras and Free camera
  72841. * @see http://doc.babylonjs.com/features/cameras
  72842. * @param name Defines the name of the camera in the scene
  72843. * @param position Defines the start position of the camera in the scene
  72844. * @param scene Defines the scene the camera belongs to
  72845. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72846. */
  72847. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72848. /**
  72849. * Gets the position in front of the camera at a given distance.
  72850. * @param distance The distance from the camera we want the position to be
  72851. * @returns the position
  72852. */
  72853. getFrontPosition(distance: number): Vector3;
  72854. /** @hidden */
  72855. _getLockedTargetPosition(): Nullable<Vector3>;
  72856. private _storedPosition;
  72857. private _storedRotation;
  72858. private _storedRotationQuaternion;
  72859. /**
  72860. * Store current camera state of the camera (fov, position, rotation, etc..)
  72861. * @returns the camera
  72862. */
  72863. storeState(): Camera;
  72864. /**
  72865. * Restored camera state. You must call storeState() first
  72866. * @returns whether it was successful or not
  72867. * @hidden
  72868. */
  72869. _restoreStateValues(): boolean;
  72870. /** @hidden */
  72871. _initCache(): void;
  72872. /** @hidden */
  72873. _updateCache(ignoreParentClass?: boolean): void;
  72874. /** @hidden */
  72875. _isSynchronizedViewMatrix(): boolean;
  72876. /** @hidden */
  72877. _computeLocalCameraSpeed(): number;
  72878. /**
  72879. * Defines the target the camera should look at.
  72880. * @param target Defines the new target as a Vector or a mesh
  72881. */
  72882. setTarget(target: Vector3): void;
  72883. /**
  72884. * Return the current target position of the camera. This value is expressed in local space.
  72885. * @returns the target position
  72886. */
  72887. getTarget(): Vector3;
  72888. /** @hidden */
  72889. _decideIfNeedsToMove(): boolean;
  72890. /** @hidden */
  72891. _updatePosition(): void;
  72892. /** @hidden */
  72893. _checkInputs(): void;
  72894. protected _updateCameraRotationMatrix(): void;
  72895. /**
  72896. * 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)
  72897. * @returns the current camera
  72898. */
  72899. private _rotateUpVectorWithCameraRotationMatrix;
  72900. private _cachedRotationZ;
  72901. private _cachedQuaternionRotationZ;
  72902. /** @hidden */
  72903. _getViewMatrix(): Matrix;
  72904. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72905. /**
  72906. * @hidden
  72907. */
  72908. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72909. /**
  72910. * @hidden
  72911. */
  72912. _updateRigCameras(): void;
  72913. private _getRigCamPositionAndTarget;
  72914. /**
  72915. * Gets the current object class name.
  72916. * @return the class name
  72917. */
  72918. getClassName(): string;
  72919. }
  72920. }
  72921. declare module BABYLON {
  72922. /**
  72923. * Gather the list of keyboard event types as constants.
  72924. */
  72925. export class KeyboardEventTypes {
  72926. /**
  72927. * The keydown event is fired when a key becomes active (pressed).
  72928. */
  72929. static readonly KEYDOWN: number;
  72930. /**
  72931. * The keyup event is fired when a key has been released.
  72932. */
  72933. static readonly KEYUP: number;
  72934. }
  72935. /**
  72936. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72937. */
  72938. export class KeyboardInfo {
  72939. /**
  72940. * Defines the type of event (KeyboardEventTypes)
  72941. */
  72942. type: number;
  72943. /**
  72944. * Defines the related dom event
  72945. */
  72946. event: KeyboardEvent;
  72947. /**
  72948. * Instantiates a new keyboard info.
  72949. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72950. * @param type Defines the type of event (KeyboardEventTypes)
  72951. * @param event Defines the related dom event
  72952. */
  72953. constructor(
  72954. /**
  72955. * Defines the type of event (KeyboardEventTypes)
  72956. */
  72957. type: number,
  72958. /**
  72959. * Defines the related dom event
  72960. */
  72961. event: KeyboardEvent);
  72962. }
  72963. /**
  72964. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72965. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72966. */
  72967. export class KeyboardInfoPre extends KeyboardInfo {
  72968. /**
  72969. * Defines the type of event (KeyboardEventTypes)
  72970. */
  72971. type: number;
  72972. /**
  72973. * Defines the related dom event
  72974. */
  72975. event: KeyboardEvent;
  72976. /**
  72977. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72978. */
  72979. skipOnPointerObservable: boolean;
  72980. /**
  72981. * Instantiates a new keyboard pre info.
  72982. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72983. * @param type Defines the type of event (KeyboardEventTypes)
  72984. * @param event Defines the related dom event
  72985. */
  72986. constructor(
  72987. /**
  72988. * Defines the type of event (KeyboardEventTypes)
  72989. */
  72990. type: number,
  72991. /**
  72992. * Defines the related dom event
  72993. */
  72994. event: KeyboardEvent);
  72995. }
  72996. }
  72997. declare module BABYLON {
  72998. /**
  72999. * Manage the keyboard inputs to control the movement of a free camera.
  73000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73001. */
  73002. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73003. /**
  73004. * Defines the camera the input is attached to.
  73005. */
  73006. camera: FreeCamera;
  73007. /**
  73008. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73009. */
  73010. keysUp: number[];
  73011. /**
  73012. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73013. */
  73014. keysDown: number[];
  73015. /**
  73016. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73017. */
  73018. keysLeft: number[];
  73019. /**
  73020. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73021. */
  73022. keysRight: number[];
  73023. private _keys;
  73024. private _onCanvasBlurObserver;
  73025. private _onKeyboardObserver;
  73026. private _engine;
  73027. private _scene;
  73028. /**
  73029. * Attach the input controls to a specific dom element to get the input from.
  73030. * @param element Defines the element the controls should be listened from
  73031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73032. */
  73033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73034. /**
  73035. * Detach the current controls from the specified dom element.
  73036. * @param element Defines the element to stop listening the inputs from
  73037. */
  73038. detachControl(element: Nullable<HTMLElement>): void;
  73039. /**
  73040. * Update the current camera state depending on the inputs that have been used this frame.
  73041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73042. */
  73043. checkInputs(): void;
  73044. /**
  73045. * Gets the class name of the current intput.
  73046. * @returns the class name
  73047. */
  73048. getClassName(): string;
  73049. /** @hidden */
  73050. _onLostFocus(): void;
  73051. /**
  73052. * Get the friendly name associated with the input class.
  73053. * @returns the input friendly name
  73054. */
  73055. getSimpleName(): string;
  73056. }
  73057. }
  73058. declare module BABYLON {
  73059. /**
  73060. * Interface describing all the common properties and methods a shadow light needs to implement.
  73061. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73062. * as well as binding the different shadow properties to the effects.
  73063. */
  73064. export interface IShadowLight extends Light {
  73065. /**
  73066. * The light id in the scene (used in scene.findLighById for instance)
  73067. */
  73068. id: string;
  73069. /**
  73070. * The position the shdow will be casted from.
  73071. */
  73072. position: Vector3;
  73073. /**
  73074. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73075. */
  73076. direction: Vector3;
  73077. /**
  73078. * The transformed position. Position of the light in world space taking parenting in account.
  73079. */
  73080. transformedPosition: Vector3;
  73081. /**
  73082. * The transformed direction. Direction of the light in world space taking parenting in account.
  73083. */
  73084. transformedDirection: Vector3;
  73085. /**
  73086. * The friendly name of the light in the scene.
  73087. */
  73088. name: string;
  73089. /**
  73090. * Defines the shadow projection clipping minimum z value.
  73091. */
  73092. shadowMinZ: number;
  73093. /**
  73094. * Defines the shadow projection clipping maximum z value.
  73095. */
  73096. shadowMaxZ: number;
  73097. /**
  73098. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73099. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73100. */
  73101. computeTransformedInformation(): boolean;
  73102. /**
  73103. * Gets the scene the light belongs to.
  73104. * @returns The scene
  73105. */
  73106. getScene(): Scene;
  73107. /**
  73108. * Callback defining a custom Projection Matrix Builder.
  73109. * This can be used to override the default projection matrix computation.
  73110. */
  73111. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73112. /**
  73113. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73114. * @param matrix The materix to updated with the projection information
  73115. * @param viewMatrix The transform matrix of the light
  73116. * @param renderList The list of mesh to render in the map
  73117. * @returns The current light
  73118. */
  73119. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73120. /**
  73121. * Gets the current depth scale used in ESM.
  73122. * @returns The scale
  73123. */
  73124. getDepthScale(): number;
  73125. /**
  73126. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73127. * @returns true if a cube texture needs to be use
  73128. */
  73129. needCube(): boolean;
  73130. /**
  73131. * Detects if the projection matrix requires to be recomputed this frame.
  73132. * @returns true if it requires to be recomputed otherwise, false.
  73133. */
  73134. needProjectionMatrixCompute(): boolean;
  73135. /**
  73136. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73137. */
  73138. forceProjectionMatrixCompute(): void;
  73139. /**
  73140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73143. */
  73144. getShadowDirection(faceIndex?: number): Vector3;
  73145. /**
  73146. * Gets the minZ used for shadow according to both the scene and the light.
  73147. * @param activeCamera The camera we are returning the min for
  73148. * @returns the depth min z
  73149. */
  73150. getDepthMinZ(activeCamera: Camera): number;
  73151. /**
  73152. * Gets the maxZ used for shadow according to both the scene and the light.
  73153. * @param activeCamera The camera we are returning the max for
  73154. * @returns the depth max z
  73155. */
  73156. getDepthMaxZ(activeCamera: Camera): number;
  73157. }
  73158. /**
  73159. * Base implementation IShadowLight
  73160. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73161. */
  73162. export abstract class ShadowLight extends Light implements IShadowLight {
  73163. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73164. protected _position: Vector3;
  73165. protected _setPosition(value: Vector3): void;
  73166. /**
  73167. * Sets the position the shadow will be casted from. Also use as the light position for both
  73168. * point and spot lights.
  73169. */
  73170. /**
  73171. * Sets the position the shadow will be casted from. Also use as the light position for both
  73172. * point and spot lights.
  73173. */
  73174. position: Vector3;
  73175. protected _direction: Vector3;
  73176. protected _setDirection(value: Vector3): void;
  73177. /**
  73178. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73179. * Also use as the light direction on spot and directional lights.
  73180. */
  73181. /**
  73182. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73183. * Also use as the light direction on spot and directional lights.
  73184. */
  73185. direction: Vector3;
  73186. private _shadowMinZ;
  73187. /**
  73188. * Gets the shadow projection clipping minimum z value.
  73189. */
  73190. /**
  73191. * Sets the shadow projection clipping minimum z value.
  73192. */
  73193. shadowMinZ: number;
  73194. private _shadowMaxZ;
  73195. /**
  73196. * Sets the shadow projection clipping maximum z value.
  73197. */
  73198. /**
  73199. * Gets the shadow projection clipping maximum z value.
  73200. */
  73201. shadowMaxZ: number;
  73202. /**
  73203. * Callback defining a custom Projection Matrix Builder.
  73204. * This can be used to override the default projection matrix computation.
  73205. */
  73206. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73207. /**
  73208. * The transformed position. Position of the light in world space taking parenting in account.
  73209. */
  73210. transformedPosition: Vector3;
  73211. /**
  73212. * The transformed direction. Direction of the light in world space taking parenting in account.
  73213. */
  73214. transformedDirection: Vector3;
  73215. private _needProjectionMatrixCompute;
  73216. /**
  73217. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73218. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73219. */
  73220. computeTransformedInformation(): boolean;
  73221. /**
  73222. * Return the depth scale used for the shadow map.
  73223. * @returns the depth scale.
  73224. */
  73225. getDepthScale(): number;
  73226. /**
  73227. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73228. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73229. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73230. */
  73231. getShadowDirection(faceIndex?: number): Vector3;
  73232. /**
  73233. * Returns the ShadowLight absolute position in the World.
  73234. * @returns the position vector in world space
  73235. */
  73236. getAbsolutePosition(): Vector3;
  73237. /**
  73238. * Sets the ShadowLight direction toward the passed target.
  73239. * @param target The point to target in local space
  73240. * @returns the updated ShadowLight direction
  73241. */
  73242. setDirectionToTarget(target: Vector3): Vector3;
  73243. /**
  73244. * Returns the light rotation in euler definition.
  73245. * @returns the x y z rotation in local space.
  73246. */
  73247. getRotation(): Vector3;
  73248. /**
  73249. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73250. * @returns true if a cube texture needs to be use
  73251. */
  73252. needCube(): boolean;
  73253. /**
  73254. * Detects if the projection matrix requires to be recomputed this frame.
  73255. * @returns true if it requires to be recomputed otherwise, false.
  73256. */
  73257. needProjectionMatrixCompute(): boolean;
  73258. /**
  73259. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73260. */
  73261. forceProjectionMatrixCompute(): void;
  73262. /** @hidden */
  73263. _initCache(): void;
  73264. /** @hidden */
  73265. _isSynchronized(): boolean;
  73266. /**
  73267. * Computes the world matrix of the node
  73268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73269. * @returns the world matrix
  73270. */
  73271. computeWorldMatrix(force?: boolean): Matrix;
  73272. /**
  73273. * Gets the minZ used for shadow according to both the scene and the light.
  73274. * @param activeCamera The camera we are returning the min for
  73275. * @returns the depth min z
  73276. */
  73277. getDepthMinZ(activeCamera: Camera): number;
  73278. /**
  73279. * Gets the maxZ used for shadow according to both the scene and the light.
  73280. * @param activeCamera The camera we are returning the max for
  73281. * @returns the depth max z
  73282. */
  73283. getDepthMaxZ(activeCamera: Camera): number;
  73284. /**
  73285. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73286. * @param matrix The materix to updated with the projection information
  73287. * @param viewMatrix The transform matrix of the light
  73288. * @param renderList The list of mesh to render in the map
  73289. * @returns The current light
  73290. */
  73291. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73292. }
  73293. }
  73294. declare module BABYLON {
  73295. /**
  73296. * "Static Class" containing the most commonly used helper while dealing with material for
  73297. * rendering purpose.
  73298. *
  73299. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73300. *
  73301. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73302. */
  73303. export class MaterialHelper {
  73304. /**
  73305. * Bind the current view position to an effect.
  73306. * @param effect The effect to be bound
  73307. * @param scene The scene the eyes position is used from
  73308. */
  73309. static BindEyePosition(effect: Effect, scene: Scene): void;
  73310. /**
  73311. * Helps preparing the defines values about the UVs in used in the effect.
  73312. * UVs are shared as much as we can accross channels in the shaders.
  73313. * @param texture The texture we are preparing the UVs for
  73314. * @param defines The defines to update
  73315. * @param key The channel key "diffuse", "specular"... used in the shader
  73316. */
  73317. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73318. /**
  73319. * Binds a texture matrix value to its corrsponding uniform
  73320. * @param texture The texture to bind the matrix for
  73321. * @param uniformBuffer The uniform buffer receivin the data
  73322. * @param key The channel key "diffuse", "specular"... used in the shader
  73323. */
  73324. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73325. /**
  73326. * Gets the current status of the fog (should it be enabled?)
  73327. * @param mesh defines the mesh to evaluate for fog support
  73328. * @param scene defines the hosting scene
  73329. * @returns true if fog must be enabled
  73330. */
  73331. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73332. /**
  73333. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73334. * @param mesh defines the current mesh
  73335. * @param scene defines the current scene
  73336. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73337. * @param pointsCloud defines if point cloud rendering has to be turned on
  73338. * @param fogEnabled defines if fog has to be turned on
  73339. * @param alphaTest defines if alpha testing has to be turned on
  73340. * @param defines defines the current list of defines
  73341. */
  73342. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73343. /**
  73344. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73345. * @param scene defines the current scene
  73346. * @param engine defines the current engine
  73347. * @param defines specifies the list of active defines
  73348. * @param useInstances defines if instances have to be turned on
  73349. * @param useClipPlane defines if clip plane have to be turned on
  73350. */
  73351. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73352. /**
  73353. * Prepares the defines for bones
  73354. * @param mesh The mesh containing the geometry data we will draw
  73355. * @param defines The defines to update
  73356. */
  73357. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73358. /**
  73359. * Prepares the defines for morph targets
  73360. * @param mesh The mesh containing the geometry data we will draw
  73361. * @param defines The defines to update
  73362. */
  73363. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73364. /**
  73365. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73366. * @param mesh The mesh containing the geometry data we will draw
  73367. * @param defines The defines to update
  73368. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73369. * @param useBones Precise whether bones should be used or not (override mesh info)
  73370. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73371. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73372. * @returns false if defines are considered not dirty and have not been checked
  73373. */
  73374. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73375. /**
  73376. * Prepares the defines related to multiview
  73377. * @param scene The scene we are intending to draw
  73378. * @param defines The defines to update
  73379. */
  73380. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73381. /**
  73382. * Prepares the defines related to the light information passed in parameter
  73383. * @param scene The scene we are intending to draw
  73384. * @param mesh The mesh the effect is compiling for
  73385. * @param light The light the effect is compiling for
  73386. * @param lightIndex The index of the light
  73387. * @param defines The defines to update
  73388. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73389. * @param state Defines the current state regarding what is needed (normals, etc...)
  73390. */
  73391. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73392. needNormals: boolean;
  73393. needRebuild: boolean;
  73394. shadowEnabled: boolean;
  73395. specularEnabled: boolean;
  73396. lightmapMode: boolean;
  73397. }): void;
  73398. /**
  73399. * Prepares the defines related to the light information passed in parameter
  73400. * @param scene The scene we are intending to draw
  73401. * @param mesh The mesh the effect is compiling for
  73402. * @param defines The defines to update
  73403. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73404. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73405. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73406. * @returns true if normals will be required for the rest of the effect
  73407. */
  73408. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73409. /**
  73410. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73411. * @param lightIndex defines the light index
  73412. * @param uniformsList The uniform list
  73413. * @param samplersList The sampler list
  73414. * @param projectedLightTexture defines if projected texture must be used
  73415. * @param uniformBuffersList defines an optional list of uniform buffers
  73416. */
  73417. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73418. /**
  73419. * Prepares the uniforms and samplers list to be used in the effect
  73420. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73421. * @param samplersList The sampler list
  73422. * @param defines The defines helping in the list generation
  73423. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73424. */
  73425. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73426. /**
  73427. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73428. * @param defines The defines to update while falling back
  73429. * @param fallbacks The authorized effect fallbacks
  73430. * @param maxSimultaneousLights The maximum number of lights allowed
  73431. * @param rank the current rank of the Effect
  73432. * @returns The newly affected rank
  73433. */
  73434. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73435. private static _TmpMorphInfluencers;
  73436. /**
  73437. * Prepares the list of attributes required for morph targets according to the effect defines.
  73438. * @param attribs The current list of supported attribs
  73439. * @param mesh The mesh to prepare the morph targets attributes for
  73440. * @param influencers The number of influencers
  73441. */
  73442. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73443. /**
  73444. * Prepares the list of attributes required for morph targets according to the effect defines.
  73445. * @param attribs The current list of supported attribs
  73446. * @param mesh The mesh to prepare the morph targets attributes for
  73447. * @param defines The current Defines of the effect
  73448. */
  73449. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73450. /**
  73451. * Prepares the list of attributes required for bones according to the effect defines.
  73452. * @param attribs The current list of supported attribs
  73453. * @param mesh The mesh to prepare the bones attributes for
  73454. * @param defines The current Defines of the effect
  73455. * @param fallbacks The current efffect fallback strategy
  73456. */
  73457. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73458. /**
  73459. * Check and prepare the list of attributes required for instances according to the effect defines.
  73460. * @param attribs The current list of supported attribs
  73461. * @param defines The current MaterialDefines of the effect
  73462. */
  73463. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73464. /**
  73465. * Add the list of attributes required for instances to the attribs array.
  73466. * @param attribs The current list of supported attribs
  73467. */
  73468. static PushAttributesForInstances(attribs: string[]): void;
  73469. /**
  73470. * Binds the light shadow information to the effect for the given mesh.
  73471. * @param light The light containing the generator
  73472. * @param scene The scene the lights belongs to
  73473. * @param mesh The mesh we are binding the information to render
  73474. * @param lightIndex The light index in the effect used to render the mesh
  73475. * @param effect The effect we are binding the data to
  73476. */
  73477. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73478. /**
  73479. * Binds the light information to the effect.
  73480. * @param light The light containing the generator
  73481. * @param effect The effect we are binding the data to
  73482. * @param lightIndex The light index in the effect used to render
  73483. */
  73484. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73485. /**
  73486. * Binds the lights information from the scene to the effect for the given mesh.
  73487. * @param light Light to bind
  73488. * @param lightIndex Light index
  73489. * @param scene The scene where the light belongs to
  73490. * @param mesh The mesh we are binding the information to render
  73491. * @param effect The effect we are binding the data to
  73492. * @param useSpecular Defines if specular is supported
  73493. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73494. */
  73495. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73496. /**
  73497. * Binds the lights information from the scene to the effect for the given mesh.
  73498. * @param scene The scene the lights belongs to
  73499. * @param mesh The mesh we are binding the information to render
  73500. * @param effect The effect we are binding the data to
  73501. * @param defines The generated defines for the effect
  73502. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73503. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73504. */
  73505. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73506. private static _tempFogColor;
  73507. /**
  73508. * Binds the fog information from the scene to the effect for the given mesh.
  73509. * @param scene The scene the lights belongs to
  73510. * @param mesh The mesh we are binding the information to render
  73511. * @param effect The effect we are binding the data to
  73512. * @param linearSpace Defines if the fog effect is applied in linear space
  73513. */
  73514. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73515. /**
  73516. * Binds the bones information from the mesh to the effect.
  73517. * @param mesh The mesh we are binding the information to render
  73518. * @param effect The effect we are binding the data to
  73519. */
  73520. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73521. /**
  73522. * Binds the morph targets information from the mesh to the effect.
  73523. * @param abstractMesh The mesh we are binding the information to render
  73524. * @param effect The effect we are binding the data to
  73525. */
  73526. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73527. /**
  73528. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73529. * @param defines The generated defines used in the effect
  73530. * @param effect The effect we are binding the data to
  73531. * @param scene The scene we are willing to render with logarithmic scale for
  73532. */
  73533. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73534. /**
  73535. * Binds the clip plane information from the scene to the effect.
  73536. * @param scene The scene the clip plane information are extracted from
  73537. * @param effect The effect we are binding the data to
  73538. */
  73539. static BindClipPlane(effect: Effect, scene: Scene): void;
  73540. }
  73541. }
  73542. declare module BABYLON {
  73543. /** @hidden */
  73544. export var packingFunctions: {
  73545. name: string;
  73546. shader: string;
  73547. };
  73548. }
  73549. declare module BABYLON {
  73550. /** @hidden */
  73551. export var shadowMapPixelShader: {
  73552. name: string;
  73553. shader: string;
  73554. };
  73555. }
  73556. declare module BABYLON {
  73557. /** @hidden */
  73558. export var bonesDeclaration: {
  73559. name: string;
  73560. shader: string;
  73561. };
  73562. }
  73563. declare module BABYLON {
  73564. /** @hidden */
  73565. export var morphTargetsVertexGlobalDeclaration: {
  73566. name: string;
  73567. shader: string;
  73568. };
  73569. }
  73570. declare module BABYLON {
  73571. /** @hidden */
  73572. export var morphTargetsVertexDeclaration: {
  73573. name: string;
  73574. shader: string;
  73575. };
  73576. }
  73577. declare module BABYLON {
  73578. /** @hidden */
  73579. export var instancesDeclaration: {
  73580. name: string;
  73581. shader: string;
  73582. };
  73583. }
  73584. declare module BABYLON {
  73585. /** @hidden */
  73586. export var helperFunctions: {
  73587. name: string;
  73588. shader: string;
  73589. };
  73590. }
  73591. declare module BABYLON {
  73592. /** @hidden */
  73593. export var morphTargetsVertex: {
  73594. name: string;
  73595. shader: string;
  73596. };
  73597. }
  73598. declare module BABYLON {
  73599. /** @hidden */
  73600. export var instancesVertex: {
  73601. name: string;
  73602. shader: string;
  73603. };
  73604. }
  73605. declare module BABYLON {
  73606. /** @hidden */
  73607. export var bonesVertex: {
  73608. name: string;
  73609. shader: string;
  73610. };
  73611. }
  73612. declare module BABYLON {
  73613. /** @hidden */
  73614. export var shadowMapVertexShader: {
  73615. name: string;
  73616. shader: string;
  73617. };
  73618. }
  73619. declare module BABYLON {
  73620. /** @hidden */
  73621. export var depthBoxBlurPixelShader: {
  73622. name: string;
  73623. shader: string;
  73624. };
  73625. }
  73626. declare module BABYLON {
  73627. /**
  73628. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73629. */
  73630. export interface ICustomShaderOptions {
  73631. /**
  73632. * Gets or sets the custom shader name to use
  73633. */
  73634. shaderName: string;
  73635. /**
  73636. * The list of attribute names used in the shader
  73637. */
  73638. attributes?: string[];
  73639. /**
  73640. * The list of unifrom names used in the shader
  73641. */
  73642. uniforms?: string[];
  73643. /**
  73644. * The list of sampler names used in the shader
  73645. */
  73646. samplers?: string[];
  73647. /**
  73648. * The list of defines used in the shader
  73649. */
  73650. defines?: string[];
  73651. }
  73652. /**
  73653. * Interface to implement to create a shadow generator compatible with BJS.
  73654. */
  73655. export interface IShadowGenerator {
  73656. /**
  73657. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73658. * @returns The render target texture if present otherwise, null
  73659. */
  73660. getShadowMap(): Nullable<RenderTargetTexture>;
  73661. /**
  73662. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73663. * @returns The render target texture if the shadow map is present otherwise, null
  73664. */
  73665. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73666. /**
  73667. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73668. * @param subMesh The submesh we want to render in the shadow map
  73669. * @param useInstances Defines wether will draw in the map using instances
  73670. * @returns true if ready otherwise, false
  73671. */
  73672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73673. /**
  73674. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73675. * @param defines Defines of the material we want to update
  73676. * @param lightIndex Index of the light in the enabled light list of the material
  73677. */
  73678. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73679. /**
  73680. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73681. * defined in the generator but impacting the effect).
  73682. * It implies the unifroms available on the materials are the standard BJS ones.
  73683. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73684. * @param effect The effect we are binfing the information for
  73685. */
  73686. bindShadowLight(lightIndex: string, effect: Effect): void;
  73687. /**
  73688. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73689. * (eq to shadow prjection matrix * light transform matrix)
  73690. * @returns The transform matrix used to create the shadow map
  73691. */
  73692. getTransformMatrix(): Matrix;
  73693. /**
  73694. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73695. * Cube and 2D textures for instance.
  73696. */
  73697. recreateShadowMap(): void;
  73698. /**
  73699. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73700. * @param onCompiled Callback triggered at the and of the effects compilation
  73701. * @param options Sets of optional options forcing the compilation with different modes
  73702. */
  73703. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73704. useInstances: boolean;
  73705. }>): void;
  73706. /**
  73707. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73708. * @param options Sets of optional options forcing the compilation with different modes
  73709. * @returns A promise that resolves when the compilation completes
  73710. */
  73711. forceCompilationAsync(options?: Partial<{
  73712. useInstances: boolean;
  73713. }>): Promise<void>;
  73714. /**
  73715. * Serializes the shadow generator setup to a json object.
  73716. * @returns The serialized JSON object
  73717. */
  73718. serialize(): any;
  73719. /**
  73720. * Disposes the Shadow map and related Textures and effects.
  73721. */
  73722. dispose(): void;
  73723. }
  73724. /**
  73725. * Default implementation IShadowGenerator.
  73726. * This is the main object responsible of generating shadows in the framework.
  73727. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73728. */
  73729. export class ShadowGenerator implements IShadowGenerator {
  73730. /**
  73731. * Shadow generator mode None: no filtering applied.
  73732. */
  73733. static readonly FILTER_NONE: number;
  73734. /**
  73735. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73736. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73737. */
  73738. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73739. /**
  73740. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73741. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73742. */
  73743. static readonly FILTER_POISSONSAMPLING: number;
  73744. /**
  73745. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73746. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73747. */
  73748. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73749. /**
  73750. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73751. * edge artifacts on steep falloff.
  73752. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73753. */
  73754. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73755. /**
  73756. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73757. * edge artifacts on steep falloff.
  73758. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73759. */
  73760. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73761. /**
  73762. * Shadow generator mode PCF: Percentage Closer Filtering
  73763. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73764. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73765. */
  73766. static readonly FILTER_PCF: number;
  73767. /**
  73768. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73769. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73770. * Contact Hardening
  73771. */
  73772. static readonly FILTER_PCSS: number;
  73773. /**
  73774. * Reserved for PCF and PCSS
  73775. * Highest Quality.
  73776. *
  73777. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73778. *
  73779. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73780. */
  73781. static readonly QUALITY_HIGH: number;
  73782. /**
  73783. * Reserved for PCF and PCSS
  73784. * Good tradeoff for quality/perf cross devices
  73785. *
  73786. * Execute PCF on a 3*3 kernel.
  73787. *
  73788. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73789. */
  73790. static readonly QUALITY_MEDIUM: number;
  73791. /**
  73792. * Reserved for PCF and PCSS
  73793. * The lowest quality but the fastest.
  73794. *
  73795. * Execute PCF on a 1*1 kernel.
  73796. *
  73797. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73798. */
  73799. static readonly QUALITY_LOW: number;
  73800. /** Gets or sets the custom shader name to use */
  73801. customShaderOptions: ICustomShaderOptions;
  73802. /**
  73803. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73804. */
  73805. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73806. /**
  73807. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73808. */
  73809. onAfterShadowMapRenderObservable: Observable<Effect>;
  73810. /**
  73811. * Observable triggered before a mesh is rendered in the shadow map.
  73812. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73813. */
  73814. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73815. /**
  73816. * Observable triggered after a mesh is rendered in the shadow map.
  73817. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73818. */
  73819. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73820. private _bias;
  73821. /**
  73822. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73823. */
  73824. /**
  73825. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73826. */
  73827. bias: number;
  73828. private _normalBias;
  73829. /**
  73830. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73831. */
  73832. /**
  73833. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73834. */
  73835. normalBias: number;
  73836. private _blurBoxOffset;
  73837. /**
  73838. * Gets the blur box offset: offset applied during the blur pass.
  73839. * Only useful if useKernelBlur = false
  73840. */
  73841. /**
  73842. * Sets the blur box offset: offset applied during the blur pass.
  73843. * Only useful if useKernelBlur = false
  73844. */
  73845. blurBoxOffset: number;
  73846. private _blurScale;
  73847. /**
  73848. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73849. * 2 means half of the size.
  73850. */
  73851. /**
  73852. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73853. * 2 means half of the size.
  73854. */
  73855. blurScale: number;
  73856. private _blurKernel;
  73857. /**
  73858. * Gets the blur kernel: kernel size of the blur pass.
  73859. * Only useful if useKernelBlur = true
  73860. */
  73861. /**
  73862. * Sets the blur kernel: kernel size of the blur pass.
  73863. * Only useful if useKernelBlur = true
  73864. */
  73865. blurKernel: number;
  73866. private _useKernelBlur;
  73867. /**
  73868. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73869. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73870. */
  73871. /**
  73872. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73873. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73874. */
  73875. useKernelBlur: boolean;
  73876. private _depthScale;
  73877. /**
  73878. * Gets the depth scale used in ESM mode.
  73879. */
  73880. /**
  73881. * Sets the depth scale used in ESM mode.
  73882. * This can override the scale stored on the light.
  73883. */
  73884. depthScale: number;
  73885. private _filter;
  73886. /**
  73887. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73888. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73889. */
  73890. /**
  73891. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73892. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73893. */
  73894. filter: number;
  73895. /**
  73896. * Gets if the current filter is set to Poisson Sampling.
  73897. */
  73898. /**
  73899. * Sets the current filter to Poisson Sampling.
  73900. */
  73901. usePoissonSampling: boolean;
  73902. /**
  73903. * Gets if the current filter is set to ESM.
  73904. */
  73905. /**
  73906. * Sets the current filter is to ESM.
  73907. */
  73908. useExponentialShadowMap: boolean;
  73909. /**
  73910. * Gets if the current filter is set to filtered ESM.
  73911. */
  73912. /**
  73913. * Gets if the current filter is set to filtered ESM.
  73914. */
  73915. useBlurExponentialShadowMap: boolean;
  73916. /**
  73917. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73918. * exponential to prevent steep falloff artifacts).
  73919. */
  73920. /**
  73921. * Sets the current filter to "close ESM" (using the inverse of the
  73922. * exponential to prevent steep falloff artifacts).
  73923. */
  73924. useCloseExponentialShadowMap: boolean;
  73925. /**
  73926. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73927. * exponential to prevent steep falloff artifacts).
  73928. */
  73929. /**
  73930. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73931. * exponential to prevent steep falloff artifacts).
  73932. */
  73933. useBlurCloseExponentialShadowMap: boolean;
  73934. /**
  73935. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73936. */
  73937. /**
  73938. * Sets the current filter to "PCF" (percentage closer filtering).
  73939. */
  73940. usePercentageCloserFiltering: boolean;
  73941. private _filteringQuality;
  73942. /**
  73943. * Gets the PCF or PCSS Quality.
  73944. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73945. */
  73946. /**
  73947. * Sets the PCF or PCSS Quality.
  73948. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73949. */
  73950. filteringQuality: number;
  73951. /**
  73952. * Gets if the current filter is set to "PCSS" (contact hardening).
  73953. */
  73954. /**
  73955. * Sets the current filter to "PCSS" (contact hardening).
  73956. */
  73957. useContactHardeningShadow: boolean;
  73958. private _contactHardeningLightSizeUVRatio;
  73959. /**
  73960. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73961. * Using a ratio helps keeping shape stability independently of the map size.
  73962. *
  73963. * It does not account for the light projection as it was having too much
  73964. * instability during the light setup or during light position changes.
  73965. *
  73966. * Only valid if useContactHardeningShadow is true.
  73967. */
  73968. /**
  73969. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73970. * Using a ratio helps keeping shape stability independently of the map size.
  73971. *
  73972. * It does not account for the light projection as it was having too much
  73973. * instability during the light setup or during light position changes.
  73974. *
  73975. * Only valid if useContactHardeningShadow is true.
  73976. */
  73977. contactHardeningLightSizeUVRatio: number;
  73978. private _darkness;
  73979. /** Gets or sets the actual darkness of a shadow */
  73980. darkness: number;
  73981. /**
  73982. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73983. * 0 means strongest and 1 would means no shadow.
  73984. * @returns the darkness.
  73985. */
  73986. getDarkness(): number;
  73987. /**
  73988. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73989. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73990. * @returns the shadow generator allowing fluent coding.
  73991. */
  73992. setDarkness(darkness: number): ShadowGenerator;
  73993. private _transparencyShadow;
  73994. /** Gets or sets the ability to have transparent shadow */
  73995. transparencyShadow: boolean;
  73996. /**
  73997. * Sets the ability to have transparent shadow (boolean).
  73998. * @param transparent True if transparent else False
  73999. * @returns the shadow generator allowing fluent coding
  74000. */
  74001. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74002. private _shadowMap;
  74003. private _shadowMap2;
  74004. /**
  74005. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74006. * @returns The render target texture if present otherwise, null
  74007. */
  74008. getShadowMap(): Nullable<RenderTargetTexture>;
  74009. /**
  74010. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74011. * @returns The render target texture if the shadow map is present otherwise, null
  74012. */
  74013. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74014. /**
  74015. * Gets the class name of that object
  74016. * @returns "ShadowGenerator"
  74017. */
  74018. getClassName(): string;
  74019. /**
  74020. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74021. * @param mesh Mesh to add
  74022. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74023. * @returns the Shadow Generator itself
  74024. */
  74025. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74026. /**
  74027. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74028. * @param mesh Mesh to remove
  74029. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74030. * @returns the Shadow Generator itself
  74031. */
  74032. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74033. /**
  74034. * Controls the extent to which the shadows fade out at the edge of the frustum
  74035. * Used only by directionals and spots
  74036. */
  74037. frustumEdgeFalloff: number;
  74038. private _light;
  74039. /**
  74040. * Returns the associated light object.
  74041. * @returns the light generating the shadow
  74042. */
  74043. getLight(): IShadowLight;
  74044. /**
  74045. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74046. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74047. * It might on the other hand introduce peter panning.
  74048. */
  74049. forceBackFacesOnly: boolean;
  74050. private _scene;
  74051. private _lightDirection;
  74052. private _effect;
  74053. private _viewMatrix;
  74054. private _projectionMatrix;
  74055. private _transformMatrix;
  74056. private _cachedPosition;
  74057. private _cachedDirection;
  74058. private _cachedDefines;
  74059. private _currentRenderID;
  74060. private _boxBlurPostprocess;
  74061. private _kernelBlurXPostprocess;
  74062. private _kernelBlurYPostprocess;
  74063. private _blurPostProcesses;
  74064. private _mapSize;
  74065. private _currentFaceIndex;
  74066. private _currentFaceIndexCache;
  74067. private _textureType;
  74068. private _defaultTextureMatrix;
  74069. /** @hidden */
  74070. static _SceneComponentInitialization: (scene: Scene) => void;
  74071. /**
  74072. * Creates a ShadowGenerator object.
  74073. * A ShadowGenerator is the required tool to use the shadows.
  74074. * Each light casting shadows needs to use its own ShadowGenerator.
  74075. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74076. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74077. * @param light The light object generating the shadows.
  74078. * @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.
  74079. */
  74080. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74081. private _initializeGenerator;
  74082. private _initializeShadowMap;
  74083. private _initializeBlurRTTAndPostProcesses;
  74084. private _renderForShadowMap;
  74085. private _renderSubMeshForShadowMap;
  74086. private _applyFilterValues;
  74087. /**
  74088. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74089. * @param onCompiled Callback triggered at the and of the effects compilation
  74090. * @param options Sets of optional options forcing the compilation with different modes
  74091. */
  74092. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74093. useInstances: boolean;
  74094. }>): void;
  74095. /**
  74096. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74097. * @param options Sets of optional options forcing the compilation with different modes
  74098. * @returns A promise that resolves when the compilation completes
  74099. */
  74100. forceCompilationAsync(options?: Partial<{
  74101. useInstances: boolean;
  74102. }>): Promise<void>;
  74103. /**
  74104. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74105. * @param subMesh The submesh we want to render in the shadow map
  74106. * @param useInstances Defines wether will draw in the map using instances
  74107. * @returns true if ready otherwise, false
  74108. */
  74109. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74110. /**
  74111. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74112. * @param defines Defines of the material we want to update
  74113. * @param lightIndex Index of the light in the enabled light list of the material
  74114. */
  74115. prepareDefines(defines: any, lightIndex: number): void;
  74116. /**
  74117. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74118. * defined in the generator but impacting the effect).
  74119. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74120. * @param effect The effect we are binfing the information for
  74121. */
  74122. bindShadowLight(lightIndex: string, effect: Effect): void;
  74123. /**
  74124. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74125. * (eq to shadow prjection matrix * light transform matrix)
  74126. * @returns The transform matrix used to create the shadow map
  74127. */
  74128. getTransformMatrix(): Matrix;
  74129. /**
  74130. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74131. * Cube and 2D textures for instance.
  74132. */
  74133. recreateShadowMap(): void;
  74134. private _disposeBlurPostProcesses;
  74135. private _disposeRTTandPostProcesses;
  74136. /**
  74137. * Disposes the ShadowGenerator.
  74138. * Returns nothing.
  74139. */
  74140. dispose(): void;
  74141. /**
  74142. * Serializes the shadow generator setup to a json object.
  74143. * @returns The serialized JSON object
  74144. */
  74145. serialize(): any;
  74146. /**
  74147. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74148. * @param parsedShadowGenerator The JSON object to parse
  74149. * @param scene The scene to create the shadow map for
  74150. * @returns The parsed shadow generator
  74151. */
  74152. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74153. }
  74154. }
  74155. declare module BABYLON {
  74156. /**
  74157. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74158. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74159. * 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.
  74160. */
  74161. export abstract class Light extends Node {
  74162. /**
  74163. * Falloff Default: light is falling off following the material specification:
  74164. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74165. */
  74166. static readonly FALLOFF_DEFAULT: number;
  74167. /**
  74168. * Falloff Physical: light is falling off following the inverse squared distance law.
  74169. */
  74170. static readonly FALLOFF_PHYSICAL: number;
  74171. /**
  74172. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74173. * to enhance interoperability with other engines.
  74174. */
  74175. static readonly FALLOFF_GLTF: number;
  74176. /**
  74177. * Falloff Standard: light is falling off like in the standard material
  74178. * to enhance interoperability with other materials.
  74179. */
  74180. static readonly FALLOFF_STANDARD: number;
  74181. /**
  74182. * If every light affecting the material is in this lightmapMode,
  74183. * material.lightmapTexture adds or multiplies
  74184. * (depends on material.useLightmapAsShadowmap)
  74185. * after every other light calculations.
  74186. */
  74187. static readonly LIGHTMAP_DEFAULT: number;
  74188. /**
  74189. * material.lightmapTexture as only diffuse lighting from this light
  74190. * adds only specular lighting from this light
  74191. * adds dynamic shadows
  74192. */
  74193. static readonly LIGHTMAP_SPECULAR: number;
  74194. /**
  74195. * material.lightmapTexture as only lighting
  74196. * no light calculation from this light
  74197. * only adds dynamic shadows from this light
  74198. */
  74199. static readonly LIGHTMAP_SHADOWSONLY: number;
  74200. /**
  74201. * Each light type uses the default quantity according to its type:
  74202. * point/spot lights use luminous intensity
  74203. * directional lights use illuminance
  74204. */
  74205. static readonly INTENSITYMODE_AUTOMATIC: number;
  74206. /**
  74207. * lumen (lm)
  74208. */
  74209. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74210. /**
  74211. * candela (lm/sr)
  74212. */
  74213. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74214. /**
  74215. * lux (lm/m^2)
  74216. */
  74217. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74218. /**
  74219. * nit (cd/m^2)
  74220. */
  74221. static readonly INTENSITYMODE_LUMINANCE: number;
  74222. /**
  74223. * Light type const id of the point light.
  74224. */
  74225. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74226. /**
  74227. * Light type const id of the directional light.
  74228. */
  74229. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74230. /**
  74231. * Light type const id of the spot light.
  74232. */
  74233. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74234. /**
  74235. * Light type const id of the hemispheric light.
  74236. */
  74237. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74238. /**
  74239. * Diffuse gives the basic color to an object.
  74240. */
  74241. diffuse: Color3;
  74242. /**
  74243. * Specular produces a highlight color on an object.
  74244. * Note: This is note affecting PBR materials.
  74245. */
  74246. specular: Color3;
  74247. /**
  74248. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74249. * falling off base on range or angle.
  74250. * This can be set to any values in Light.FALLOFF_x.
  74251. *
  74252. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74253. * other types of materials.
  74254. */
  74255. falloffType: number;
  74256. /**
  74257. * Strength of the light.
  74258. * Note: By default it is define in the framework own unit.
  74259. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74260. */
  74261. intensity: number;
  74262. private _range;
  74263. protected _inverseSquaredRange: number;
  74264. /**
  74265. * Defines how far from the source the light is impacting in scene units.
  74266. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74267. */
  74268. /**
  74269. * Defines how far from the source the light is impacting in scene units.
  74270. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74271. */
  74272. range: number;
  74273. /**
  74274. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74275. * of light.
  74276. */
  74277. private _photometricScale;
  74278. private _intensityMode;
  74279. /**
  74280. * Gets the photometric scale used to interpret the intensity.
  74281. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74282. */
  74283. /**
  74284. * Sets the photometric scale used to interpret the intensity.
  74285. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74286. */
  74287. intensityMode: number;
  74288. private _radius;
  74289. /**
  74290. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74291. */
  74292. /**
  74293. * sets the light radius used by PBR Materials to simulate soft area lights.
  74294. */
  74295. radius: number;
  74296. private _renderPriority;
  74297. /**
  74298. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74299. * exceeding the number allowed of the materials.
  74300. */
  74301. renderPriority: number;
  74302. private _shadowEnabled;
  74303. /**
  74304. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74305. * the current shadow generator.
  74306. */
  74307. /**
  74308. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74309. * the current shadow generator.
  74310. */
  74311. shadowEnabled: boolean;
  74312. private _includedOnlyMeshes;
  74313. /**
  74314. * Gets the only meshes impacted by this light.
  74315. */
  74316. /**
  74317. * Sets the only meshes impacted by this light.
  74318. */
  74319. includedOnlyMeshes: AbstractMesh[];
  74320. private _excludedMeshes;
  74321. /**
  74322. * Gets the meshes not impacted by this light.
  74323. */
  74324. /**
  74325. * Sets the meshes not impacted by this light.
  74326. */
  74327. excludedMeshes: AbstractMesh[];
  74328. private _excludeWithLayerMask;
  74329. /**
  74330. * Gets the layer id use to find what meshes are not impacted by the light.
  74331. * Inactive if 0
  74332. */
  74333. /**
  74334. * Sets the layer id use to find what meshes are not impacted by the light.
  74335. * Inactive if 0
  74336. */
  74337. excludeWithLayerMask: number;
  74338. private _includeOnlyWithLayerMask;
  74339. /**
  74340. * Gets the layer id use to find what meshes are impacted by the light.
  74341. * Inactive if 0
  74342. */
  74343. /**
  74344. * Sets the layer id use to find what meshes are impacted by the light.
  74345. * Inactive if 0
  74346. */
  74347. includeOnlyWithLayerMask: number;
  74348. private _lightmapMode;
  74349. /**
  74350. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74351. */
  74352. /**
  74353. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74354. */
  74355. lightmapMode: number;
  74356. /**
  74357. * Shadow generator associted to the light.
  74358. * @hidden Internal use only.
  74359. */
  74360. _shadowGenerator: Nullable<IShadowGenerator>;
  74361. /**
  74362. * @hidden Internal use only.
  74363. */
  74364. _excludedMeshesIds: string[];
  74365. /**
  74366. * @hidden Internal use only.
  74367. */
  74368. _includedOnlyMeshesIds: string[];
  74369. /**
  74370. * The current light unifom buffer.
  74371. * @hidden Internal use only.
  74372. */
  74373. _uniformBuffer: UniformBuffer;
  74374. /**
  74375. * Creates a Light object in the scene.
  74376. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74377. * @param name The firendly name of the light
  74378. * @param scene The scene the light belongs too
  74379. */
  74380. constructor(name: string, scene: Scene);
  74381. protected abstract _buildUniformLayout(): void;
  74382. /**
  74383. * Sets the passed Effect "effect" with the Light information.
  74384. * @param effect The effect to update
  74385. * @param lightIndex The index of the light in the effect to update
  74386. * @returns The light
  74387. */
  74388. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74389. /**
  74390. * Returns the string "Light".
  74391. * @returns the class name
  74392. */
  74393. getClassName(): string;
  74394. /** @hidden */
  74395. readonly _isLight: boolean;
  74396. /**
  74397. * Converts the light information to a readable string for debug purpose.
  74398. * @param fullDetails Supports for multiple levels of logging within scene loading
  74399. * @returns the human readable light info
  74400. */
  74401. toString(fullDetails?: boolean): string;
  74402. /** @hidden */
  74403. protected _syncParentEnabledState(): void;
  74404. /**
  74405. * Set the enabled state of this node.
  74406. * @param value - the new enabled state
  74407. */
  74408. setEnabled(value: boolean): void;
  74409. /**
  74410. * Returns the Light associated shadow generator if any.
  74411. * @return the associated shadow generator.
  74412. */
  74413. getShadowGenerator(): Nullable<IShadowGenerator>;
  74414. /**
  74415. * Returns a Vector3, the absolute light position in the World.
  74416. * @returns the world space position of the light
  74417. */
  74418. getAbsolutePosition(): Vector3;
  74419. /**
  74420. * Specifies if the light will affect the passed mesh.
  74421. * @param mesh The mesh to test against the light
  74422. * @return true the mesh is affected otherwise, false.
  74423. */
  74424. canAffectMesh(mesh: AbstractMesh): boolean;
  74425. /**
  74426. * Sort function to order lights for rendering.
  74427. * @param a First Light object to compare to second.
  74428. * @param b Second Light object to compare first.
  74429. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74430. */
  74431. static CompareLightsPriority(a: Light, b: Light): number;
  74432. /**
  74433. * Releases resources associated with this node.
  74434. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74435. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74436. */
  74437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74438. /**
  74439. * Returns the light type ID (integer).
  74440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74441. */
  74442. getTypeID(): number;
  74443. /**
  74444. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74445. * @returns the scaled intensity in intensity mode unit
  74446. */
  74447. getScaledIntensity(): number;
  74448. /**
  74449. * Returns a new Light object, named "name", from the current one.
  74450. * @param name The name of the cloned light
  74451. * @returns the new created light
  74452. */
  74453. clone(name: string): Nullable<Light>;
  74454. /**
  74455. * Serializes the current light into a Serialization object.
  74456. * @returns the serialized object.
  74457. */
  74458. serialize(): any;
  74459. /**
  74460. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74461. * This new light is named "name" and added to the passed scene.
  74462. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74463. * @param name The friendly name of the light
  74464. * @param scene The scene the new light will belong to
  74465. * @returns the constructor function
  74466. */
  74467. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74468. /**
  74469. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74470. * @param parsedLight The JSON representation of the light
  74471. * @param scene The scene to create the parsed light in
  74472. * @returns the created light after parsing
  74473. */
  74474. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74475. private _hookArrayForExcluded;
  74476. private _hookArrayForIncludedOnly;
  74477. private _resyncMeshes;
  74478. /**
  74479. * Forces the meshes to update their light related information in their rendering used effects
  74480. * @hidden Internal Use Only
  74481. */
  74482. _markMeshesAsLightDirty(): void;
  74483. /**
  74484. * Recomputes the cached photometric scale if needed.
  74485. */
  74486. private _computePhotometricScale;
  74487. /**
  74488. * Returns the Photometric Scale according to the light type and intensity mode.
  74489. */
  74490. private _getPhotometricScale;
  74491. /**
  74492. * Reorder the light in the scene according to their defined priority.
  74493. * @hidden Internal Use Only
  74494. */
  74495. _reorderLightsInScene(): void;
  74496. /**
  74497. * Prepares the list of defines specific to the light type.
  74498. * @param defines the list of defines
  74499. * @param lightIndex defines the index of the light for the effect
  74500. */
  74501. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74502. }
  74503. }
  74504. declare module BABYLON {
  74505. /**
  74506. * Interface used to define Action
  74507. */
  74508. export interface IAction {
  74509. /**
  74510. * Trigger for the action
  74511. */
  74512. trigger: number;
  74513. /** Options of the trigger */
  74514. triggerOptions: any;
  74515. /**
  74516. * Gets the trigger parameters
  74517. * @returns the trigger parameters
  74518. */
  74519. getTriggerParameter(): any;
  74520. /**
  74521. * Internal only - executes current action event
  74522. * @hidden
  74523. */
  74524. _executeCurrent(evt?: ActionEvent): void;
  74525. /**
  74526. * Serialize placeholder for child classes
  74527. * @param parent of child
  74528. * @returns the serialized object
  74529. */
  74530. serialize(parent: any): any;
  74531. /**
  74532. * Internal only
  74533. * @hidden
  74534. */
  74535. _prepare(): void;
  74536. /**
  74537. * Internal only - manager for action
  74538. * @hidden
  74539. */
  74540. _actionManager: AbstractActionManager;
  74541. /**
  74542. * Adds action to chain of actions, may be a DoNothingAction
  74543. * @param action defines the next action to execute
  74544. * @returns The action passed in
  74545. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74546. */
  74547. then(action: IAction): IAction;
  74548. }
  74549. /**
  74550. * The action to be carried out following a trigger
  74551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74552. */
  74553. export class Action implements IAction {
  74554. /** the trigger, with or without parameters, for the action */
  74555. triggerOptions: any;
  74556. /**
  74557. * Trigger for the action
  74558. */
  74559. trigger: number;
  74560. /**
  74561. * Internal only - manager for action
  74562. * @hidden
  74563. */
  74564. _actionManager: ActionManager;
  74565. private _nextActiveAction;
  74566. private _child;
  74567. private _condition?;
  74568. private _triggerParameter;
  74569. /**
  74570. * An event triggered prior to action being executed.
  74571. */
  74572. onBeforeExecuteObservable: Observable<Action>;
  74573. /**
  74574. * Creates a new Action
  74575. * @param triggerOptions the trigger, with or without parameters, for the action
  74576. * @param condition an optional determinant of action
  74577. */
  74578. constructor(
  74579. /** the trigger, with or without parameters, for the action */
  74580. triggerOptions: any, condition?: Condition);
  74581. /**
  74582. * Internal only
  74583. * @hidden
  74584. */
  74585. _prepare(): void;
  74586. /**
  74587. * Gets the trigger parameters
  74588. * @returns the trigger parameters
  74589. */
  74590. getTriggerParameter(): any;
  74591. /**
  74592. * Internal only - executes current action event
  74593. * @hidden
  74594. */
  74595. _executeCurrent(evt?: ActionEvent): void;
  74596. /**
  74597. * Execute placeholder for child classes
  74598. * @param evt optional action event
  74599. */
  74600. execute(evt?: ActionEvent): void;
  74601. /**
  74602. * Skips to next active action
  74603. */
  74604. skipToNextActiveAction(): void;
  74605. /**
  74606. * Adds action to chain of actions, may be a DoNothingAction
  74607. * @param action defines the next action to execute
  74608. * @returns The action passed in
  74609. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74610. */
  74611. then(action: Action): Action;
  74612. /**
  74613. * Internal only
  74614. * @hidden
  74615. */
  74616. _getProperty(propertyPath: string): string;
  74617. /**
  74618. * Internal only
  74619. * @hidden
  74620. */
  74621. _getEffectiveTarget(target: any, propertyPath: string): any;
  74622. /**
  74623. * Serialize placeholder for child classes
  74624. * @param parent of child
  74625. * @returns the serialized object
  74626. */
  74627. serialize(parent: any): any;
  74628. /**
  74629. * Internal only called by serialize
  74630. * @hidden
  74631. */
  74632. protected _serialize(serializedAction: any, parent?: any): any;
  74633. /**
  74634. * Internal only
  74635. * @hidden
  74636. */
  74637. static _SerializeValueAsString: (value: any) => string;
  74638. /**
  74639. * Internal only
  74640. * @hidden
  74641. */
  74642. static _GetTargetProperty: (target: Node | Scene) => {
  74643. name: string;
  74644. targetType: string;
  74645. value: string;
  74646. };
  74647. }
  74648. }
  74649. declare module BABYLON {
  74650. /**
  74651. * A Condition applied to an Action
  74652. */
  74653. export class Condition {
  74654. /**
  74655. * Internal only - manager for action
  74656. * @hidden
  74657. */
  74658. _actionManager: ActionManager;
  74659. /**
  74660. * Internal only
  74661. * @hidden
  74662. */
  74663. _evaluationId: number;
  74664. /**
  74665. * Internal only
  74666. * @hidden
  74667. */
  74668. _currentResult: boolean;
  74669. /**
  74670. * Creates a new Condition
  74671. * @param actionManager the manager of the action the condition is applied to
  74672. */
  74673. constructor(actionManager: ActionManager);
  74674. /**
  74675. * Check if the current condition is valid
  74676. * @returns a boolean
  74677. */
  74678. isValid(): boolean;
  74679. /**
  74680. * Internal only
  74681. * @hidden
  74682. */
  74683. _getProperty(propertyPath: string): string;
  74684. /**
  74685. * Internal only
  74686. * @hidden
  74687. */
  74688. _getEffectiveTarget(target: any, propertyPath: string): any;
  74689. /**
  74690. * Serialize placeholder for child classes
  74691. * @returns the serialized object
  74692. */
  74693. serialize(): any;
  74694. /**
  74695. * Internal only
  74696. * @hidden
  74697. */
  74698. protected _serialize(serializedCondition: any): any;
  74699. }
  74700. /**
  74701. * Defines specific conditional operators as extensions of Condition
  74702. */
  74703. export class ValueCondition extends Condition {
  74704. /** path to specify the property of the target the conditional operator uses */
  74705. propertyPath: string;
  74706. /** the value compared by the conditional operator against the current value of the property */
  74707. value: any;
  74708. /** the conditional operator, default ValueCondition.IsEqual */
  74709. operator: number;
  74710. /**
  74711. * Internal only
  74712. * @hidden
  74713. */
  74714. private static _IsEqual;
  74715. /**
  74716. * Internal only
  74717. * @hidden
  74718. */
  74719. private static _IsDifferent;
  74720. /**
  74721. * Internal only
  74722. * @hidden
  74723. */
  74724. private static _IsGreater;
  74725. /**
  74726. * Internal only
  74727. * @hidden
  74728. */
  74729. private static _IsLesser;
  74730. /**
  74731. * returns the number for IsEqual
  74732. */
  74733. static readonly IsEqual: number;
  74734. /**
  74735. * Returns the number for IsDifferent
  74736. */
  74737. static readonly IsDifferent: number;
  74738. /**
  74739. * Returns the number for IsGreater
  74740. */
  74741. static readonly IsGreater: number;
  74742. /**
  74743. * Returns the number for IsLesser
  74744. */
  74745. static readonly IsLesser: number;
  74746. /**
  74747. * Internal only The action manager for the condition
  74748. * @hidden
  74749. */
  74750. _actionManager: ActionManager;
  74751. /**
  74752. * Internal only
  74753. * @hidden
  74754. */
  74755. private _target;
  74756. /**
  74757. * Internal only
  74758. * @hidden
  74759. */
  74760. private _effectiveTarget;
  74761. /**
  74762. * Internal only
  74763. * @hidden
  74764. */
  74765. private _property;
  74766. /**
  74767. * Creates a new ValueCondition
  74768. * @param actionManager manager for the action the condition applies to
  74769. * @param target for the action
  74770. * @param propertyPath path to specify the property of the target the conditional operator uses
  74771. * @param value the value compared by the conditional operator against the current value of the property
  74772. * @param operator the conditional operator, default ValueCondition.IsEqual
  74773. */
  74774. constructor(actionManager: ActionManager, target: any,
  74775. /** path to specify the property of the target the conditional operator uses */
  74776. propertyPath: string,
  74777. /** the value compared by the conditional operator against the current value of the property */
  74778. value: any,
  74779. /** the conditional operator, default ValueCondition.IsEqual */
  74780. operator?: number);
  74781. /**
  74782. * Compares the given value with the property value for the specified conditional operator
  74783. * @returns the result of the comparison
  74784. */
  74785. isValid(): boolean;
  74786. /**
  74787. * Serialize the ValueCondition into a JSON compatible object
  74788. * @returns serialization object
  74789. */
  74790. serialize(): any;
  74791. /**
  74792. * Gets the name of the conditional operator for the ValueCondition
  74793. * @param operator the conditional operator
  74794. * @returns the name
  74795. */
  74796. static GetOperatorName(operator: number): string;
  74797. }
  74798. /**
  74799. * Defines a predicate condition as an extension of Condition
  74800. */
  74801. export class PredicateCondition extends Condition {
  74802. /** defines the predicate function used to validate the condition */
  74803. predicate: () => boolean;
  74804. /**
  74805. * Internal only - manager for action
  74806. * @hidden
  74807. */
  74808. _actionManager: ActionManager;
  74809. /**
  74810. * Creates a new PredicateCondition
  74811. * @param actionManager manager for the action the condition applies to
  74812. * @param predicate defines the predicate function used to validate the condition
  74813. */
  74814. constructor(actionManager: ActionManager,
  74815. /** defines the predicate function used to validate the condition */
  74816. predicate: () => boolean);
  74817. /**
  74818. * @returns the validity of the predicate condition
  74819. */
  74820. isValid(): boolean;
  74821. }
  74822. /**
  74823. * Defines a state condition as an extension of Condition
  74824. */
  74825. export class StateCondition extends Condition {
  74826. /** Value to compare with target state */
  74827. value: string;
  74828. /**
  74829. * Internal only - manager for action
  74830. * @hidden
  74831. */
  74832. _actionManager: ActionManager;
  74833. /**
  74834. * Internal only
  74835. * @hidden
  74836. */
  74837. private _target;
  74838. /**
  74839. * Creates a new StateCondition
  74840. * @param actionManager manager for the action the condition applies to
  74841. * @param target of the condition
  74842. * @param value to compare with target state
  74843. */
  74844. constructor(actionManager: ActionManager, target: any,
  74845. /** Value to compare with target state */
  74846. value: string);
  74847. /**
  74848. * Gets a boolean indicating if the current condition is met
  74849. * @returns the validity of the state
  74850. */
  74851. isValid(): boolean;
  74852. /**
  74853. * Serialize the StateCondition into a JSON compatible object
  74854. * @returns serialization object
  74855. */
  74856. serialize(): any;
  74857. }
  74858. }
  74859. declare module BABYLON {
  74860. /**
  74861. * This defines an action responsible to toggle a boolean once triggered.
  74862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74863. */
  74864. export class SwitchBooleanAction extends Action {
  74865. /**
  74866. * The path to the boolean property in the target object
  74867. */
  74868. propertyPath: string;
  74869. private _target;
  74870. private _effectiveTarget;
  74871. private _property;
  74872. /**
  74873. * Instantiate the action
  74874. * @param triggerOptions defines the trigger options
  74875. * @param target defines the object containing the boolean
  74876. * @param propertyPath defines the path to the boolean property in the target object
  74877. * @param condition defines the trigger related conditions
  74878. */
  74879. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74880. /** @hidden */
  74881. _prepare(): void;
  74882. /**
  74883. * Execute the action toggle the boolean value.
  74884. */
  74885. execute(): void;
  74886. /**
  74887. * Serializes the actions and its related information.
  74888. * @param parent defines the object to serialize in
  74889. * @returns the serialized object
  74890. */
  74891. serialize(parent: any): any;
  74892. }
  74893. /**
  74894. * This defines an action responsible to set a the state field of the target
  74895. * to a desired value once triggered.
  74896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74897. */
  74898. export class SetStateAction extends Action {
  74899. /**
  74900. * The value to store in the state field.
  74901. */
  74902. value: string;
  74903. private _target;
  74904. /**
  74905. * Instantiate the action
  74906. * @param triggerOptions defines the trigger options
  74907. * @param target defines the object containing the state property
  74908. * @param value defines the value to store in the state field
  74909. * @param condition defines the trigger related conditions
  74910. */
  74911. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74912. /**
  74913. * Execute the action and store the value on the target state property.
  74914. */
  74915. execute(): void;
  74916. /**
  74917. * Serializes the actions and its related information.
  74918. * @param parent defines the object to serialize in
  74919. * @returns the serialized object
  74920. */
  74921. serialize(parent: any): any;
  74922. }
  74923. /**
  74924. * This defines an action responsible to set a property of the target
  74925. * to a desired value once triggered.
  74926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74927. */
  74928. export class SetValueAction extends Action {
  74929. /**
  74930. * The path of the property to set in the target.
  74931. */
  74932. propertyPath: string;
  74933. /**
  74934. * The value to set in the property
  74935. */
  74936. value: any;
  74937. private _target;
  74938. private _effectiveTarget;
  74939. private _property;
  74940. /**
  74941. * Instantiate the action
  74942. * @param triggerOptions defines the trigger options
  74943. * @param target defines the object containing the property
  74944. * @param propertyPath defines the path of the property to set in the target
  74945. * @param value defines the value to set in the property
  74946. * @param condition defines the trigger related conditions
  74947. */
  74948. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74949. /** @hidden */
  74950. _prepare(): void;
  74951. /**
  74952. * Execute the action and set the targetted property to the desired value.
  74953. */
  74954. execute(): void;
  74955. /**
  74956. * Serializes the actions and its related information.
  74957. * @param parent defines the object to serialize in
  74958. * @returns the serialized object
  74959. */
  74960. serialize(parent: any): any;
  74961. }
  74962. /**
  74963. * This defines an action responsible to increment the target value
  74964. * to a desired value once triggered.
  74965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74966. */
  74967. export class IncrementValueAction extends Action {
  74968. /**
  74969. * The path of the property to increment in the target.
  74970. */
  74971. propertyPath: string;
  74972. /**
  74973. * The value we should increment the property by.
  74974. */
  74975. value: any;
  74976. private _target;
  74977. private _effectiveTarget;
  74978. private _property;
  74979. /**
  74980. * Instantiate the action
  74981. * @param triggerOptions defines the trigger options
  74982. * @param target defines the object containing the property
  74983. * @param propertyPath defines the path of the property to increment in the target
  74984. * @param value defines the value value we should increment the property by
  74985. * @param condition defines the trigger related conditions
  74986. */
  74987. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74988. /** @hidden */
  74989. _prepare(): void;
  74990. /**
  74991. * Execute the action and increment the target of the value amount.
  74992. */
  74993. execute(): void;
  74994. /**
  74995. * Serializes the actions and its related information.
  74996. * @param parent defines the object to serialize in
  74997. * @returns the serialized object
  74998. */
  74999. serialize(parent: any): any;
  75000. }
  75001. /**
  75002. * This defines an action responsible to start an animation once triggered.
  75003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75004. */
  75005. export class PlayAnimationAction extends Action {
  75006. /**
  75007. * Where the animation should start (animation frame)
  75008. */
  75009. from: number;
  75010. /**
  75011. * Where the animation should stop (animation frame)
  75012. */
  75013. to: number;
  75014. /**
  75015. * Define if the animation should loop or stop after the first play.
  75016. */
  75017. loop?: boolean;
  75018. private _target;
  75019. /**
  75020. * Instantiate the action
  75021. * @param triggerOptions defines the trigger options
  75022. * @param target defines the target animation or animation name
  75023. * @param from defines from where the animation should start (animation frame)
  75024. * @param end defines where the animation should stop (animation frame)
  75025. * @param loop defines if the animation should loop or stop after the first play
  75026. * @param condition defines the trigger related conditions
  75027. */
  75028. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75029. /** @hidden */
  75030. _prepare(): void;
  75031. /**
  75032. * Execute the action and play the animation.
  75033. */
  75034. execute(): void;
  75035. /**
  75036. * Serializes the actions and its related information.
  75037. * @param parent defines the object to serialize in
  75038. * @returns the serialized object
  75039. */
  75040. serialize(parent: any): any;
  75041. }
  75042. /**
  75043. * This defines an action responsible to stop an animation once triggered.
  75044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75045. */
  75046. export class StopAnimationAction extends Action {
  75047. private _target;
  75048. /**
  75049. * Instantiate the action
  75050. * @param triggerOptions defines the trigger options
  75051. * @param target defines the target animation or animation name
  75052. * @param condition defines the trigger related conditions
  75053. */
  75054. constructor(triggerOptions: any, target: any, condition?: Condition);
  75055. /** @hidden */
  75056. _prepare(): void;
  75057. /**
  75058. * Execute the action and stop the animation.
  75059. */
  75060. execute(): void;
  75061. /**
  75062. * Serializes the actions and its related information.
  75063. * @param parent defines the object to serialize in
  75064. * @returns the serialized object
  75065. */
  75066. serialize(parent: any): any;
  75067. }
  75068. /**
  75069. * This defines an action responsible that does nothing once triggered.
  75070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75071. */
  75072. export class DoNothingAction extends Action {
  75073. /**
  75074. * Instantiate the action
  75075. * @param triggerOptions defines the trigger options
  75076. * @param condition defines the trigger related conditions
  75077. */
  75078. constructor(triggerOptions?: any, condition?: Condition);
  75079. /**
  75080. * Execute the action and do nothing.
  75081. */
  75082. execute(): void;
  75083. /**
  75084. * Serializes the actions and its related information.
  75085. * @param parent defines the object to serialize in
  75086. * @returns the serialized object
  75087. */
  75088. serialize(parent: any): any;
  75089. }
  75090. /**
  75091. * This defines an action responsible to trigger several actions once triggered.
  75092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75093. */
  75094. export class CombineAction extends Action {
  75095. /**
  75096. * The list of aggregated animations to run.
  75097. */
  75098. children: Action[];
  75099. /**
  75100. * Instantiate the action
  75101. * @param triggerOptions defines the trigger options
  75102. * @param children defines the list of aggregated animations to run
  75103. * @param condition defines the trigger related conditions
  75104. */
  75105. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75106. /** @hidden */
  75107. _prepare(): void;
  75108. /**
  75109. * Execute the action and executes all the aggregated actions.
  75110. */
  75111. execute(evt: ActionEvent): void;
  75112. /**
  75113. * Serializes the actions and its related information.
  75114. * @param parent defines the object to serialize in
  75115. * @returns the serialized object
  75116. */
  75117. serialize(parent: any): any;
  75118. }
  75119. /**
  75120. * This defines an action responsible to run code (external event) once triggered.
  75121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75122. */
  75123. export class ExecuteCodeAction extends Action {
  75124. /**
  75125. * The callback function to run.
  75126. */
  75127. func: (evt: ActionEvent) => void;
  75128. /**
  75129. * Instantiate the action
  75130. * @param triggerOptions defines the trigger options
  75131. * @param func defines the callback function to run
  75132. * @param condition defines the trigger related conditions
  75133. */
  75134. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75135. /**
  75136. * Execute the action and run the attached code.
  75137. */
  75138. execute(evt: ActionEvent): void;
  75139. }
  75140. /**
  75141. * This defines an action responsible to set the parent property of the target once triggered.
  75142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75143. */
  75144. export class SetParentAction extends Action {
  75145. private _parent;
  75146. private _target;
  75147. /**
  75148. * Instantiate the action
  75149. * @param triggerOptions defines the trigger options
  75150. * @param target defines the target containing the parent property
  75151. * @param parent defines from where the animation should start (animation frame)
  75152. * @param condition defines the trigger related conditions
  75153. */
  75154. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75155. /** @hidden */
  75156. _prepare(): void;
  75157. /**
  75158. * Execute the action and set the parent property.
  75159. */
  75160. execute(): void;
  75161. /**
  75162. * Serializes the actions and its related information.
  75163. * @param parent defines the object to serialize in
  75164. * @returns the serialized object
  75165. */
  75166. serialize(parent: any): any;
  75167. }
  75168. }
  75169. declare module BABYLON {
  75170. /**
  75171. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75172. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75174. */
  75175. export class ActionManager extends AbstractActionManager {
  75176. /**
  75177. * Nothing
  75178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75179. */
  75180. static readonly NothingTrigger: number;
  75181. /**
  75182. * On pick
  75183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75184. */
  75185. static readonly OnPickTrigger: number;
  75186. /**
  75187. * On left pick
  75188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75189. */
  75190. static readonly OnLeftPickTrigger: number;
  75191. /**
  75192. * On right pick
  75193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75194. */
  75195. static readonly OnRightPickTrigger: number;
  75196. /**
  75197. * On center pick
  75198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75199. */
  75200. static readonly OnCenterPickTrigger: number;
  75201. /**
  75202. * On pick down
  75203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75204. */
  75205. static readonly OnPickDownTrigger: number;
  75206. /**
  75207. * On double pick
  75208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75209. */
  75210. static readonly OnDoublePickTrigger: number;
  75211. /**
  75212. * On pick up
  75213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75214. */
  75215. static readonly OnPickUpTrigger: number;
  75216. /**
  75217. * On pick out.
  75218. * This trigger will only be raised if you also declared a OnPickDown
  75219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75220. */
  75221. static readonly OnPickOutTrigger: number;
  75222. /**
  75223. * On long press
  75224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75225. */
  75226. static readonly OnLongPressTrigger: number;
  75227. /**
  75228. * On pointer over
  75229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75230. */
  75231. static readonly OnPointerOverTrigger: number;
  75232. /**
  75233. * On pointer out
  75234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75235. */
  75236. static readonly OnPointerOutTrigger: number;
  75237. /**
  75238. * On every frame
  75239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75240. */
  75241. static readonly OnEveryFrameTrigger: number;
  75242. /**
  75243. * On intersection enter
  75244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75245. */
  75246. static readonly OnIntersectionEnterTrigger: number;
  75247. /**
  75248. * On intersection exit
  75249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75250. */
  75251. static readonly OnIntersectionExitTrigger: number;
  75252. /**
  75253. * On key down
  75254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75255. */
  75256. static readonly OnKeyDownTrigger: number;
  75257. /**
  75258. * On key up
  75259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75260. */
  75261. static readonly OnKeyUpTrigger: number;
  75262. private _scene;
  75263. /**
  75264. * Creates a new action manager
  75265. * @param scene defines the hosting scene
  75266. */
  75267. constructor(scene: Scene);
  75268. /**
  75269. * Releases all associated resources
  75270. */
  75271. dispose(): void;
  75272. /**
  75273. * Gets hosting scene
  75274. * @returns the hosting scene
  75275. */
  75276. getScene(): Scene;
  75277. /**
  75278. * Does this action manager handles actions of any of the given triggers
  75279. * @param triggers defines the triggers to be tested
  75280. * @return a boolean indicating whether one (or more) of the triggers is handled
  75281. */
  75282. hasSpecificTriggers(triggers: number[]): boolean;
  75283. /**
  75284. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75285. * speed.
  75286. * @param triggerA defines the trigger to be tested
  75287. * @param triggerB defines the trigger to be tested
  75288. * @return a boolean indicating whether one (or more) of the triggers is handled
  75289. */
  75290. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75291. /**
  75292. * Does this action manager handles actions of a given trigger
  75293. * @param trigger defines the trigger to be tested
  75294. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75295. * @return whether the trigger is handled
  75296. */
  75297. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75298. /**
  75299. * Does this action manager has pointer triggers
  75300. */
  75301. readonly hasPointerTriggers: boolean;
  75302. /**
  75303. * Does this action manager has pick triggers
  75304. */
  75305. readonly hasPickTriggers: boolean;
  75306. /**
  75307. * Registers an action to this action manager
  75308. * @param action defines the action to be registered
  75309. * @return the action amended (prepared) after registration
  75310. */
  75311. registerAction(action: IAction): Nullable<IAction>;
  75312. /**
  75313. * Unregisters an action to this action manager
  75314. * @param action defines the action to be unregistered
  75315. * @return a boolean indicating whether the action has been unregistered
  75316. */
  75317. unregisterAction(action: IAction): Boolean;
  75318. /**
  75319. * Process a specific trigger
  75320. * @param trigger defines the trigger to process
  75321. * @param evt defines the event details to be processed
  75322. */
  75323. processTrigger(trigger: number, evt?: IActionEvent): void;
  75324. /** @hidden */
  75325. _getEffectiveTarget(target: any, propertyPath: string): any;
  75326. /** @hidden */
  75327. _getProperty(propertyPath: string): string;
  75328. /**
  75329. * Serialize this manager to a JSON object
  75330. * @param name defines the property name to store this manager
  75331. * @returns a JSON representation of this manager
  75332. */
  75333. serialize(name: string): any;
  75334. /**
  75335. * Creates a new ActionManager from a JSON data
  75336. * @param parsedActions defines the JSON data to read from
  75337. * @param object defines the hosting mesh
  75338. * @param scene defines the hosting scene
  75339. */
  75340. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75341. /**
  75342. * Get a trigger name by index
  75343. * @param trigger defines the trigger index
  75344. * @returns a trigger name
  75345. */
  75346. static GetTriggerName(trigger: number): string;
  75347. }
  75348. }
  75349. declare module BABYLON {
  75350. /**
  75351. * Class representing a ray with position and direction
  75352. */
  75353. export class Ray {
  75354. /** origin point */
  75355. origin: Vector3;
  75356. /** direction */
  75357. direction: Vector3;
  75358. /** length of the ray */
  75359. length: number;
  75360. private static readonly TmpVector3;
  75361. private _tmpRay;
  75362. /**
  75363. * Creates a new ray
  75364. * @param origin origin point
  75365. * @param direction direction
  75366. * @param length length of the ray
  75367. */
  75368. constructor(
  75369. /** origin point */
  75370. origin: Vector3,
  75371. /** direction */
  75372. direction: Vector3,
  75373. /** length of the ray */
  75374. length?: number);
  75375. /**
  75376. * Checks if the ray intersects a box
  75377. * @param minimum bound of the box
  75378. * @param maximum bound of the box
  75379. * @param intersectionTreshold extra extend to be added to the box in all direction
  75380. * @returns if the box was hit
  75381. */
  75382. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75383. /**
  75384. * Checks if the ray intersects a box
  75385. * @param box the bounding box to check
  75386. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75387. * @returns if the box was hit
  75388. */
  75389. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75390. /**
  75391. * If the ray hits a sphere
  75392. * @param sphere the bounding sphere to check
  75393. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75394. * @returns true if it hits the sphere
  75395. */
  75396. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75397. /**
  75398. * If the ray hits a triange
  75399. * @param vertex0 triangle vertex
  75400. * @param vertex1 triangle vertex
  75401. * @param vertex2 triangle vertex
  75402. * @returns intersection information if hit
  75403. */
  75404. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75405. /**
  75406. * Checks if ray intersects a plane
  75407. * @param plane the plane to check
  75408. * @returns the distance away it was hit
  75409. */
  75410. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75411. /**
  75412. * Calculate the intercept of a ray on a given axis
  75413. * @param axis to check 'x' | 'y' | 'z'
  75414. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75415. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75416. */
  75417. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75418. /**
  75419. * Checks if ray intersects a mesh
  75420. * @param mesh the mesh to check
  75421. * @param fastCheck if only the bounding box should checked
  75422. * @returns picking info of the intersecton
  75423. */
  75424. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75425. /**
  75426. * Checks if ray intersects a mesh
  75427. * @param meshes the meshes to check
  75428. * @param fastCheck if only the bounding box should checked
  75429. * @param results array to store result in
  75430. * @returns Array of picking infos
  75431. */
  75432. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75433. private _comparePickingInfo;
  75434. private static smallnum;
  75435. private static rayl;
  75436. /**
  75437. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75438. * @param sega the first point of the segment to test the intersection against
  75439. * @param segb the second point of the segment to test the intersection against
  75440. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75441. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75442. */
  75443. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75444. /**
  75445. * Update the ray from viewport position
  75446. * @param x position
  75447. * @param y y position
  75448. * @param viewportWidth viewport width
  75449. * @param viewportHeight viewport height
  75450. * @param world world matrix
  75451. * @param view view matrix
  75452. * @param projection projection matrix
  75453. * @returns this ray updated
  75454. */
  75455. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75456. /**
  75457. * Creates a ray with origin and direction of 0,0,0
  75458. * @returns the new ray
  75459. */
  75460. static Zero(): Ray;
  75461. /**
  75462. * Creates a new ray from screen space and viewport
  75463. * @param x position
  75464. * @param y y position
  75465. * @param viewportWidth viewport width
  75466. * @param viewportHeight viewport height
  75467. * @param world world matrix
  75468. * @param view view matrix
  75469. * @param projection projection matrix
  75470. * @returns new ray
  75471. */
  75472. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75473. /**
  75474. * 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
  75475. * transformed to the given world matrix.
  75476. * @param origin The origin point
  75477. * @param end The end point
  75478. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75479. * @returns the new ray
  75480. */
  75481. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75482. /**
  75483. * Transforms a ray by a matrix
  75484. * @param ray ray to transform
  75485. * @param matrix matrix to apply
  75486. * @returns the resulting new ray
  75487. */
  75488. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75489. /**
  75490. * Transforms a ray by a matrix
  75491. * @param ray ray to transform
  75492. * @param matrix matrix to apply
  75493. * @param result ray to store result in
  75494. */
  75495. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75496. /**
  75497. * Unproject a ray from screen space to object space
  75498. * @param sourceX defines the screen space x coordinate to use
  75499. * @param sourceY defines the screen space y coordinate to use
  75500. * @param viewportWidth defines the current width of the viewport
  75501. * @param viewportHeight defines the current height of the viewport
  75502. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75503. * @param view defines the view matrix to use
  75504. * @param projection defines the projection matrix to use
  75505. */
  75506. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75507. }
  75508. /**
  75509. * Type used to define predicate used to select faces when a mesh intersection is detected
  75510. */
  75511. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75512. interface Scene {
  75513. /** @hidden */
  75514. _tempPickingRay: Nullable<Ray>;
  75515. /** @hidden */
  75516. _cachedRayForTransform: Ray;
  75517. /** @hidden */
  75518. _pickWithRayInverseMatrix: Matrix;
  75519. /** @hidden */
  75520. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75521. /** @hidden */
  75522. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75523. }
  75524. }
  75525. declare module BABYLON {
  75526. /**
  75527. * Groups all the scene component constants in one place to ease maintenance.
  75528. * @hidden
  75529. */
  75530. export class SceneComponentConstants {
  75531. static readonly NAME_EFFECTLAYER: string;
  75532. static readonly NAME_LAYER: string;
  75533. static readonly NAME_LENSFLARESYSTEM: string;
  75534. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75535. static readonly NAME_PARTICLESYSTEM: string;
  75536. static readonly NAME_GAMEPAD: string;
  75537. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75538. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75539. static readonly NAME_DEPTHRENDERER: string;
  75540. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75541. static readonly NAME_SPRITE: string;
  75542. static readonly NAME_OUTLINERENDERER: string;
  75543. static readonly NAME_PROCEDURALTEXTURE: string;
  75544. static readonly NAME_SHADOWGENERATOR: string;
  75545. static readonly NAME_OCTREE: string;
  75546. static readonly NAME_PHYSICSENGINE: string;
  75547. static readonly NAME_AUDIO: string;
  75548. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75549. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75550. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75551. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75552. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75553. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75554. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75555. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75556. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75557. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75558. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75559. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75560. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75561. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75562. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75563. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75564. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75565. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75566. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75567. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75568. static readonly STEP_AFTERRENDER_AUDIO: number;
  75569. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75570. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75571. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75572. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75573. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75574. static readonly STEP_POINTERMOVE_SPRITE: number;
  75575. static readonly STEP_POINTERDOWN_SPRITE: number;
  75576. static readonly STEP_POINTERUP_SPRITE: number;
  75577. }
  75578. /**
  75579. * This represents a scene component.
  75580. *
  75581. * This is used to decouple the dependency the scene is having on the different workloads like
  75582. * layers, post processes...
  75583. */
  75584. export interface ISceneComponent {
  75585. /**
  75586. * The name of the component. Each component must have a unique name.
  75587. */
  75588. name: string;
  75589. /**
  75590. * The scene the component belongs to.
  75591. */
  75592. scene: Scene;
  75593. /**
  75594. * Register the component to one instance of a scene.
  75595. */
  75596. register(): void;
  75597. /**
  75598. * Rebuilds the elements related to this component in case of
  75599. * context lost for instance.
  75600. */
  75601. rebuild(): void;
  75602. /**
  75603. * Disposes the component and the associated ressources.
  75604. */
  75605. dispose(): void;
  75606. }
  75607. /**
  75608. * This represents a SERIALIZABLE scene component.
  75609. *
  75610. * This extends Scene Component to add Serialization methods on top.
  75611. */
  75612. export interface ISceneSerializableComponent extends ISceneComponent {
  75613. /**
  75614. * Adds all the elements from the container to the scene
  75615. * @param container the container holding the elements
  75616. */
  75617. addFromContainer(container: AbstractScene): void;
  75618. /**
  75619. * Removes all the elements in the container from the scene
  75620. * @param container contains the elements to remove
  75621. * @param dispose if the removed element should be disposed (default: false)
  75622. */
  75623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75624. /**
  75625. * Serializes the component data to the specified json object
  75626. * @param serializationObject The object to serialize to
  75627. */
  75628. serialize(serializationObject: any): void;
  75629. }
  75630. /**
  75631. * Strong typing of a Mesh related stage step action
  75632. */
  75633. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75634. /**
  75635. * Strong typing of a Evaluate Sub Mesh related stage step action
  75636. */
  75637. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75638. /**
  75639. * Strong typing of a Active Mesh related stage step action
  75640. */
  75641. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75642. /**
  75643. * Strong typing of a Camera related stage step action
  75644. */
  75645. export type CameraStageAction = (camera: Camera) => void;
  75646. /**
  75647. * Strong typing of a Camera Frame buffer related stage step action
  75648. */
  75649. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75650. /**
  75651. * Strong typing of a Render Target related stage step action
  75652. */
  75653. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75654. /**
  75655. * Strong typing of a RenderingGroup related stage step action
  75656. */
  75657. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75658. /**
  75659. * Strong typing of a Mesh Render related stage step action
  75660. */
  75661. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75662. /**
  75663. * Strong typing of a simple stage step action
  75664. */
  75665. export type SimpleStageAction = () => void;
  75666. /**
  75667. * Strong typing of a render target action.
  75668. */
  75669. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75670. /**
  75671. * Strong typing of a pointer move action.
  75672. */
  75673. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75674. /**
  75675. * Strong typing of a pointer up/down action.
  75676. */
  75677. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75678. /**
  75679. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75680. * @hidden
  75681. */
  75682. export class Stage<T extends Function> extends Array<{
  75683. index: number;
  75684. component: ISceneComponent;
  75685. action: T;
  75686. }> {
  75687. /**
  75688. * Hide ctor from the rest of the world.
  75689. * @param items The items to add.
  75690. */
  75691. private constructor();
  75692. /**
  75693. * Creates a new Stage.
  75694. * @returns A new instance of a Stage
  75695. */
  75696. static Create<T extends Function>(): Stage<T>;
  75697. /**
  75698. * Registers a step in an ordered way in the targeted stage.
  75699. * @param index Defines the position to register the step in
  75700. * @param component Defines the component attached to the step
  75701. * @param action Defines the action to launch during the step
  75702. */
  75703. registerStep(index: number, component: ISceneComponent, action: T): void;
  75704. /**
  75705. * Clears all the steps from the stage.
  75706. */
  75707. clear(): void;
  75708. }
  75709. }
  75710. declare module BABYLON {
  75711. interface Scene {
  75712. /** @hidden */
  75713. _pointerOverSprite: Nullable<Sprite>;
  75714. /** @hidden */
  75715. _pickedDownSprite: Nullable<Sprite>;
  75716. /** @hidden */
  75717. _tempSpritePickingRay: Nullable<Ray>;
  75718. /**
  75719. * All of the sprite managers added to this scene
  75720. * @see http://doc.babylonjs.com/babylon101/sprites
  75721. */
  75722. spriteManagers: Array<ISpriteManager>;
  75723. /**
  75724. * An event triggered when sprites rendering is about to start
  75725. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75726. */
  75727. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75728. /**
  75729. * An event triggered when sprites rendering is done
  75730. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75731. */
  75732. onAfterSpritesRenderingObservable: Observable<Scene>;
  75733. /** @hidden */
  75734. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75735. /** Launch a ray to try to pick a sprite in the scene
  75736. * @param x position on screen
  75737. * @param y position on screen
  75738. * @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
  75739. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75740. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75741. * @returns a PickingInfo
  75742. */
  75743. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75744. /** Use the given ray to pick a sprite in the scene
  75745. * @param ray The ray (in world space) to use to pick meshes
  75746. * @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
  75747. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75748. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75749. * @returns a PickingInfo
  75750. */
  75751. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75752. /**
  75753. * Force the sprite under the pointer
  75754. * @param sprite defines the sprite to use
  75755. */
  75756. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75757. /**
  75758. * Gets the sprite under the pointer
  75759. * @returns a Sprite or null if no sprite is under the pointer
  75760. */
  75761. getPointerOverSprite(): Nullable<Sprite>;
  75762. }
  75763. /**
  75764. * Defines the sprite scene component responsible to manage sprites
  75765. * in a given scene.
  75766. */
  75767. export class SpriteSceneComponent implements ISceneComponent {
  75768. /**
  75769. * The component name helpfull to identify the component in the list of scene components.
  75770. */
  75771. readonly name: string;
  75772. /**
  75773. * The scene the component belongs to.
  75774. */
  75775. scene: Scene;
  75776. /** @hidden */
  75777. private _spritePredicate;
  75778. /**
  75779. * Creates a new instance of the component for the given scene
  75780. * @param scene Defines the scene to register the component in
  75781. */
  75782. constructor(scene: Scene);
  75783. /**
  75784. * Registers the component in a given scene
  75785. */
  75786. register(): void;
  75787. /**
  75788. * Rebuilds the elements related to this component in case of
  75789. * context lost for instance.
  75790. */
  75791. rebuild(): void;
  75792. /**
  75793. * Disposes the component and the associated ressources.
  75794. */
  75795. dispose(): void;
  75796. private _pickSpriteButKeepRay;
  75797. private _pointerMove;
  75798. private _pointerDown;
  75799. private _pointerUp;
  75800. }
  75801. }
  75802. declare module BABYLON {
  75803. /** @hidden */
  75804. export var fogFragmentDeclaration: {
  75805. name: string;
  75806. shader: string;
  75807. };
  75808. }
  75809. declare module BABYLON {
  75810. /** @hidden */
  75811. export var fogFragment: {
  75812. name: string;
  75813. shader: string;
  75814. };
  75815. }
  75816. declare module BABYLON {
  75817. /** @hidden */
  75818. export var spritesPixelShader: {
  75819. name: string;
  75820. shader: string;
  75821. };
  75822. }
  75823. declare module BABYLON {
  75824. /** @hidden */
  75825. export var fogVertexDeclaration: {
  75826. name: string;
  75827. shader: string;
  75828. };
  75829. }
  75830. declare module BABYLON {
  75831. /** @hidden */
  75832. export var spritesVertexShader: {
  75833. name: string;
  75834. shader: string;
  75835. };
  75836. }
  75837. declare module BABYLON {
  75838. /**
  75839. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75840. */
  75841. export interface ISpriteManager extends IDisposable {
  75842. /**
  75843. * Restricts the camera to viewing objects with the same layerMask.
  75844. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75845. */
  75846. layerMask: number;
  75847. /**
  75848. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75849. */
  75850. isPickable: boolean;
  75851. /**
  75852. * Specifies the rendering group id for this mesh (0 by default)
  75853. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75854. */
  75855. renderingGroupId: number;
  75856. /**
  75857. * Defines the list of sprites managed by the manager.
  75858. */
  75859. sprites: Array<Sprite>;
  75860. /**
  75861. * Tests the intersection of a sprite with a specific ray.
  75862. * @param ray The ray we are sending to test the collision
  75863. * @param camera The camera space we are sending rays in
  75864. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75865. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75866. * @returns picking info or null.
  75867. */
  75868. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75869. /**
  75870. * Renders the list of sprites on screen.
  75871. */
  75872. render(): void;
  75873. }
  75874. /**
  75875. * Class used to manage multiple sprites on the same spritesheet
  75876. * @see http://doc.babylonjs.com/babylon101/sprites
  75877. */
  75878. export class SpriteManager implements ISpriteManager {
  75879. /** defines the manager's name */
  75880. name: string;
  75881. /** Gets the list of sprites */
  75882. sprites: Sprite[];
  75883. /** Gets or sets the rendering group id (0 by default) */
  75884. renderingGroupId: number;
  75885. /** Gets or sets camera layer mask */
  75886. layerMask: number;
  75887. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75888. fogEnabled: boolean;
  75889. /** Gets or sets a boolean indicating if the sprites are pickable */
  75890. isPickable: boolean;
  75891. /** Defines the default width of a cell in the spritesheet */
  75892. cellWidth: number;
  75893. /** Defines the default height of a cell in the spritesheet */
  75894. cellHeight: number;
  75895. /** Associative array from JSON sprite data file */
  75896. private _cellData;
  75897. /** Array of sprite names from JSON sprite data file */
  75898. private _spriteMap;
  75899. /** True when packed cell data from JSON file is ready*/
  75900. private _packedAndReady;
  75901. /**
  75902. * An event triggered when the manager is disposed.
  75903. */
  75904. onDisposeObservable: Observable<SpriteManager>;
  75905. private _onDisposeObserver;
  75906. /**
  75907. * Callback called when the manager is disposed
  75908. */
  75909. onDispose: () => void;
  75910. private _capacity;
  75911. private _fromPacked;
  75912. private _spriteTexture;
  75913. private _epsilon;
  75914. private _scene;
  75915. private _vertexData;
  75916. private _buffer;
  75917. private _vertexBuffers;
  75918. private _indexBuffer;
  75919. private _effectBase;
  75920. private _effectFog;
  75921. /**
  75922. * Gets or sets the spritesheet texture
  75923. */
  75924. texture: Texture;
  75925. /**
  75926. * Creates a new sprite manager
  75927. * @param name defines the manager's name
  75928. * @param imgUrl defines the sprite sheet url
  75929. * @param capacity defines the maximum allowed number of sprites
  75930. * @param cellSize defines the size of a sprite cell
  75931. * @param scene defines the hosting scene
  75932. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75933. * @param samplingMode defines the smapling mode to use with spritesheet
  75934. * @param fromPacked set to false; do not alter
  75935. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  75936. */
  75937. constructor(
  75938. /** defines the manager's name */
  75939. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  75940. private _makePacked;
  75941. private _appendSpriteVertex;
  75942. /**
  75943. * Intersects the sprites with a ray
  75944. * @param ray defines the ray to intersect with
  75945. * @param camera defines the current active camera
  75946. * @param predicate defines a predicate used to select candidate sprites
  75947. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75948. * @returns null if no hit or a PickingInfo
  75949. */
  75950. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75951. /**
  75952. * Render all child sprites
  75953. */
  75954. render(): void;
  75955. /**
  75956. * Release associated resources
  75957. */
  75958. dispose(): void;
  75959. }
  75960. }
  75961. declare module BABYLON {
  75962. /**
  75963. * Class used to represent a sprite
  75964. * @see http://doc.babylonjs.com/babylon101/sprites
  75965. */
  75966. export class Sprite {
  75967. /** defines the name */
  75968. name: string;
  75969. /** Gets or sets the current world position */
  75970. position: Vector3;
  75971. /** Gets or sets the main color */
  75972. color: Color4;
  75973. /** Gets or sets the width */
  75974. width: number;
  75975. /** Gets or sets the height */
  75976. height: number;
  75977. /** Gets or sets rotation angle */
  75978. angle: number;
  75979. /** Gets or sets the cell index in the sprite sheet */
  75980. cellIndex: number;
  75981. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  75982. cellRef: string;
  75983. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75984. invertU: number;
  75985. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75986. invertV: number;
  75987. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75988. disposeWhenFinishedAnimating: boolean;
  75989. /** Gets the list of attached animations */
  75990. animations: Animation[];
  75991. /** Gets or sets a boolean indicating if the sprite can be picked */
  75992. isPickable: boolean;
  75993. /**
  75994. * Gets or sets the associated action manager
  75995. */
  75996. actionManager: Nullable<ActionManager>;
  75997. private _animationStarted;
  75998. private _loopAnimation;
  75999. private _fromIndex;
  76000. private _toIndex;
  76001. private _delay;
  76002. private _direction;
  76003. private _manager;
  76004. private _time;
  76005. private _onAnimationEnd;
  76006. /**
  76007. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76008. */
  76009. isVisible: boolean;
  76010. /**
  76011. * Gets or sets the sprite size
  76012. */
  76013. size: number;
  76014. /**
  76015. * Creates a new Sprite
  76016. * @param name defines the name
  76017. * @param manager defines the manager
  76018. */
  76019. constructor(
  76020. /** defines the name */
  76021. name: string, manager: ISpriteManager);
  76022. /**
  76023. * Starts an animation
  76024. * @param from defines the initial key
  76025. * @param to defines the end key
  76026. * @param loop defines if the animation must loop
  76027. * @param delay defines the start delay (in ms)
  76028. * @param onAnimationEnd defines a callback to call when animation ends
  76029. */
  76030. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76031. /** Stops current animation (if any) */
  76032. stopAnimation(): void;
  76033. /** @hidden */
  76034. _animate(deltaTime: number): void;
  76035. /** Release associated resources */
  76036. dispose(): void;
  76037. }
  76038. }
  76039. declare module BABYLON {
  76040. /**
  76041. * Information about the result of picking within a scene
  76042. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76043. */
  76044. export class PickingInfo {
  76045. /** @hidden */
  76046. _pickingUnavailable: boolean;
  76047. /**
  76048. * If the pick collided with an object
  76049. */
  76050. hit: boolean;
  76051. /**
  76052. * Distance away where the pick collided
  76053. */
  76054. distance: number;
  76055. /**
  76056. * The location of pick collision
  76057. */
  76058. pickedPoint: Nullable<Vector3>;
  76059. /**
  76060. * The mesh corresponding the the pick collision
  76061. */
  76062. pickedMesh: Nullable<AbstractMesh>;
  76063. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76064. bu: number;
  76065. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76066. bv: number;
  76067. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76068. faceId: number;
  76069. /** Id of the the submesh that was picked */
  76070. subMeshId: number;
  76071. /** If a sprite was picked, this will be the sprite the pick collided with */
  76072. pickedSprite: Nullable<Sprite>;
  76073. /**
  76074. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76075. */
  76076. originMesh: Nullable<AbstractMesh>;
  76077. /**
  76078. * The ray that was used to perform the picking.
  76079. */
  76080. ray: Nullable<Ray>;
  76081. /**
  76082. * Gets the normal correspodning to the face the pick collided with
  76083. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76084. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76085. * @returns The normal correspodning to the face the pick collided with
  76086. */
  76087. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76088. /**
  76089. * Gets the texture coordinates of where the pick occured
  76090. * @returns the vector containing the coordnates of the texture
  76091. */
  76092. getTextureCoordinates(): Nullable<Vector2>;
  76093. }
  76094. }
  76095. declare module BABYLON {
  76096. /**
  76097. * Gather the list of pointer event types as constants.
  76098. */
  76099. export class PointerEventTypes {
  76100. /**
  76101. * 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.
  76102. */
  76103. static readonly POINTERDOWN: number;
  76104. /**
  76105. * The pointerup event is fired when a pointer is no longer active.
  76106. */
  76107. static readonly POINTERUP: number;
  76108. /**
  76109. * The pointermove event is fired when a pointer changes coordinates.
  76110. */
  76111. static readonly POINTERMOVE: number;
  76112. /**
  76113. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76114. */
  76115. static readonly POINTERWHEEL: number;
  76116. /**
  76117. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76118. */
  76119. static readonly POINTERPICK: number;
  76120. /**
  76121. * The pointertap event is fired when a the object has been touched and released without drag.
  76122. */
  76123. static readonly POINTERTAP: number;
  76124. /**
  76125. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76126. */
  76127. static readonly POINTERDOUBLETAP: number;
  76128. }
  76129. /**
  76130. * Base class of pointer info types.
  76131. */
  76132. export class PointerInfoBase {
  76133. /**
  76134. * Defines the type of event (PointerEventTypes)
  76135. */
  76136. type: number;
  76137. /**
  76138. * Defines the related dom event
  76139. */
  76140. event: PointerEvent | MouseWheelEvent;
  76141. /**
  76142. * Instantiates the base class of pointers info.
  76143. * @param type Defines the type of event (PointerEventTypes)
  76144. * @param event Defines the related dom event
  76145. */
  76146. constructor(
  76147. /**
  76148. * Defines the type of event (PointerEventTypes)
  76149. */
  76150. type: number,
  76151. /**
  76152. * Defines the related dom event
  76153. */
  76154. event: PointerEvent | MouseWheelEvent);
  76155. }
  76156. /**
  76157. * This class is used to store pointer related info for the onPrePointerObservable event.
  76158. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76159. */
  76160. export class PointerInfoPre extends PointerInfoBase {
  76161. /**
  76162. * Ray from a pointer if availible (eg. 6dof controller)
  76163. */
  76164. ray: Nullable<Ray>;
  76165. /**
  76166. * Defines the local position of the pointer on the canvas.
  76167. */
  76168. localPosition: Vector2;
  76169. /**
  76170. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76171. */
  76172. skipOnPointerObservable: boolean;
  76173. /**
  76174. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76175. * @param type Defines the type of event (PointerEventTypes)
  76176. * @param event Defines the related dom event
  76177. * @param localX Defines the local x coordinates of the pointer when the event occured
  76178. * @param localY Defines the local y coordinates of the pointer when the event occured
  76179. */
  76180. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76181. }
  76182. /**
  76183. * This type contains all the data related to a pointer event in Babylon.js.
  76184. * 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.
  76185. */
  76186. export class PointerInfo extends PointerInfoBase {
  76187. /**
  76188. * Defines the picking info associated to the info (if any)\
  76189. */
  76190. pickInfo: Nullable<PickingInfo>;
  76191. /**
  76192. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76193. * @param type Defines the type of event (PointerEventTypes)
  76194. * @param event Defines the related dom event
  76195. * @param pickInfo Defines the picking info associated to the info (if any)\
  76196. */
  76197. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76198. /**
  76199. * Defines the picking info associated to the info (if any)\
  76200. */
  76201. pickInfo: Nullable<PickingInfo>);
  76202. }
  76203. /**
  76204. * Data relating to a touch event on the screen.
  76205. */
  76206. export interface PointerTouch {
  76207. /**
  76208. * X coordinate of touch.
  76209. */
  76210. x: number;
  76211. /**
  76212. * Y coordinate of touch.
  76213. */
  76214. y: number;
  76215. /**
  76216. * Id of touch. Unique for each finger.
  76217. */
  76218. pointerId: number;
  76219. /**
  76220. * Event type passed from DOM.
  76221. */
  76222. type: any;
  76223. }
  76224. }
  76225. declare module BABYLON {
  76226. /**
  76227. * Manage the mouse inputs to control the movement of a free camera.
  76228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76229. */
  76230. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76231. /**
  76232. * Define if touch is enabled in the mouse input
  76233. */
  76234. touchEnabled: boolean;
  76235. /**
  76236. * Defines the camera the input is attached to.
  76237. */
  76238. camera: FreeCamera;
  76239. /**
  76240. * Defines the buttons associated with the input to handle camera move.
  76241. */
  76242. buttons: number[];
  76243. /**
  76244. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76245. */
  76246. angularSensibility: number;
  76247. private _pointerInput;
  76248. private _onMouseMove;
  76249. private _observer;
  76250. private previousPosition;
  76251. /**
  76252. * Observable for when a pointer move event occurs containing the move offset
  76253. */
  76254. onPointerMovedObservable: Observable<{
  76255. offsetX: number;
  76256. offsetY: number;
  76257. }>;
  76258. /**
  76259. * @hidden
  76260. * If the camera should be rotated automatically based on pointer movement
  76261. */
  76262. _allowCameraRotation: boolean;
  76263. /**
  76264. * Manage the mouse inputs to control the movement of a free camera.
  76265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76266. * @param touchEnabled Defines if touch is enabled or not
  76267. */
  76268. constructor(
  76269. /**
  76270. * Define if touch is enabled in the mouse input
  76271. */
  76272. touchEnabled?: boolean);
  76273. /**
  76274. * Attach the input controls to a specific dom element to get the input from.
  76275. * @param element Defines the element the controls should be listened from
  76276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76277. */
  76278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76279. /**
  76280. * Called on JS contextmenu event.
  76281. * Override this method to provide functionality.
  76282. */
  76283. protected onContextMenu(evt: PointerEvent): void;
  76284. /**
  76285. * Detach the current controls from the specified dom element.
  76286. * @param element Defines the element to stop listening the inputs from
  76287. */
  76288. detachControl(element: Nullable<HTMLElement>): void;
  76289. /**
  76290. * Gets the class name of the current intput.
  76291. * @returns the class name
  76292. */
  76293. getClassName(): string;
  76294. /**
  76295. * Get the friendly name associated with the input class.
  76296. * @returns the input friendly name
  76297. */
  76298. getSimpleName(): string;
  76299. }
  76300. }
  76301. declare module BABYLON {
  76302. /**
  76303. * Manage the touch inputs to control the movement of a free camera.
  76304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76305. */
  76306. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76307. /**
  76308. * Defines the camera the input is attached to.
  76309. */
  76310. camera: FreeCamera;
  76311. /**
  76312. * Defines the touch sensibility for rotation.
  76313. * The higher the faster.
  76314. */
  76315. touchAngularSensibility: number;
  76316. /**
  76317. * Defines the touch sensibility for move.
  76318. * The higher the faster.
  76319. */
  76320. touchMoveSensibility: number;
  76321. private _offsetX;
  76322. private _offsetY;
  76323. private _pointerPressed;
  76324. private _pointerInput;
  76325. private _observer;
  76326. private _onLostFocus;
  76327. /**
  76328. * Attach the input controls to a specific dom element to get the input from.
  76329. * @param element Defines the element the controls should be listened from
  76330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76331. */
  76332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76333. /**
  76334. * Detach the current controls from the specified dom element.
  76335. * @param element Defines the element to stop listening the inputs from
  76336. */
  76337. detachControl(element: Nullable<HTMLElement>): void;
  76338. /**
  76339. * Update the current camera state depending on the inputs that have been used this frame.
  76340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76341. */
  76342. checkInputs(): void;
  76343. /**
  76344. * Gets the class name of the current intput.
  76345. * @returns the class name
  76346. */
  76347. getClassName(): string;
  76348. /**
  76349. * Get the friendly name associated with the input class.
  76350. * @returns the input friendly name
  76351. */
  76352. getSimpleName(): string;
  76353. }
  76354. }
  76355. declare module BABYLON {
  76356. /**
  76357. * Default Inputs manager for the FreeCamera.
  76358. * It groups all the default supported inputs for ease of use.
  76359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76360. */
  76361. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76362. /**
  76363. * @hidden
  76364. */
  76365. _mouseInput: Nullable<FreeCameraMouseInput>;
  76366. /**
  76367. * Instantiates a new FreeCameraInputsManager.
  76368. * @param camera Defines the camera the inputs belong to
  76369. */
  76370. constructor(camera: FreeCamera);
  76371. /**
  76372. * Add keyboard input support to the input manager.
  76373. * @returns the current input manager
  76374. */
  76375. addKeyboard(): FreeCameraInputsManager;
  76376. /**
  76377. * Add mouse input support to the input manager.
  76378. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76379. * @returns the current input manager
  76380. */
  76381. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76382. /**
  76383. * Removes the mouse input support from the manager
  76384. * @returns the current input manager
  76385. */
  76386. removeMouse(): FreeCameraInputsManager;
  76387. /**
  76388. * Add touch input support to the input manager.
  76389. * @returns the current input manager
  76390. */
  76391. addTouch(): FreeCameraInputsManager;
  76392. /**
  76393. * Remove all attached input methods from a camera
  76394. */
  76395. clear(): void;
  76396. }
  76397. }
  76398. declare module BABYLON {
  76399. /**
  76400. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76401. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76402. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76403. */
  76404. export class FreeCamera extends TargetCamera {
  76405. /**
  76406. * Define the collision ellipsoid of the camera.
  76407. * This is helpful to simulate a camera body like the player body around the camera
  76408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76409. */
  76410. ellipsoid: Vector3;
  76411. /**
  76412. * Define an offset for the position of the ellipsoid around the camera.
  76413. * This can be helpful to determine the center of the body near the gravity center of the body
  76414. * instead of its head.
  76415. */
  76416. ellipsoidOffset: Vector3;
  76417. /**
  76418. * Enable or disable collisions of the camera with the rest of the scene objects.
  76419. */
  76420. checkCollisions: boolean;
  76421. /**
  76422. * Enable or disable gravity on the camera.
  76423. */
  76424. applyGravity: boolean;
  76425. /**
  76426. * Define the input manager associated to the camera.
  76427. */
  76428. inputs: FreeCameraInputsManager;
  76429. /**
  76430. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76431. * Higher values reduce sensitivity.
  76432. */
  76433. /**
  76434. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76435. * Higher values reduce sensitivity.
  76436. */
  76437. angularSensibility: number;
  76438. /**
  76439. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76440. */
  76441. keysUp: number[];
  76442. /**
  76443. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76444. */
  76445. keysDown: number[];
  76446. /**
  76447. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76448. */
  76449. keysLeft: number[];
  76450. /**
  76451. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76452. */
  76453. keysRight: number[];
  76454. /**
  76455. * Event raised when the camera collide with a mesh in the scene.
  76456. */
  76457. onCollide: (collidedMesh: AbstractMesh) => void;
  76458. private _collider;
  76459. private _needMoveForGravity;
  76460. private _oldPosition;
  76461. private _diffPosition;
  76462. private _newPosition;
  76463. /** @hidden */
  76464. _localDirection: Vector3;
  76465. /** @hidden */
  76466. _transformedDirection: Vector3;
  76467. /**
  76468. * Instantiates a Free Camera.
  76469. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76470. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76472. * @param name Define the name of the camera in the scene
  76473. * @param position Define the start position of the camera in the scene
  76474. * @param scene Define the scene the camera belongs to
  76475. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76476. */
  76477. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76478. /**
  76479. * Attached controls to the current camera.
  76480. * @param element Defines the element the controls should be listened from
  76481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76482. */
  76483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76484. /**
  76485. * Detach the current controls from the camera.
  76486. * The camera will stop reacting to inputs.
  76487. * @param element Defines the element to stop listening the inputs from
  76488. */
  76489. detachControl(element: HTMLElement): void;
  76490. private _collisionMask;
  76491. /**
  76492. * Define a collision mask to limit the list of object the camera can collide with
  76493. */
  76494. collisionMask: number;
  76495. /** @hidden */
  76496. _collideWithWorld(displacement: Vector3): void;
  76497. private _onCollisionPositionChange;
  76498. /** @hidden */
  76499. _checkInputs(): void;
  76500. /** @hidden */
  76501. _decideIfNeedsToMove(): boolean;
  76502. /** @hidden */
  76503. _updatePosition(): void;
  76504. /**
  76505. * Destroy the camera and release the current resources hold by it.
  76506. */
  76507. dispose(): void;
  76508. /**
  76509. * Gets the current object class name.
  76510. * @return the class name
  76511. */
  76512. getClassName(): string;
  76513. }
  76514. }
  76515. declare module BABYLON {
  76516. /**
  76517. * Represents a gamepad control stick position
  76518. */
  76519. export class StickValues {
  76520. /**
  76521. * The x component of the control stick
  76522. */
  76523. x: number;
  76524. /**
  76525. * The y component of the control stick
  76526. */
  76527. y: number;
  76528. /**
  76529. * Initializes the gamepad x and y control stick values
  76530. * @param x The x component of the gamepad control stick value
  76531. * @param y The y component of the gamepad control stick value
  76532. */
  76533. constructor(
  76534. /**
  76535. * The x component of the control stick
  76536. */
  76537. x: number,
  76538. /**
  76539. * The y component of the control stick
  76540. */
  76541. y: number);
  76542. }
  76543. /**
  76544. * An interface which manages callbacks for gamepad button changes
  76545. */
  76546. export interface GamepadButtonChanges {
  76547. /**
  76548. * Called when a gamepad has been changed
  76549. */
  76550. changed: boolean;
  76551. /**
  76552. * Called when a gamepad press event has been triggered
  76553. */
  76554. pressChanged: boolean;
  76555. /**
  76556. * Called when a touch event has been triggered
  76557. */
  76558. touchChanged: boolean;
  76559. /**
  76560. * Called when a value has changed
  76561. */
  76562. valueChanged: boolean;
  76563. }
  76564. /**
  76565. * Represents a gamepad
  76566. */
  76567. export class Gamepad {
  76568. /**
  76569. * The id of the gamepad
  76570. */
  76571. id: string;
  76572. /**
  76573. * The index of the gamepad
  76574. */
  76575. index: number;
  76576. /**
  76577. * The browser gamepad
  76578. */
  76579. browserGamepad: any;
  76580. /**
  76581. * Specifies what type of gamepad this represents
  76582. */
  76583. type: number;
  76584. private _leftStick;
  76585. private _rightStick;
  76586. /** @hidden */
  76587. _isConnected: boolean;
  76588. private _leftStickAxisX;
  76589. private _leftStickAxisY;
  76590. private _rightStickAxisX;
  76591. private _rightStickAxisY;
  76592. /**
  76593. * Triggered when the left control stick has been changed
  76594. */
  76595. private _onleftstickchanged;
  76596. /**
  76597. * Triggered when the right control stick has been changed
  76598. */
  76599. private _onrightstickchanged;
  76600. /**
  76601. * Represents a gamepad controller
  76602. */
  76603. static GAMEPAD: number;
  76604. /**
  76605. * Represents a generic controller
  76606. */
  76607. static GENERIC: number;
  76608. /**
  76609. * Represents an XBox controller
  76610. */
  76611. static XBOX: number;
  76612. /**
  76613. * Represents a pose-enabled controller
  76614. */
  76615. static POSE_ENABLED: number;
  76616. /**
  76617. * Represents an Dual Shock controller
  76618. */
  76619. static DUALSHOCK: number;
  76620. /**
  76621. * Specifies whether the left control stick should be Y-inverted
  76622. */
  76623. protected _invertLeftStickY: boolean;
  76624. /**
  76625. * Specifies if the gamepad has been connected
  76626. */
  76627. readonly isConnected: boolean;
  76628. /**
  76629. * Initializes the gamepad
  76630. * @param id The id of the gamepad
  76631. * @param index The index of the gamepad
  76632. * @param browserGamepad The browser gamepad
  76633. * @param leftStickX The x component of the left joystick
  76634. * @param leftStickY The y component of the left joystick
  76635. * @param rightStickX The x component of the right joystick
  76636. * @param rightStickY The y component of the right joystick
  76637. */
  76638. constructor(
  76639. /**
  76640. * The id of the gamepad
  76641. */
  76642. id: string,
  76643. /**
  76644. * The index of the gamepad
  76645. */
  76646. index: number,
  76647. /**
  76648. * The browser gamepad
  76649. */
  76650. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76651. /**
  76652. * Callback triggered when the left joystick has changed
  76653. * @param callback
  76654. */
  76655. onleftstickchanged(callback: (values: StickValues) => void): void;
  76656. /**
  76657. * Callback triggered when the right joystick has changed
  76658. * @param callback
  76659. */
  76660. onrightstickchanged(callback: (values: StickValues) => void): void;
  76661. /**
  76662. * Gets the left joystick
  76663. */
  76664. /**
  76665. * Sets the left joystick values
  76666. */
  76667. leftStick: StickValues;
  76668. /**
  76669. * Gets the right joystick
  76670. */
  76671. /**
  76672. * Sets the right joystick value
  76673. */
  76674. rightStick: StickValues;
  76675. /**
  76676. * Updates the gamepad joystick positions
  76677. */
  76678. update(): void;
  76679. /**
  76680. * Disposes the gamepad
  76681. */
  76682. dispose(): void;
  76683. }
  76684. /**
  76685. * Represents a generic gamepad
  76686. */
  76687. export class GenericPad extends Gamepad {
  76688. private _buttons;
  76689. private _onbuttondown;
  76690. private _onbuttonup;
  76691. /**
  76692. * Observable triggered when a button has been pressed
  76693. */
  76694. onButtonDownObservable: Observable<number>;
  76695. /**
  76696. * Observable triggered when a button has been released
  76697. */
  76698. onButtonUpObservable: Observable<number>;
  76699. /**
  76700. * Callback triggered when a button has been pressed
  76701. * @param callback Called when a button has been pressed
  76702. */
  76703. onbuttondown(callback: (buttonPressed: number) => void): void;
  76704. /**
  76705. * Callback triggered when a button has been released
  76706. * @param callback Called when a button has been released
  76707. */
  76708. onbuttonup(callback: (buttonReleased: number) => void): void;
  76709. /**
  76710. * Initializes the generic gamepad
  76711. * @param id The id of the generic gamepad
  76712. * @param index The index of the generic gamepad
  76713. * @param browserGamepad The browser gamepad
  76714. */
  76715. constructor(id: string, index: number, browserGamepad: any);
  76716. private _setButtonValue;
  76717. /**
  76718. * Updates the generic gamepad
  76719. */
  76720. update(): void;
  76721. /**
  76722. * Disposes the generic gamepad
  76723. */
  76724. dispose(): void;
  76725. }
  76726. }
  76727. declare module BABYLON {
  76728. interface Engine {
  76729. /**
  76730. * Creates a raw texture
  76731. * @param data defines the data to store in the texture
  76732. * @param width defines the width of the texture
  76733. * @param height defines the height of the texture
  76734. * @param format defines the format of the data
  76735. * @param generateMipMaps defines if the engine should generate the mip levels
  76736. * @param invertY defines if data must be stored with Y axis inverted
  76737. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76738. * @param compression defines the compression used (null by default)
  76739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76740. * @returns the raw texture inside an InternalTexture
  76741. */
  76742. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76743. /**
  76744. * Update a raw texture
  76745. * @param texture defines the texture to update
  76746. * @param data defines the data to store in the texture
  76747. * @param format defines the format of the data
  76748. * @param invertY defines if data must be stored with Y axis inverted
  76749. */
  76750. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76751. /**
  76752. * Update a raw texture
  76753. * @param texture defines the texture to update
  76754. * @param data defines the data to store in the texture
  76755. * @param format defines the format of the data
  76756. * @param invertY defines if data must be stored with Y axis inverted
  76757. * @param compression defines the compression used (null by default)
  76758. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76759. */
  76760. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76761. /**
  76762. * Creates a new raw cube texture
  76763. * @param data defines the array of data to use to create each face
  76764. * @param size defines the size of the textures
  76765. * @param format defines the format of the data
  76766. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76767. * @param generateMipMaps defines if the engine should generate the mip levels
  76768. * @param invertY defines if data must be stored with Y axis inverted
  76769. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76770. * @param compression defines the compression used (null by default)
  76771. * @returns the cube texture as an InternalTexture
  76772. */
  76773. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76774. /**
  76775. * Update a raw cube texture
  76776. * @param texture defines the texture to udpdate
  76777. * @param data defines the data to store
  76778. * @param format defines the data format
  76779. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76780. * @param invertY defines if data must be stored with Y axis inverted
  76781. */
  76782. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76783. /**
  76784. * Update a raw cube texture
  76785. * @param texture defines the texture to udpdate
  76786. * @param data defines the data to store
  76787. * @param format defines the data format
  76788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76789. * @param invertY defines if data must be stored with Y axis inverted
  76790. * @param compression defines the compression used (null by default)
  76791. */
  76792. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76793. /**
  76794. * Update a raw cube texture
  76795. * @param texture defines the texture to udpdate
  76796. * @param data defines the data to store
  76797. * @param format defines the data format
  76798. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76799. * @param invertY defines if data must be stored with Y axis inverted
  76800. * @param compression defines the compression used (null by default)
  76801. * @param level defines which level of the texture to update
  76802. */
  76803. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76804. /**
  76805. * Creates a new raw cube texture from a specified url
  76806. * @param url defines the url where the data is located
  76807. * @param scene defines the current scene
  76808. * @param size defines the size of the textures
  76809. * @param format defines the format of the data
  76810. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76811. * @param noMipmap defines if the engine should avoid generating the mip levels
  76812. * @param callback defines a callback used to extract texture data from loaded data
  76813. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76814. * @param onLoad defines a callback called when texture is loaded
  76815. * @param onError defines a callback called if there is an error
  76816. * @returns the cube texture as an InternalTexture
  76817. */
  76818. 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;
  76819. /**
  76820. * Creates a new raw cube texture from a specified url
  76821. * @param url defines the url where the data is located
  76822. * @param scene defines the current scene
  76823. * @param size defines the size of the textures
  76824. * @param format defines the format of the data
  76825. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76826. * @param noMipmap defines if the engine should avoid generating the mip levels
  76827. * @param callback defines a callback used to extract texture data from loaded data
  76828. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76829. * @param onLoad defines a callback called when texture is loaded
  76830. * @param onError defines a callback called if there is an error
  76831. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76832. * @param invertY defines if data must be stored with Y axis inverted
  76833. * @returns the cube texture as an InternalTexture
  76834. */
  76835. 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;
  76836. /**
  76837. * Creates a new raw 3D texture
  76838. * @param data defines the data used to create the texture
  76839. * @param width defines the width of the texture
  76840. * @param height defines the height of the texture
  76841. * @param depth defines the depth of the texture
  76842. * @param format defines the format of the texture
  76843. * @param generateMipMaps defines if the engine must generate mip levels
  76844. * @param invertY defines if data must be stored with Y axis inverted
  76845. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76846. * @param compression defines the compressed used (can be null)
  76847. * @param textureType defines the compressed used (can be null)
  76848. * @returns a new raw 3D texture (stored in an InternalTexture)
  76849. */
  76850. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76851. /**
  76852. * Update a raw 3D texture
  76853. * @param texture defines the texture to update
  76854. * @param data defines the data to store
  76855. * @param format defines the data format
  76856. * @param invertY defines if data must be stored with Y axis inverted
  76857. */
  76858. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76859. /**
  76860. * Update a raw 3D texture
  76861. * @param texture defines the texture to update
  76862. * @param data defines the data to store
  76863. * @param format defines the data format
  76864. * @param invertY defines if data must be stored with Y axis inverted
  76865. * @param compression defines the used compression (can be null)
  76866. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76867. */
  76868. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76869. }
  76870. }
  76871. declare module BABYLON {
  76872. /**
  76873. * Raw texture can help creating a texture directly from an array of data.
  76874. * This can be super useful if you either get the data from an uncompressed source or
  76875. * if you wish to create your texture pixel by pixel.
  76876. */
  76877. export class RawTexture extends Texture {
  76878. /**
  76879. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76880. */
  76881. format: number;
  76882. private _engine;
  76883. /**
  76884. * Instantiates a new RawTexture.
  76885. * Raw texture can help creating a texture directly from an array of data.
  76886. * This can be super useful if you either get the data from an uncompressed source or
  76887. * if you wish to create your texture pixel by pixel.
  76888. * @param data define the array of data to use to create the texture
  76889. * @param width define the width of the texture
  76890. * @param height define the height of the texture
  76891. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76892. * @param scene define the scene the texture belongs to
  76893. * @param generateMipMaps define whether mip maps should be generated or not
  76894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76897. */
  76898. constructor(data: ArrayBufferView, width: number, height: number,
  76899. /**
  76900. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76901. */
  76902. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76903. /**
  76904. * Updates the texture underlying data.
  76905. * @param data Define the new data of the texture
  76906. */
  76907. update(data: ArrayBufferView): void;
  76908. /**
  76909. * Creates a luminance texture from some data.
  76910. * @param data Define the texture data
  76911. * @param width Define the width of the texture
  76912. * @param height Define the height of the texture
  76913. * @param scene Define the scene the texture belongs to
  76914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76917. * @returns the luminance texture
  76918. */
  76919. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76920. /**
  76921. * Creates a luminance alpha texture from some data.
  76922. * @param data Define the texture data
  76923. * @param width Define the width of the texture
  76924. * @param height Define the height of the texture
  76925. * @param scene Define the scene the texture belongs to
  76926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76929. * @returns the luminance alpha texture
  76930. */
  76931. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76932. /**
  76933. * Creates an alpha texture from some data.
  76934. * @param data Define the texture data
  76935. * @param width Define the width of the texture
  76936. * @param height Define the height of the texture
  76937. * @param scene Define the scene the texture belongs to
  76938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76941. * @returns the alpha texture
  76942. */
  76943. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76944. /**
  76945. * Creates a RGB texture from some data.
  76946. * @param data Define the texture data
  76947. * @param width Define the width of the texture
  76948. * @param height Define the height of the texture
  76949. * @param scene Define the scene the texture belongs to
  76950. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76954. * @returns the RGB alpha texture
  76955. */
  76956. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76957. /**
  76958. * Creates a RGBA texture from some data.
  76959. * @param data Define the texture data
  76960. * @param width Define the width of the texture
  76961. * @param height Define the height of the texture
  76962. * @param scene Define the scene the texture belongs to
  76963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76966. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76967. * @returns the RGBA texture
  76968. */
  76969. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76970. /**
  76971. * Creates a R texture from some data.
  76972. * @param data Define the texture data
  76973. * @param width Define the width of the texture
  76974. * @param height Define the height of the texture
  76975. * @param scene Define the scene the texture belongs to
  76976. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76977. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76978. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76979. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76980. * @returns the R texture
  76981. */
  76982. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76983. }
  76984. }
  76985. declare module BABYLON {
  76986. /**
  76987. * Interface for the size containing width and height
  76988. */
  76989. export interface ISize {
  76990. /**
  76991. * Width
  76992. */
  76993. width: number;
  76994. /**
  76995. * Heighht
  76996. */
  76997. height: number;
  76998. }
  76999. /**
  77000. * Size containing widht and height
  77001. */
  77002. export class Size implements ISize {
  77003. /**
  77004. * Width
  77005. */
  77006. width: number;
  77007. /**
  77008. * Height
  77009. */
  77010. height: number;
  77011. /**
  77012. * Creates a Size object from the given width and height (floats).
  77013. * @param width width of the new size
  77014. * @param height height of the new size
  77015. */
  77016. constructor(width: number, height: number);
  77017. /**
  77018. * Returns a string with the Size width and height
  77019. * @returns a string with the Size width and height
  77020. */
  77021. toString(): string;
  77022. /**
  77023. * "Size"
  77024. * @returns the string "Size"
  77025. */
  77026. getClassName(): string;
  77027. /**
  77028. * Returns the Size hash code.
  77029. * @returns a hash code for a unique width and height
  77030. */
  77031. getHashCode(): number;
  77032. /**
  77033. * Updates the current size from the given one.
  77034. * @param src the given size
  77035. */
  77036. copyFrom(src: Size): void;
  77037. /**
  77038. * Updates in place the current Size from the given floats.
  77039. * @param width width of the new size
  77040. * @param height height of the new size
  77041. * @returns the updated Size.
  77042. */
  77043. copyFromFloats(width: number, height: number): Size;
  77044. /**
  77045. * Updates in place the current Size from the given floats.
  77046. * @param width width to set
  77047. * @param height height to set
  77048. * @returns the updated Size.
  77049. */
  77050. set(width: number, height: number): Size;
  77051. /**
  77052. * Multiplies the width and height by numbers
  77053. * @param w factor to multiple the width by
  77054. * @param h factor to multiple the height by
  77055. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77056. */
  77057. multiplyByFloats(w: number, h: number): Size;
  77058. /**
  77059. * Clones the size
  77060. * @returns a new Size copied from the given one.
  77061. */
  77062. clone(): Size;
  77063. /**
  77064. * True if the current Size and the given one width and height are strictly equal.
  77065. * @param other the other size to compare against
  77066. * @returns True if the current Size and the given one width and height are strictly equal.
  77067. */
  77068. equals(other: Size): boolean;
  77069. /**
  77070. * The surface of the Size : width * height (float).
  77071. */
  77072. readonly surface: number;
  77073. /**
  77074. * Create a new size of zero
  77075. * @returns a new Size set to (0.0, 0.0)
  77076. */
  77077. static Zero(): Size;
  77078. /**
  77079. * Sums the width and height of two sizes
  77080. * @param otherSize size to add to this size
  77081. * @returns a new Size set as the addition result of the current Size and the given one.
  77082. */
  77083. add(otherSize: Size): Size;
  77084. /**
  77085. * Subtracts the width and height of two
  77086. * @param otherSize size to subtract to this size
  77087. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77088. */
  77089. subtract(otherSize: Size): Size;
  77090. /**
  77091. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77092. * @param start starting size to lerp between
  77093. * @param end end size to lerp between
  77094. * @param amount amount to lerp between the start and end values
  77095. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77096. */
  77097. static Lerp(start: Size, end: Size, amount: number): Size;
  77098. }
  77099. }
  77100. declare module BABYLON {
  77101. /**
  77102. * Defines a runtime animation
  77103. */
  77104. export class RuntimeAnimation {
  77105. private _events;
  77106. /**
  77107. * The current frame of the runtime animation
  77108. */
  77109. private _currentFrame;
  77110. /**
  77111. * The animation used by the runtime animation
  77112. */
  77113. private _animation;
  77114. /**
  77115. * The target of the runtime animation
  77116. */
  77117. private _target;
  77118. /**
  77119. * The initiating animatable
  77120. */
  77121. private _host;
  77122. /**
  77123. * The original value of the runtime animation
  77124. */
  77125. private _originalValue;
  77126. /**
  77127. * The original blend value of the runtime animation
  77128. */
  77129. private _originalBlendValue;
  77130. /**
  77131. * The offsets cache of the runtime animation
  77132. */
  77133. private _offsetsCache;
  77134. /**
  77135. * The high limits cache of the runtime animation
  77136. */
  77137. private _highLimitsCache;
  77138. /**
  77139. * Specifies if the runtime animation has been stopped
  77140. */
  77141. private _stopped;
  77142. /**
  77143. * The blending factor of the runtime animation
  77144. */
  77145. private _blendingFactor;
  77146. /**
  77147. * The BabylonJS scene
  77148. */
  77149. private _scene;
  77150. /**
  77151. * The current value of the runtime animation
  77152. */
  77153. private _currentValue;
  77154. /** @hidden */
  77155. _animationState: _IAnimationState;
  77156. /**
  77157. * The active target of the runtime animation
  77158. */
  77159. private _activeTargets;
  77160. private _currentActiveTarget;
  77161. private _directTarget;
  77162. /**
  77163. * The target path of the runtime animation
  77164. */
  77165. private _targetPath;
  77166. /**
  77167. * The weight of the runtime animation
  77168. */
  77169. private _weight;
  77170. /**
  77171. * The ratio offset of the runtime animation
  77172. */
  77173. private _ratioOffset;
  77174. /**
  77175. * The previous delay of the runtime animation
  77176. */
  77177. private _previousDelay;
  77178. /**
  77179. * The previous ratio of the runtime animation
  77180. */
  77181. private _previousRatio;
  77182. private _enableBlending;
  77183. private _keys;
  77184. private _minFrame;
  77185. private _maxFrame;
  77186. private _minValue;
  77187. private _maxValue;
  77188. private _targetIsArray;
  77189. /**
  77190. * Gets the current frame of the runtime animation
  77191. */
  77192. readonly currentFrame: number;
  77193. /**
  77194. * Gets the weight of the runtime animation
  77195. */
  77196. readonly weight: number;
  77197. /**
  77198. * Gets the current value of the runtime animation
  77199. */
  77200. readonly currentValue: any;
  77201. /**
  77202. * Gets the target path of the runtime animation
  77203. */
  77204. readonly targetPath: string;
  77205. /**
  77206. * Gets the actual target of the runtime animation
  77207. */
  77208. readonly target: any;
  77209. /** @hidden */
  77210. _onLoop: () => void;
  77211. /**
  77212. * Create a new RuntimeAnimation object
  77213. * @param target defines the target of the animation
  77214. * @param animation defines the source animation object
  77215. * @param scene defines the hosting scene
  77216. * @param host defines the initiating Animatable
  77217. */
  77218. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77219. private _preparePath;
  77220. /**
  77221. * Gets the animation from the runtime animation
  77222. */
  77223. readonly animation: Animation;
  77224. /**
  77225. * Resets the runtime animation to the beginning
  77226. * @param restoreOriginal defines whether to restore the target property to the original value
  77227. */
  77228. reset(restoreOriginal?: boolean): void;
  77229. /**
  77230. * Specifies if the runtime animation is stopped
  77231. * @returns Boolean specifying if the runtime animation is stopped
  77232. */
  77233. isStopped(): boolean;
  77234. /**
  77235. * Disposes of the runtime animation
  77236. */
  77237. dispose(): void;
  77238. /**
  77239. * Apply the interpolated value to the target
  77240. * @param currentValue defines the value computed by the animation
  77241. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77242. */
  77243. setValue(currentValue: any, weight: number): void;
  77244. private _getOriginalValues;
  77245. private _setValue;
  77246. /**
  77247. * Gets the loop pmode of the runtime animation
  77248. * @returns Loop Mode
  77249. */
  77250. private _getCorrectLoopMode;
  77251. /**
  77252. * Move the current animation to a given frame
  77253. * @param frame defines the frame to move to
  77254. */
  77255. goToFrame(frame: number): void;
  77256. /**
  77257. * @hidden Internal use only
  77258. */
  77259. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77260. /**
  77261. * Execute the current animation
  77262. * @param delay defines the delay to add to the current frame
  77263. * @param from defines the lower bound of the animation range
  77264. * @param to defines the upper bound of the animation range
  77265. * @param loop defines if the current animation must loop
  77266. * @param speedRatio defines the current speed ratio
  77267. * @param weight defines the weight of the animation (default is -1 so no weight)
  77268. * @param onLoop optional callback called when animation loops
  77269. * @returns a boolean indicating if the animation is running
  77270. */
  77271. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77272. }
  77273. }
  77274. declare module BABYLON {
  77275. /**
  77276. * Class used to store an actual running animation
  77277. */
  77278. export class Animatable {
  77279. /** defines the target object */
  77280. target: any;
  77281. /** defines the starting frame number (default is 0) */
  77282. fromFrame: number;
  77283. /** defines the ending frame number (default is 100) */
  77284. toFrame: number;
  77285. /** defines if the animation must loop (default is false) */
  77286. loopAnimation: boolean;
  77287. /** defines a callback to call when animation ends if it is not looping */
  77288. onAnimationEnd?: (() => void) | null | undefined;
  77289. /** defines a callback to call when animation loops */
  77290. onAnimationLoop?: (() => void) | null | undefined;
  77291. private _localDelayOffset;
  77292. private _pausedDelay;
  77293. private _runtimeAnimations;
  77294. private _paused;
  77295. private _scene;
  77296. private _speedRatio;
  77297. private _weight;
  77298. private _syncRoot;
  77299. /**
  77300. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77301. * This will only apply for non looping animation (default is true)
  77302. */
  77303. disposeOnEnd: boolean;
  77304. /**
  77305. * Gets a boolean indicating if the animation has started
  77306. */
  77307. animationStarted: boolean;
  77308. /**
  77309. * Observer raised when the animation ends
  77310. */
  77311. onAnimationEndObservable: Observable<Animatable>;
  77312. /**
  77313. * Observer raised when the animation loops
  77314. */
  77315. onAnimationLoopObservable: Observable<Animatable>;
  77316. /**
  77317. * Gets the root Animatable used to synchronize and normalize animations
  77318. */
  77319. readonly syncRoot: Nullable<Animatable>;
  77320. /**
  77321. * Gets the current frame of the first RuntimeAnimation
  77322. * Used to synchronize Animatables
  77323. */
  77324. readonly masterFrame: number;
  77325. /**
  77326. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77327. */
  77328. weight: number;
  77329. /**
  77330. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77331. */
  77332. speedRatio: number;
  77333. /**
  77334. * Creates a new Animatable
  77335. * @param scene defines the hosting scene
  77336. * @param target defines the target object
  77337. * @param fromFrame defines the starting frame number (default is 0)
  77338. * @param toFrame defines the ending frame number (default is 100)
  77339. * @param loopAnimation defines if the animation must loop (default is false)
  77340. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77341. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77342. * @param animations defines a group of animation to add to the new Animatable
  77343. * @param onAnimationLoop defines a callback to call when animation loops
  77344. */
  77345. constructor(scene: Scene,
  77346. /** defines the target object */
  77347. target: any,
  77348. /** defines the starting frame number (default is 0) */
  77349. fromFrame?: number,
  77350. /** defines the ending frame number (default is 100) */
  77351. toFrame?: number,
  77352. /** defines if the animation must loop (default is false) */
  77353. loopAnimation?: boolean, speedRatio?: number,
  77354. /** defines a callback to call when animation ends if it is not looping */
  77355. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77356. /** defines a callback to call when animation loops */
  77357. onAnimationLoop?: (() => void) | null | undefined);
  77358. /**
  77359. * Synchronize and normalize current Animatable with a source Animatable
  77360. * This is useful when using animation weights and when animations are not of the same length
  77361. * @param root defines the root Animatable to synchronize with
  77362. * @returns the current Animatable
  77363. */
  77364. syncWith(root: Animatable): Animatable;
  77365. /**
  77366. * Gets the list of runtime animations
  77367. * @returns an array of RuntimeAnimation
  77368. */
  77369. getAnimations(): RuntimeAnimation[];
  77370. /**
  77371. * Adds more animations to the current animatable
  77372. * @param target defines the target of the animations
  77373. * @param animations defines the new animations to add
  77374. */
  77375. appendAnimations(target: any, animations: Animation[]): void;
  77376. /**
  77377. * Gets the source animation for a specific property
  77378. * @param property defines the propertyu to look for
  77379. * @returns null or the source animation for the given property
  77380. */
  77381. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77382. /**
  77383. * Gets the runtime animation for a specific property
  77384. * @param property defines the propertyu to look for
  77385. * @returns null or the runtime animation for the given property
  77386. */
  77387. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77388. /**
  77389. * Resets the animatable to its original state
  77390. */
  77391. reset(): void;
  77392. /**
  77393. * Allows the animatable to blend with current running animations
  77394. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77395. * @param blendingSpeed defines the blending speed to use
  77396. */
  77397. enableBlending(blendingSpeed: number): void;
  77398. /**
  77399. * Disable animation blending
  77400. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77401. */
  77402. disableBlending(): void;
  77403. /**
  77404. * Jump directly to a given frame
  77405. * @param frame defines the frame to jump to
  77406. */
  77407. goToFrame(frame: number): void;
  77408. /**
  77409. * Pause the animation
  77410. */
  77411. pause(): void;
  77412. /**
  77413. * Restart the animation
  77414. */
  77415. restart(): void;
  77416. private _raiseOnAnimationEnd;
  77417. /**
  77418. * Stop and delete the current animation
  77419. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77420. * @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)
  77421. */
  77422. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77423. /**
  77424. * Wait asynchronously for the animation to end
  77425. * @returns a promise which will be fullfilled when the animation ends
  77426. */
  77427. waitAsync(): Promise<Animatable>;
  77428. /** @hidden */
  77429. _animate(delay: number): boolean;
  77430. }
  77431. interface Scene {
  77432. /** @hidden */
  77433. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77434. /** @hidden */
  77435. _processLateAnimationBindingsForMatrices(holder: {
  77436. totalWeight: number;
  77437. animations: RuntimeAnimation[];
  77438. originalValue: Matrix;
  77439. }): any;
  77440. /** @hidden */
  77441. _processLateAnimationBindingsForQuaternions(holder: {
  77442. totalWeight: number;
  77443. animations: RuntimeAnimation[];
  77444. originalValue: Quaternion;
  77445. }, refQuaternion: Quaternion): Quaternion;
  77446. /** @hidden */
  77447. _processLateAnimationBindings(): void;
  77448. /**
  77449. * Will start the animation sequence of a given target
  77450. * @param target defines the target
  77451. * @param from defines from which frame should animation start
  77452. * @param to defines until which frame should animation run.
  77453. * @param weight defines the weight to apply to the animation (1.0 by default)
  77454. * @param loop defines if the animation loops
  77455. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77456. * @param onAnimationEnd defines the function to be executed when the animation ends
  77457. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77458. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77459. * @param onAnimationLoop defines the callback to call when an animation loops
  77460. * @returns the animatable object created for this animation
  77461. */
  77462. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77463. /**
  77464. * Will start the animation sequence of a given target
  77465. * @param target defines the target
  77466. * @param from defines from which frame should animation start
  77467. * @param to defines until which frame should animation run.
  77468. * @param loop defines if the animation loops
  77469. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77470. * @param onAnimationEnd defines the function to be executed when the animation ends
  77471. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77472. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77473. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77474. * @param onAnimationLoop defines the callback to call when an animation loops
  77475. * @returns the animatable object created for this animation
  77476. */
  77477. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77478. /**
  77479. * Will start the animation sequence of a given target and its hierarchy
  77480. * @param target defines the target
  77481. * @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.
  77482. * @param from defines from which frame should animation start
  77483. * @param to defines until which frame should animation run.
  77484. * @param loop defines if the animation loops
  77485. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77486. * @param onAnimationEnd defines the function to be executed when the animation ends
  77487. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77488. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77489. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77490. * @param onAnimationLoop defines the callback to call when an animation loops
  77491. * @returns the list of created animatables
  77492. */
  77493. 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[];
  77494. /**
  77495. * Begin a new animation on a given node
  77496. * @param target defines the target where the animation will take place
  77497. * @param animations defines the list of animations to start
  77498. * @param from defines the initial value
  77499. * @param to defines the final value
  77500. * @param loop defines if you want animation to loop (off by default)
  77501. * @param speedRatio defines the speed ratio to apply to all animations
  77502. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77503. * @param onAnimationLoop defines the callback to call when an animation loops
  77504. * @returns the list of created animatables
  77505. */
  77506. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77507. /**
  77508. * Begin a new animation on a given node and its hierarchy
  77509. * @param target defines the root node where the animation will take place
  77510. * @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.
  77511. * @param animations defines the list of animations to start
  77512. * @param from defines the initial value
  77513. * @param to defines the final value
  77514. * @param loop defines if you want animation to loop (off by default)
  77515. * @param speedRatio defines the speed ratio to apply to all animations
  77516. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77517. * @param onAnimationLoop defines the callback to call when an animation loops
  77518. * @returns the list of animatables created for all nodes
  77519. */
  77520. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77521. /**
  77522. * Gets the animatable associated with a specific target
  77523. * @param target defines the target of the animatable
  77524. * @returns the required animatable if found
  77525. */
  77526. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77527. /**
  77528. * Gets all animatables associated with a given target
  77529. * @param target defines the target to look animatables for
  77530. * @returns an array of Animatables
  77531. */
  77532. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77533. /**
  77534. * Stops and removes all animations that have been applied to the scene
  77535. */
  77536. stopAllAnimations(): void;
  77537. }
  77538. interface Bone {
  77539. /**
  77540. * Copy an animation range from another bone
  77541. * @param source defines the source bone
  77542. * @param rangeName defines the range name to copy
  77543. * @param frameOffset defines the frame offset
  77544. * @param rescaleAsRequired defines if rescaling must be applied if required
  77545. * @param skelDimensionsRatio defines the scaling ratio
  77546. * @returns true if operation was successful
  77547. */
  77548. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77549. }
  77550. }
  77551. declare module BABYLON {
  77552. /**
  77553. * Class used to override all child animations of a given target
  77554. */
  77555. export class AnimationPropertiesOverride {
  77556. /**
  77557. * Gets or sets a value indicating if animation blending must be used
  77558. */
  77559. enableBlending: boolean;
  77560. /**
  77561. * Gets or sets the blending speed to use when enableBlending is true
  77562. */
  77563. blendingSpeed: number;
  77564. /**
  77565. * Gets or sets the default loop mode to use
  77566. */
  77567. loopMode: number;
  77568. }
  77569. }
  77570. declare module BABYLON {
  77571. /**
  77572. * Class used to handle skinning animations
  77573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77574. */
  77575. export class Skeleton implements IAnimatable {
  77576. /** defines the skeleton name */
  77577. name: string;
  77578. /** defines the skeleton Id */
  77579. id: string;
  77580. /**
  77581. * Defines the list of child bones
  77582. */
  77583. bones: Bone[];
  77584. /**
  77585. * Defines an estimate of the dimension of the skeleton at rest
  77586. */
  77587. dimensionsAtRest: Vector3;
  77588. /**
  77589. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77590. */
  77591. needInitialSkinMatrix: boolean;
  77592. /**
  77593. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77594. */
  77595. overrideMesh: Nullable<AbstractMesh>;
  77596. /**
  77597. * Gets the list of animations attached to this skeleton
  77598. */
  77599. animations: Array<Animation>;
  77600. private _scene;
  77601. private _isDirty;
  77602. private _transformMatrices;
  77603. private _transformMatrixTexture;
  77604. private _meshesWithPoseMatrix;
  77605. private _animatables;
  77606. private _identity;
  77607. private _synchronizedWithMesh;
  77608. private _ranges;
  77609. private _lastAbsoluteTransformsUpdateId;
  77610. private _canUseTextureForBones;
  77611. private _uniqueId;
  77612. /** @hidden */
  77613. _numBonesWithLinkedTransformNode: number;
  77614. /** @hidden */
  77615. _hasWaitingData: Nullable<boolean>;
  77616. /**
  77617. * Specifies if the skeleton should be serialized
  77618. */
  77619. doNotSerialize: boolean;
  77620. private _useTextureToStoreBoneMatrices;
  77621. /**
  77622. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77623. * Please note that this option is not available if the hardware does not support it
  77624. */
  77625. useTextureToStoreBoneMatrices: boolean;
  77626. private _animationPropertiesOverride;
  77627. /**
  77628. * Gets or sets the animation properties override
  77629. */
  77630. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77631. /**
  77632. * List of inspectable custom properties (used by the Inspector)
  77633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77634. */
  77635. inspectableCustomProperties: IInspectable[];
  77636. /**
  77637. * An observable triggered before computing the skeleton's matrices
  77638. */
  77639. onBeforeComputeObservable: Observable<Skeleton>;
  77640. /**
  77641. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77642. */
  77643. readonly isUsingTextureForMatrices: boolean;
  77644. /**
  77645. * Gets the unique ID of this skeleton
  77646. */
  77647. readonly uniqueId: number;
  77648. /**
  77649. * Creates a new skeleton
  77650. * @param name defines the skeleton name
  77651. * @param id defines the skeleton Id
  77652. * @param scene defines the hosting scene
  77653. */
  77654. constructor(
  77655. /** defines the skeleton name */
  77656. name: string,
  77657. /** defines the skeleton Id */
  77658. id: string, scene: Scene);
  77659. /**
  77660. * Gets the current object class name.
  77661. * @return the class name
  77662. */
  77663. getClassName(): string;
  77664. /**
  77665. * Returns an array containing the root bones
  77666. * @returns an array containing the root bones
  77667. */
  77668. getChildren(): Array<Bone>;
  77669. /**
  77670. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77671. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77672. * @returns a Float32Array containing matrices data
  77673. */
  77674. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77675. /**
  77676. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77677. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77678. * @returns a raw texture containing the data
  77679. */
  77680. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77681. /**
  77682. * Gets the current hosting scene
  77683. * @returns a scene object
  77684. */
  77685. getScene(): Scene;
  77686. /**
  77687. * Gets a string representing the current skeleton data
  77688. * @param fullDetails defines a boolean indicating if we want a verbose version
  77689. * @returns a string representing the current skeleton data
  77690. */
  77691. toString(fullDetails?: boolean): string;
  77692. /**
  77693. * Get bone's index searching by name
  77694. * @param name defines bone's name to search for
  77695. * @return the indice of the bone. Returns -1 if not found
  77696. */
  77697. getBoneIndexByName(name: string): number;
  77698. /**
  77699. * Creater a new animation range
  77700. * @param name defines the name of the range
  77701. * @param from defines the start key
  77702. * @param to defines the end key
  77703. */
  77704. createAnimationRange(name: string, from: number, to: number): void;
  77705. /**
  77706. * Delete a specific animation range
  77707. * @param name defines the name of the range
  77708. * @param deleteFrames defines if frames must be removed as well
  77709. */
  77710. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77711. /**
  77712. * Gets a specific animation range
  77713. * @param name defines the name of the range to look for
  77714. * @returns the requested animation range or null if not found
  77715. */
  77716. getAnimationRange(name: string): Nullable<AnimationRange>;
  77717. /**
  77718. * Gets the list of all animation ranges defined on this skeleton
  77719. * @returns an array
  77720. */
  77721. getAnimationRanges(): Nullable<AnimationRange>[];
  77722. /**
  77723. * Copy animation range from a source skeleton.
  77724. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77725. * @param source defines the source skeleton
  77726. * @param name defines the name of the range to copy
  77727. * @param rescaleAsRequired defines if rescaling must be applied if required
  77728. * @returns true if operation was successful
  77729. */
  77730. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77731. /**
  77732. * Forces the skeleton to go to rest pose
  77733. */
  77734. returnToRest(): void;
  77735. private _getHighestAnimationFrame;
  77736. /**
  77737. * Begin a specific animation range
  77738. * @param name defines the name of the range to start
  77739. * @param loop defines if looping must be turned on (false by default)
  77740. * @param speedRatio defines the speed ratio to apply (1 by default)
  77741. * @param onAnimationEnd defines a callback which will be called when animation will end
  77742. * @returns a new animatable
  77743. */
  77744. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77745. /** @hidden */
  77746. _markAsDirty(): void;
  77747. /** @hidden */
  77748. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77749. /** @hidden */
  77750. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77751. private _computeTransformMatrices;
  77752. /**
  77753. * Build all resources required to render a skeleton
  77754. */
  77755. prepare(): void;
  77756. /**
  77757. * Gets the list of animatables currently running for this skeleton
  77758. * @returns an array of animatables
  77759. */
  77760. getAnimatables(): IAnimatable[];
  77761. /**
  77762. * Clone the current skeleton
  77763. * @param name defines the name of the new skeleton
  77764. * @param id defines the id of the new skeleton
  77765. * @returns the new skeleton
  77766. */
  77767. clone(name: string, id: string): Skeleton;
  77768. /**
  77769. * Enable animation blending for this skeleton
  77770. * @param blendingSpeed defines the blending speed to apply
  77771. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77772. */
  77773. enableBlending(blendingSpeed?: number): void;
  77774. /**
  77775. * Releases all resources associated with the current skeleton
  77776. */
  77777. dispose(): void;
  77778. /**
  77779. * Serialize the skeleton in a JSON object
  77780. * @returns a JSON object
  77781. */
  77782. serialize(): any;
  77783. /**
  77784. * Creates a new skeleton from serialized data
  77785. * @param parsedSkeleton defines the serialized data
  77786. * @param scene defines the hosting scene
  77787. * @returns a new skeleton
  77788. */
  77789. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77790. /**
  77791. * Compute all node absolute transforms
  77792. * @param forceUpdate defines if computation must be done even if cache is up to date
  77793. */
  77794. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77795. /**
  77796. * Gets the root pose matrix
  77797. * @returns a matrix
  77798. */
  77799. getPoseMatrix(): Nullable<Matrix>;
  77800. /**
  77801. * Sorts bones per internal index
  77802. */
  77803. sortBones(): void;
  77804. private _sortBones;
  77805. }
  77806. }
  77807. declare module BABYLON {
  77808. /**
  77809. * Class used to store bone information
  77810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77811. */
  77812. export class Bone extends Node {
  77813. /**
  77814. * defines the bone name
  77815. */
  77816. name: string;
  77817. private static _tmpVecs;
  77818. private static _tmpQuat;
  77819. private static _tmpMats;
  77820. /**
  77821. * Gets the list of child bones
  77822. */
  77823. children: Bone[];
  77824. /** Gets the animations associated with this bone */
  77825. animations: Animation[];
  77826. /**
  77827. * Gets or sets bone length
  77828. */
  77829. length: number;
  77830. /**
  77831. * @hidden Internal only
  77832. * Set this value to map this bone to a different index in the transform matrices
  77833. * Set this value to -1 to exclude the bone from the transform matrices
  77834. */
  77835. _index: Nullable<number>;
  77836. private _skeleton;
  77837. private _localMatrix;
  77838. private _restPose;
  77839. private _baseMatrix;
  77840. private _absoluteTransform;
  77841. private _invertedAbsoluteTransform;
  77842. private _parent;
  77843. private _scalingDeterminant;
  77844. private _worldTransform;
  77845. private _localScaling;
  77846. private _localRotation;
  77847. private _localPosition;
  77848. private _needToDecompose;
  77849. private _needToCompose;
  77850. /** @hidden */
  77851. _linkedTransformNode: Nullable<TransformNode>;
  77852. /** @hidden */
  77853. _waitingTransformNodeId: Nullable<string>;
  77854. /** @hidden */
  77855. /** @hidden */
  77856. _matrix: Matrix;
  77857. /**
  77858. * Create a new bone
  77859. * @param name defines the bone name
  77860. * @param skeleton defines the parent skeleton
  77861. * @param parentBone defines the parent (can be null if the bone is the root)
  77862. * @param localMatrix defines the local matrix
  77863. * @param restPose defines the rest pose matrix
  77864. * @param baseMatrix defines the base matrix
  77865. * @param index defines index of the bone in the hiearchy
  77866. */
  77867. constructor(
  77868. /**
  77869. * defines the bone name
  77870. */
  77871. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77872. /**
  77873. * Gets the current object class name.
  77874. * @return the class name
  77875. */
  77876. getClassName(): string;
  77877. /**
  77878. * Gets the parent skeleton
  77879. * @returns a skeleton
  77880. */
  77881. getSkeleton(): Skeleton;
  77882. /**
  77883. * Gets parent bone
  77884. * @returns a bone or null if the bone is the root of the bone hierarchy
  77885. */
  77886. getParent(): Nullable<Bone>;
  77887. /**
  77888. * Returns an array containing the root bones
  77889. * @returns an array containing the root bones
  77890. */
  77891. getChildren(): Array<Bone>;
  77892. /**
  77893. * Sets the parent bone
  77894. * @param parent defines the parent (can be null if the bone is the root)
  77895. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77896. */
  77897. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77898. /**
  77899. * Gets the local matrix
  77900. * @returns a matrix
  77901. */
  77902. getLocalMatrix(): Matrix;
  77903. /**
  77904. * Gets the base matrix (initial matrix which remains unchanged)
  77905. * @returns a matrix
  77906. */
  77907. getBaseMatrix(): Matrix;
  77908. /**
  77909. * Gets the rest pose matrix
  77910. * @returns a matrix
  77911. */
  77912. getRestPose(): Matrix;
  77913. /**
  77914. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77915. */
  77916. getWorldMatrix(): Matrix;
  77917. /**
  77918. * Sets the local matrix to rest pose matrix
  77919. */
  77920. returnToRest(): void;
  77921. /**
  77922. * Gets the inverse of the absolute transform matrix.
  77923. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77924. * @returns a matrix
  77925. */
  77926. getInvertedAbsoluteTransform(): Matrix;
  77927. /**
  77928. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77929. * @returns a matrix
  77930. */
  77931. getAbsoluteTransform(): Matrix;
  77932. /**
  77933. * Links with the given transform node.
  77934. * The local matrix of this bone is copied from the transform node every frame.
  77935. * @param transformNode defines the transform node to link to
  77936. */
  77937. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77938. /**
  77939. * Gets the node used to drive the bone's transformation
  77940. * @returns a transform node or null
  77941. */
  77942. getTransformNode(): Nullable<TransformNode>;
  77943. /** Gets or sets current position (in local space) */
  77944. position: Vector3;
  77945. /** Gets or sets current rotation (in local space) */
  77946. rotation: Vector3;
  77947. /** Gets or sets current rotation quaternion (in local space) */
  77948. rotationQuaternion: Quaternion;
  77949. /** Gets or sets current scaling (in local space) */
  77950. scaling: Vector3;
  77951. /**
  77952. * Gets the animation properties override
  77953. */
  77954. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77955. private _decompose;
  77956. private _compose;
  77957. /**
  77958. * Update the base and local matrices
  77959. * @param matrix defines the new base or local matrix
  77960. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77961. * @param updateLocalMatrix defines if the local matrix should be updated
  77962. */
  77963. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77964. /** @hidden */
  77965. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77966. /**
  77967. * Flag the bone as dirty (Forcing it to update everything)
  77968. */
  77969. markAsDirty(): void;
  77970. /** @hidden */
  77971. _markAsDirtyAndCompose(): void;
  77972. private _markAsDirtyAndDecompose;
  77973. /**
  77974. * Translate the bone in local or world space
  77975. * @param vec The amount to translate the bone
  77976. * @param space The space that the translation is in
  77977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77978. */
  77979. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77980. /**
  77981. * Set the postion of the bone in local or world space
  77982. * @param position The position to set the bone
  77983. * @param space The space that the position is in
  77984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77985. */
  77986. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77987. /**
  77988. * Set the absolute position of the bone (world space)
  77989. * @param position The position to set the bone
  77990. * @param mesh The mesh that this bone is attached to
  77991. */
  77992. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77993. /**
  77994. * Scale the bone on the x, y and z axes (in local space)
  77995. * @param x The amount to scale the bone on the x axis
  77996. * @param y The amount to scale the bone on the y axis
  77997. * @param z The amount to scale the bone on the z axis
  77998. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77999. */
  78000. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78001. /**
  78002. * Set the bone scaling in local space
  78003. * @param scale defines the scaling vector
  78004. */
  78005. setScale(scale: Vector3): void;
  78006. /**
  78007. * Gets the current scaling in local space
  78008. * @returns the current scaling vector
  78009. */
  78010. getScale(): Vector3;
  78011. /**
  78012. * Gets the current scaling in local space and stores it in a target vector
  78013. * @param result defines the target vector
  78014. */
  78015. getScaleToRef(result: Vector3): void;
  78016. /**
  78017. * Set the yaw, pitch, and roll of the bone in local or world space
  78018. * @param yaw The rotation of the bone on the y axis
  78019. * @param pitch The rotation of the bone on the x axis
  78020. * @param roll The rotation of the bone on the z axis
  78021. * @param space The space that the axes of rotation are in
  78022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78023. */
  78024. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78025. /**
  78026. * Add a rotation to the bone on an axis in local or world space
  78027. * @param axis The axis to rotate the bone on
  78028. * @param amount The amount to rotate the bone
  78029. * @param space The space that the axis is in
  78030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78031. */
  78032. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78033. /**
  78034. * Set the rotation of the bone to a particular axis angle in local or world space
  78035. * @param axis The axis to rotate the bone on
  78036. * @param angle The angle that the bone should be rotated to
  78037. * @param space The space that the axis is in
  78038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78039. */
  78040. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78041. /**
  78042. * Set the euler rotation of the bone in local of world space
  78043. * @param rotation The euler rotation that the bone should be set to
  78044. * @param space The space that the rotation is in
  78045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78046. */
  78047. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78048. /**
  78049. * Set the quaternion rotation of the bone in local of world space
  78050. * @param quat The quaternion rotation that the bone should be set to
  78051. * @param space The space that the rotation is in
  78052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78053. */
  78054. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78055. /**
  78056. * Set the rotation matrix of the bone in local of world space
  78057. * @param rotMat The rotation matrix that the bone should be set to
  78058. * @param space The space that the rotation is in
  78059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78060. */
  78061. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78062. private _rotateWithMatrix;
  78063. private _getNegativeRotationToRef;
  78064. /**
  78065. * Get the position of the bone in local or world space
  78066. * @param space The space that the returned position is in
  78067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78068. * @returns The position of the bone
  78069. */
  78070. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78071. /**
  78072. * Copy the position of the bone to a vector3 in local or world space
  78073. * @param space The space that the returned position is in
  78074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78075. * @param result The vector3 to copy the position to
  78076. */
  78077. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78078. /**
  78079. * Get the absolute position of the bone (world space)
  78080. * @param mesh The mesh that this bone is attached to
  78081. * @returns The absolute position of the bone
  78082. */
  78083. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78084. /**
  78085. * Copy the absolute position of the bone (world space) to the result param
  78086. * @param mesh The mesh that this bone is attached to
  78087. * @param result The vector3 to copy the absolute position to
  78088. */
  78089. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78090. /**
  78091. * Compute the absolute transforms of this bone and its children
  78092. */
  78093. computeAbsoluteTransforms(): void;
  78094. /**
  78095. * Get the world direction from an axis that is in the local space of the bone
  78096. * @param localAxis The local direction that is used to compute the world direction
  78097. * @param mesh The mesh that this bone is attached to
  78098. * @returns The world direction
  78099. */
  78100. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78101. /**
  78102. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78103. * @param localAxis The local direction that is used to compute the world direction
  78104. * @param mesh The mesh that this bone is attached to
  78105. * @param result The vector3 that the world direction will be copied to
  78106. */
  78107. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78108. /**
  78109. * Get the euler rotation of the bone in local or world space
  78110. * @param space The space that the rotation should be in
  78111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78112. * @returns The euler rotation
  78113. */
  78114. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78115. /**
  78116. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78117. * @param space The space that the rotation should be in
  78118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78119. * @param result The vector3 that the rotation should be copied to
  78120. */
  78121. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78122. /**
  78123. * Get the quaternion rotation of the bone in either local or world space
  78124. * @param space The space that the rotation should be in
  78125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78126. * @returns The quaternion rotation
  78127. */
  78128. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78129. /**
  78130. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78131. * @param space The space that the rotation should be in
  78132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78133. * @param result The quaternion that the rotation should be copied to
  78134. */
  78135. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78136. /**
  78137. * Get the rotation matrix of the bone in local or world space
  78138. * @param space The space that the rotation should be in
  78139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78140. * @returns The rotation matrix
  78141. */
  78142. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78143. /**
  78144. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78145. * @param space The space that the rotation should be in
  78146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78147. * @param result The quaternion that the rotation should be copied to
  78148. */
  78149. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78150. /**
  78151. * Get the world position of a point that is in the local space of the bone
  78152. * @param position The local position
  78153. * @param mesh The mesh that this bone is attached to
  78154. * @returns The world position
  78155. */
  78156. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78157. /**
  78158. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78159. * @param position The local position
  78160. * @param mesh The mesh that this bone is attached to
  78161. * @param result The vector3 that the world position should be copied to
  78162. */
  78163. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78164. /**
  78165. * Get the local position of a point that is in world space
  78166. * @param position The world position
  78167. * @param mesh The mesh that this bone is attached to
  78168. * @returns The local position
  78169. */
  78170. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78171. /**
  78172. * Get the local position of a point that is in world space and copy it to the result param
  78173. * @param position The world position
  78174. * @param mesh The mesh that this bone is attached to
  78175. * @param result The vector3 that the local position should be copied to
  78176. */
  78177. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78178. }
  78179. }
  78180. declare module BABYLON {
  78181. /**
  78182. * 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.
  78183. * @see https://doc.babylonjs.com/how_to/transformnode
  78184. */
  78185. export class TransformNode extends Node {
  78186. /**
  78187. * Object will not rotate to face the camera
  78188. */
  78189. static BILLBOARDMODE_NONE: number;
  78190. /**
  78191. * Object will rotate to face the camera but only on the x axis
  78192. */
  78193. static BILLBOARDMODE_X: number;
  78194. /**
  78195. * Object will rotate to face the camera but only on the y axis
  78196. */
  78197. static BILLBOARDMODE_Y: number;
  78198. /**
  78199. * Object will rotate to face the camera but only on the z axis
  78200. */
  78201. static BILLBOARDMODE_Z: number;
  78202. /**
  78203. * Object will rotate to face the camera
  78204. */
  78205. static BILLBOARDMODE_ALL: number;
  78206. /**
  78207. * Object will rotate to face the camera's position instead of orientation
  78208. */
  78209. static BILLBOARDMODE_USE_POSITION: number;
  78210. private _forward;
  78211. private _forwardInverted;
  78212. private _up;
  78213. private _right;
  78214. private _rightInverted;
  78215. private _position;
  78216. private _rotation;
  78217. private _rotationQuaternion;
  78218. protected _scaling: Vector3;
  78219. protected _isDirty: boolean;
  78220. private _transformToBoneReferal;
  78221. private _isAbsoluteSynced;
  78222. private _billboardMode;
  78223. /**
  78224. * Gets or sets the billboard mode. Default is 0.
  78225. *
  78226. * | Value | Type | Description |
  78227. * | --- | --- | --- |
  78228. * | 0 | BILLBOARDMODE_NONE | |
  78229. * | 1 | BILLBOARDMODE_X | |
  78230. * | 2 | BILLBOARDMODE_Y | |
  78231. * | 4 | BILLBOARDMODE_Z | |
  78232. * | 7 | BILLBOARDMODE_ALL | |
  78233. *
  78234. */
  78235. billboardMode: number;
  78236. private _preserveParentRotationForBillboard;
  78237. /**
  78238. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78239. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78240. */
  78241. preserveParentRotationForBillboard: boolean;
  78242. /**
  78243. * 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
  78244. */
  78245. scalingDeterminant: number;
  78246. private _infiniteDistance;
  78247. /**
  78248. * Gets or sets the distance of the object to max, often used by skybox
  78249. */
  78250. infiniteDistance: boolean;
  78251. /**
  78252. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78253. * By default the system will update normals to compensate
  78254. */
  78255. ignoreNonUniformScaling: boolean;
  78256. /**
  78257. * 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
  78258. */
  78259. reIntegrateRotationIntoRotationQuaternion: boolean;
  78260. /** @hidden */
  78261. _poseMatrix: Nullable<Matrix>;
  78262. /** @hidden */
  78263. _localMatrix: Matrix;
  78264. private _usePivotMatrix;
  78265. private _absolutePosition;
  78266. private _absoluteScaling;
  78267. private _absoluteRotationQuaternion;
  78268. private _pivotMatrix;
  78269. private _pivotMatrixInverse;
  78270. protected _postMultiplyPivotMatrix: boolean;
  78271. protected _isWorldMatrixFrozen: boolean;
  78272. /** @hidden */
  78273. _indexInSceneTransformNodesArray: number;
  78274. /**
  78275. * An event triggered after the world matrix is updated
  78276. */
  78277. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78278. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78279. /**
  78280. * Gets a string identifying the name of the class
  78281. * @returns "TransformNode" string
  78282. */
  78283. getClassName(): string;
  78284. /**
  78285. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78286. */
  78287. position: Vector3;
  78288. /**
  78289. * 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)).
  78290. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78291. */
  78292. rotation: Vector3;
  78293. /**
  78294. * 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)).
  78295. */
  78296. scaling: Vector3;
  78297. /**
  78298. * 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).
  78299. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78300. */
  78301. rotationQuaternion: Nullable<Quaternion>;
  78302. /**
  78303. * The forward direction of that transform in world space.
  78304. */
  78305. readonly forward: Vector3;
  78306. /**
  78307. * The up direction of that transform in world space.
  78308. */
  78309. readonly up: Vector3;
  78310. /**
  78311. * The right direction of that transform in world space.
  78312. */
  78313. readonly right: Vector3;
  78314. /**
  78315. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78316. * @param matrix the matrix to copy the pose from
  78317. * @returns this TransformNode.
  78318. */
  78319. updatePoseMatrix(matrix: Matrix): TransformNode;
  78320. /**
  78321. * Returns the mesh Pose matrix.
  78322. * @returns the pose matrix
  78323. */
  78324. getPoseMatrix(): Matrix;
  78325. /** @hidden */
  78326. _isSynchronized(): boolean;
  78327. /** @hidden */
  78328. _initCache(): void;
  78329. /**
  78330. * Flag the transform node as dirty (Forcing it to update everything)
  78331. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78332. * @returns this transform node
  78333. */
  78334. markAsDirty(property: string): TransformNode;
  78335. /**
  78336. * Returns the current mesh absolute position.
  78337. * Returns a Vector3.
  78338. */
  78339. readonly absolutePosition: Vector3;
  78340. /**
  78341. * Returns the current mesh absolute scaling.
  78342. * Returns a Vector3.
  78343. */
  78344. readonly absoluteScaling: Vector3;
  78345. /**
  78346. * Returns the current mesh absolute rotation.
  78347. * Returns a Quaternion.
  78348. */
  78349. readonly absoluteRotationQuaternion: Quaternion;
  78350. /**
  78351. * Sets a new matrix to apply before all other transformation
  78352. * @param matrix defines the transform matrix
  78353. * @returns the current TransformNode
  78354. */
  78355. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78356. /**
  78357. * Sets a new pivot matrix to the current node
  78358. * @param matrix defines the new pivot matrix to use
  78359. * @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
  78360. * @returns the current TransformNode
  78361. */
  78362. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78363. /**
  78364. * Returns the mesh pivot matrix.
  78365. * Default : Identity.
  78366. * @returns the matrix
  78367. */
  78368. getPivotMatrix(): Matrix;
  78369. /**
  78370. * Prevents the World matrix to be computed any longer.
  78371. * @returns the TransformNode.
  78372. */
  78373. freezeWorldMatrix(): TransformNode;
  78374. /**
  78375. * Allows back the World matrix computation.
  78376. * @returns the TransformNode.
  78377. */
  78378. unfreezeWorldMatrix(): this;
  78379. /**
  78380. * True if the World matrix has been frozen.
  78381. */
  78382. readonly isWorldMatrixFrozen: boolean;
  78383. /**
  78384. * Retuns the mesh absolute position in the World.
  78385. * @returns a Vector3.
  78386. */
  78387. getAbsolutePosition(): Vector3;
  78388. /**
  78389. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78390. * @param absolutePosition the absolute position to set
  78391. * @returns the TransformNode.
  78392. */
  78393. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78394. /**
  78395. * Sets the mesh position in its local space.
  78396. * @param vector3 the position to set in localspace
  78397. * @returns the TransformNode.
  78398. */
  78399. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78400. /**
  78401. * Returns the mesh position in the local space from the current World matrix values.
  78402. * @returns a new Vector3.
  78403. */
  78404. getPositionExpressedInLocalSpace(): Vector3;
  78405. /**
  78406. * Translates the mesh along the passed Vector3 in its local space.
  78407. * @param vector3 the distance to translate in localspace
  78408. * @returns the TransformNode.
  78409. */
  78410. locallyTranslate(vector3: Vector3): TransformNode;
  78411. private static _lookAtVectorCache;
  78412. /**
  78413. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78414. * @param targetPoint the position (must be in same space as current mesh) to look at
  78415. * @param yawCor optional yaw (y-axis) correction in radians
  78416. * @param pitchCor optional pitch (x-axis) correction in radians
  78417. * @param rollCor optional roll (z-axis) correction in radians
  78418. * @param space the choosen space of the target
  78419. * @returns the TransformNode.
  78420. */
  78421. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78422. /**
  78423. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78424. * This Vector3 is expressed in the World space.
  78425. * @param localAxis axis to rotate
  78426. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78427. */
  78428. getDirection(localAxis: Vector3): Vector3;
  78429. /**
  78430. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78431. * localAxis is expressed in the mesh local space.
  78432. * result is computed in the Wordl space from the mesh World matrix.
  78433. * @param localAxis axis to rotate
  78434. * @param result the resulting transformnode
  78435. * @returns this TransformNode.
  78436. */
  78437. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78438. /**
  78439. * Sets this transform node rotation to the given local axis.
  78440. * @param localAxis the axis in local space
  78441. * @param yawCor optional yaw (y-axis) correction in radians
  78442. * @param pitchCor optional pitch (x-axis) correction in radians
  78443. * @param rollCor optional roll (z-axis) correction in radians
  78444. * @returns this TransformNode
  78445. */
  78446. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78447. /**
  78448. * Sets a new pivot point to the current node
  78449. * @param point defines the new pivot point to use
  78450. * @param space defines if the point is in world or local space (local by default)
  78451. * @returns the current TransformNode
  78452. */
  78453. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78454. /**
  78455. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78456. * @returns the pivot point
  78457. */
  78458. getPivotPoint(): Vector3;
  78459. /**
  78460. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78461. * @param result the vector3 to store the result
  78462. * @returns this TransformNode.
  78463. */
  78464. getPivotPointToRef(result: Vector3): TransformNode;
  78465. /**
  78466. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78467. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78468. */
  78469. getAbsolutePivotPoint(): Vector3;
  78470. /**
  78471. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78472. * @param result vector3 to store the result
  78473. * @returns this TransformNode.
  78474. */
  78475. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78476. /**
  78477. * Defines the passed node as the parent of the current node.
  78478. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78479. * @see https://doc.babylonjs.com/how_to/parenting
  78480. * @param node the node ot set as the parent
  78481. * @returns this TransformNode.
  78482. */
  78483. setParent(node: Nullable<Node>): TransformNode;
  78484. private _nonUniformScaling;
  78485. /**
  78486. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78487. */
  78488. readonly nonUniformScaling: boolean;
  78489. /** @hidden */
  78490. _updateNonUniformScalingState(value: boolean): boolean;
  78491. /**
  78492. * Attach the current TransformNode to another TransformNode associated with a bone
  78493. * @param bone Bone affecting the TransformNode
  78494. * @param affectedTransformNode TransformNode associated with the bone
  78495. * @returns this object
  78496. */
  78497. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78498. /**
  78499. * Detach the transform node if its associated with a bone
  78500. * @returns this object
  78501. */
  78502. detachFromBone(): TransformNode;
  78503. private static _rotationAxisCache;
  78504. /**
  78505. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78506. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78507. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78508. * The passed axis is also normalized.
  78509. * @param axis the axis to rotate around
  78510. * @param amount the amount to rotate in radians
  78511. * @param space Space to rotate in (Default: local)
  78512. * @returns the TransformNode.
  78513. */
  78514. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78515. /**
  78516. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78517. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78518. * The passed axis is also normalized. .
  78519. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78520. * @param point the point to rotate around
  78521. * @param axis the axis to rotate around
  78522. * @param amount the amount to rotate in radians
  78523. * @returns the TransformNode
  78524. */
  78525. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78526. /**
  78527. * Translates the mesh along the axis vector for the passed distance in the given space.
  78528. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78529. * @param axis the axis to translate in
  78530. * @param distance the distance to translate
  78531. * @param space Space to rotate in (Default: local)
  78532. * @returns the TransformNode.
  78533. */
  78534. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78535. /**
  78536. * Adds a rotation step to the mesh current rotation.
  78537. * x, y, z are Euler angles expressed in radians.
  78538. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78539. * This means this rotation is made in the mesh local space only.
  78540. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78541. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78542. * ```javascript
  78543. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78544. * ```
  78545. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78546. * 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.
  78547. * @param x Rotation to add
  78548. * @param y Rotation to add
  78549. * @param z Rotation to add
  78550. * @returns the TransformNode.
  78551. */
  78552. addRotation(x: number, y: number, z: number): TransformNode;
  78553. /**
  78554. * @hidden
  78555. */
  78556. protected _getEffectiveParent(): Nullable<Node>;
  78557. /**
  78558. * Computes the world matrix of the node
  78559. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78560. * @returns the world matrix
  78561. */
  78562. computeWorldMatrix(force?: boolean): Matrix;
  78563. protected _afterComputeWorldMatrix(): void;
  78564. /**
  78565. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78566. * @param func callback function to add
  78567. *
  78568. * @returns the TransformNode.
  78569. */
  78570. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78571. /**
  78572. * Removes a registered callback function.
  78573. * @param func callback function to remove
  78574. * @returns the TransformNode.
  78575. */
  78576. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78577. /**
  78578. * Gets the position of the current mesh in camera space
  78579. * @param camera defines the camera to use
  78580. * @returns a position
  78581. */
  78582. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78583. /**
  78584. * Returns the distance from the mesh to the active camera
  78585. * @param camera defines the camera to use
  78586. * @returns the distance
  78587. */
  78588. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78589. /**
  78590. * Clone the current transform node
  78591. * @param name Name of the new clone
  78592. * @param newParent New parent for the clone
  78593. * @param doNotCloneChildren Do not clone children hierarchy
  78594. * @returns the new transform node
  78595. */
  78596. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78597. /**
  78598. * Serializes the objects information.
  78599. * @param currentSerializationObject defines the object to serialize in
  78600. * @returns the serialized object
  78601. */
  78602. serialize(currentSerializationObject?: any): any;
  78603. /**
  78604. * Returns a new TransformNode object parsed from the source provided.
  78605. * @param parsedTransformNode is the source.
  78606. * @param scene the scne the object belongs to
  78607. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78608. * @returns a new TransformNode object parsed from the source provided.
  78609. */
  78610. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78611. /**
  78612. * Get all child-transformNodes of this node
  78613. * @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
  78614. * @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
  78615. * @returns an array of TransformNode
  78616. */
  78617. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78618. /**
  78619. * Releases resources associated with this transform node.
  78620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78622. */
  78623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78624. /**
  78625. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78626. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78627. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78628. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78629. * @returns the current mesh
  78630. */
  78631. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78632. private _syncAbsoluteScalingAndRotation;
  78633. }
  78634. }
  78635. declare module BABYLON {
  78636. /**
  78637. * Defines the types of pose enabled controllers that are supported
  78638. */
  78639. export enum PoseEnabledControllerType {
  78640. /**
  78641. * HTC Vive
  78642. */
  78643. VIVE = 0,
  78644. /**
  78645. * Oculus Rift
  78646. */
  78647. OCULUS = 1,
  78648. /**
  78649. * Windows mixed reality
  78650. */
  78651. WINDOWS = 2,
  78652. /**
  78653. * Samsung gear VR
  78654. */
  78655. GEAR_VR = 3,
  78656. /**
  78657. * Google Daydream
  78658. */
  78659. DAYDREAM = 4,
  78660. /**
  78661. * Generic
  78662. */
  78663. GENERIC = 5
  78664. }
  78665. /**
  78666. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78667. */
  78668. export interface MutableGamepadButton {
  78669. /**
  78670. * Value of the button/trigger
  78671. */
  78672. value: number;
  78673. /**
  78674. * If the button/trigger is currently touched
  78675. */
  78676. touched: boolean;
  78677. /**
  78678. * If the button/trigger is currently pressed
  78679. */
  78680. pressed: boolean;
  78681. }
  78682. /**
  78683. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78684. * @hidden
  78685. */
  78686. export interface ExtendedGamepadButton extends GamepadButton {
  78687. /**
  78688. * If the button/trigger is currently pressed
  78689. */
  78690. readonly pressed: boolean;
  78691. /**
  78692. * If the button/trigger is currently touched
  78693. */
  78694. readonly touched: boolean;
  78695. /**
  78696. * Value of the button/trigger
  78697. */
  78698. readonly value: number;
  78699. }
  78700. /** @hidden */
  78701. export interface _GamePadFactory {
  78702. /**
  78703. * Returns wether or not the current gamepad can be created for this type of controller.
  78704. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78705. * @returns true if it can be created, otherwise false
  78706. */
  78707. canCreate(gamepadInfo: any): boolean;
  78708. /**
  78709. * Creates a new instance of the Gamepad.
  78710. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78711. * @returns the new gamepad instance
  78712. */
  78713. create(gamepadInfo: any): Gamepad;
  78714. }
  78715. /**
  78716. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78717. */
  78718. export class PoseEnabledControllerHelper {
  78719. /** @hidden */
  78720. static _ControllerFactories: _GamePadFactory[];
  78721. /** @hidden */
  78722. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78723. /**
  78724. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78725. * @param vrGamepad the gamepad to initialized
  78726. * @returns a vr controller of the type the gamepad identified as
  78727. */
  78728. static InitiateController(vrGamepad: any): Gamepad;
  78729. }
  78730. /**
  78731. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78732. */
  78733. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78734. /**
  78735. * If the controller is used in a webXR session
  78736. */
  78737. isXR: boolean;
  78738. private _deviceRoomPosition;
  78739. private _deviceRoomRotationQuaternion;
  78740. /**
  78741. * The device position in babylon space
  78742. */
  78743. devicePosition: Vector3;
  78744. /**
  78745. * The device rotation in babylon space
  78746. */
  78747. deviceRotationQuaternion: Quaternion;
  78748. /**
  78749. * The scale factor of the device in babylon space
  78750. */
  78751. deviceScaleFactor: number;
  78752. /**
  78753. * (Likely devicePosition should be used instead) The device position in its room space
  78754. */
  78755. position: Vector3;
  78756. /**
  78757. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78758. */
  78759. rotationQuaternion: Quaternion;
  78760. /**
  78761. * The type of controller (Eg. Windows mixed reality)
  78762. */
  78763. controllerType: PoseEnabledControllerType;
  78764. protected _calculatedPosition: Vector3;
  78765. private _calculatedRotation;
  78766. /**
  78767. * The raw pose from the device
  78768. */
  78769. rawPose: DevicePose;
  78770. private _trackPosition;
  78771. private _maxRotationDistFromHeadset;
  78772. private _draggedRoomRotation;
  78773. /**
  78774. * @hidden
  78775. */
  78776. _disableTrackPosition(fixedPosition: Vector3): void;
  78777. /**
  78778. * Internal, the mesh attached to the controller
  78779. * @hidden
  78780. */
  78781. _mesh: Nullable<AbstractMesh>;
  78782. private _poseControlledCamera;
  78783. private _leftHandSystemQuaternion;
  78784. /**
  78785. * Internal, matrix used to convert room space to babylon space
  78786. * @hidden
  78787. */
  78788. _deviceToWorld: Matrix;
  78789. /**
  78790. * Node to be used when casting a ray from the controller
  78791. * @hidden
  78792. */
  78793. _pointingPoseNode: Nullable<TransformNode>;
  78794. /**
  78795. * Name of the child mesh that can be used to cast a ray from the controller
  78796. */
  78797. static readonly POINTING_POSE: string;
  78798. /**
  78799. * Creates a new PoseEnabledController from a gamepad
  78800. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78801. */
  78802. constructor(browserGamepad: any);
  78803. private _workingMatrix;
  78804. /**
  78805. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78806. */
  78807. update(): void;
  78808. /**
  78809. * Updates only the pose device and mesh without doing any button event checking
  78810. */
  78811. protected _updatePoseAndMesh(): void;
  78812. /**
  78813. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78814. * @param poseData raw pose fromthe device
  78815. */
  78816. updateFromDevice(poseData: DevicePose): void;
  78817. /**
  78818. * @hidden
  78819. */
  78820. _meshAttachedObservable: Observable<AbstractMesh>;
  78821. /**
  78822. * Attaches a mesh to the controller
  78823. * @param mesh the mesh to be attached
  78824. */
  78825. attachToMesh(mesh: AbstractMesh): void;
  78826. /**
  78827. * Attaches the controllers mesh to a camera
  78828. * @param camera the camera the mesh should be attached to
  78829. */
  78830. attachToPoseControlledCamera(camera: TargetCamera): void;
  78831. /**
  78832. * Disposes of the controller
  78833. */
  78834. dispose(): void;
  78835. /**
  78836. * The mesh that is attached to the controller
  78837. */
  78838. readonly mesh: Nullable<AbstractMesh>;
  78839. /**
  78840. * Gets the ray of the controller in the direction the controller is pointing
  78841. * @param length the length the resulting ray should be
  78842. * @returns a ray in the direction the controller is pointing
  78843. */
  78844. getForwardRay(length?: number): Ray;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Defines the WebVRController object that represents controllers tracked in 3D space
  78850. */
  78851. export abstract class WebVRController extends PoseEnabledController {
  78852. /**
  78853. * Internal, the default controller model for the controller
  78854. */
  78855. protected _defaultModel: AbstractMesh;
  78856. /**
  78857. * Fired when the trigger state has changed
  78858. */
  78859. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78860. /**
  78861. * Fired when the main button state has changed
  78862. */
  78863. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78864. /**
  78865. * Fired when the secondary button state has changed
  78866. */
  78867. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78868. /**
  78869. * Fired when the pad state has changed
  78870. */
  78871. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78872. /**
  78873. * Fired when controllers stick values have changed
  78874. */
  78875. onPadValuesChangedObservable: Observable<StickValues>;
  78876. /**
  78877. * Array of button availible on the controller
  78878. */
  78879. protected _buttons: Array<MutableGamepadButton>;
  78880. private _onButtonStateChange;
  78881. /**
  78882. * Fired when a controller button's state has changed
  78883. * @param callback the callback containing the button that was modified
  78884. */
  78885. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78886. /**
  78887. * X and Y axis corresponding to the controllers joystick
  78888. */
  78889. pad: StickValues;
  78890. /**
  78891. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78892. */
  78893. hand: string;
  78894. /**
  78895. * The default controller model for the controller
  78896. */
  78897. readonly defaultModel: AbstractMesh;
  78898. /**
  78899. * Creates a new WebVRController from a gamepad
  78900. * @param vrGamepad the gamepad that the WebVRController should be created from
  78901. */
  78902. constructor(vrGamepad: any);
  78903. /**
  78904. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78905. */
  78906. update(): void;
  78907. /**
  78908. * Function to be called when a button is modified
  78909. */
  78910. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78911. /**
  78912. * Loads a mesh and attaches it to the controller
  78913. * @param scene the scene the mesh should be added to
  78914. * @param meshLoaded callback for when the mesh has been loaded
  78915. */
  78916. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78917. private _setButtonValue;
  78918. private _changes;
  78919. private _checkChanges;
  78920. /**
  78921. * Disposes of th webVRCOntroller
  78922. */
  78923. dispose(): void;
  78924. }
  78925. }
  78926. declare module BABYLON {
  78927. /**
  78928. * The HemisphericLight simulates the ambient environment light,
  78929. * so the passed direction is the light reflection direction, not the incoming direction.
  78930. */
  78931. export class HemisphericLight extends Light {
  78932. /**
  78933. * The groundColor is the light in the opposite direction to the one specified during creation.
  78934. * 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.
  78935. */
  78936. groundColor: Color3;
  78937. /**
  78938. * The light reflection direction, not the incoming direction.
  78939. */
  78940. direction: Vector3;
  78941. /**
  78942. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78943. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78944. * The HemisphericLight can't cast shadows.
  78945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78946. * @param name The friendly name of the light
  78947. * @param direction The direction of the light reflection
  78948. * @param scene The scene the light belongs to
  78949. */
  78950. constructor(name: string, direction: Vector3, scene: Scene);
  78951. protected _buildUniformLayout(): void;
  78952. /**
  78953. * Returns the string "HemisphericLight".
  78954. * @return The class name
  78955. */
  78956. getClassName(): string;
  78957. /**
  78958. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78959. * Returns the updated direction.
  78960. * @param target The target the direction should point to
  78961. * @return The computed direction
  78962. */
  78963. setDirectionToTarget(target: Vector3): Vector3;
  78964. /**
  78965. * Returns the shadow generator associated to the light.
  78966. * @returns Always null for hemispheric lights because it does not support shadows.
  78967. */
  78968. getShadowGenerator(): Nullable<IShadowGenerator>;
  78969. /**
  78970. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78971. * @param effect The effect to update
  78972. * @param lightIndex The index of the light in the effect to update
  78973. * @returns The hemispheric light
  78974. */
  78975. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78976. /**
  78977. * Computes the world matrix of the node
  78978. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78979. * @param useWasUpdatedFlag defines a reserved property
  78980. * @returns the world matrix
  78981. */
  78982. computeWorldMatrix(): Matrix;
  78983. /**
  78984. * Returns the integer 3.
  78985. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78986. */
  78987. getTypeID(): number;
  78988. /**
  78989. * Prepares the list of defines specific to the light type.
  78990. * @param defines the list of defines
  78991. * @param lightIndex defines the index of the light for the effect
  78992. */
  78993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78994. }
  78995. }
  78996. declare module BABYLON {
  78997. /** @hidden */
  78998. export var vrMultiviewToSingleviewPixelShader: {
  78999. name: string;
  79000. shader: string;
  79001. };
  79002. }
  79003. declare module BABYLON {
  79004. /**
  79005. * Renders to multiple views with a single draw call
  79006. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79007. */
  79008. export class MultiviewRenderTarget extends RenderTargetTexture {
  79009. /**
  79010. * Creates a multiview render target
  79011. * @param scene scene used with the render target
  79012. * @param size the size of the render target (used for each view)
  79013. */
  79014. constructor(scene: Scene, size?: number | {
  79015. width: number;
  79016. height: number;
  79017. } | {
  79018. ratio: number;
  79019. });
  79020. /**
  79021. * @hidden
  79022. * @param faceIndex the face index, if its a cube texture
  79023. */
  79024. _bindFrameBuffer(faceIndex?: number): void;
  79025. /**
  79026. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79027. * @returns the view count
  79028. */
  79029. getViewCount(): number;
  79030. }
  79031. }
  79032. declare module BABYLON {
  79033. /**
  79034. * Reprasents a camera frustum
  79035. */
  79036. export class Frustum {
  79037. /**
  79038. * Gets the planes representing the frustum
  79039. * @param transform matrix to be applied to the returned planes
  79040. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79041. */
  79042. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79043. /**
  79044. * Gets the near frustum plane transformed by the transform matrix
  79045. * @param transform transformation matrix to be applied to the resulting frustum plane
  79046. * @param frustumPlane the resuling frustum plane
  79047. */
  79048. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79049. /**
  79050. * Gets the far frustum plane transformed by the transform matrix
  79051. * @param transform transformation matrix to be applied to the resulting frustum plane
  79052. * @param frustumPlane the resuling frustum plane
  79053. */
  79054. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79055. /**
  79056. * Gets the left frustum plane transformed by the transform matrix
  79057. * @param transform transformation matrix to be applied to the resulting frustum plane
  79058. * @param frustumPlane the resuling frustum plane
  79059. */
  79060. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79061. /**
  79062. * Gets the right frustum plane transformed by the transform matrix
  79063. * @param transform transformation matrix to be applied to the resulting frustum plane
  79064. * @param frustumPlane the resuling frustum plane
  79065. */
  79066. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79067. /**
  79068. * Gets the top frustum plane transformed by the transform matrix
  79069. * @param transform transformation matrix to be applied to the resulting frustum plane
  79070. * @param frustumPlane the resuling frustum plane
  79071. */
  79072. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79073. /**
  79074. * Gets the bottom frustum plane transformed by the transform matrix
  79075. * @param transform transformation matrix to be applied to the resulting frustum plane
  79076. * @param frustumPlane the resuling frustum plane
  79077. */
  79078. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79079. /**
  79080. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79081. * @param transform transformation matrix to be applied to the resulting frustum planes
  79082. * @param frustumPlanes the resuling frustum planes
  79083. */
  79084. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79085. }
  79086. }
  79087. declare module BABYLON {
  79088. interface Engine {
  79089. /**
  79090. * Creates a new multiview render target
  79091. * @param width defines the width of the texture
  79092. * @param height defines the height of the texture
  79093. * @returns the created multiview texture
  79094. */
  79095. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79096. /**
  79097. * Binds a multiview framebuffer to be drawn to
  79098. * @param multiviewTexture texture to bind
  79099. */
  79100. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79101. }
  79102. interface Camera {
  79103. /**
  79104. * @hidden
  79105. * 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)
  79106. */
  79107. _useMultiviewToSingleView: boolean;
  79108. /**
  79109. * @hidden
  79110. * 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)
  79111. */
  79112. _multiviewTexture: Nullable<RenderTargetTexture>;
  79113. /**
  79114. * @hidden
  79115. * ensures the multiview texture of the camera exists and has the specified width/height
  79116. * @param width height to set on the multiview texture
  79117. * @param height width to set on the multiview texture
  79118. */
  79119. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79120. }
  79121. interface Scene {
  79122. /** @hidden */
  79123. _transformMatrixR: Matrix;
  79124. /** @hidden */
  79125. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79126. /** @hidden */
  79127. _createMultiviewUbo(): void;
  79128. /** @hidden */
  79129. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79130. /** @hidden */
  79131. _renderMultiviewToSingleView(camera: Camera): void;
  79132. }
  79133. }
  79134. declare module BABYLON {
  79135. /**
  79136. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79137. * This will not be used for webXR as it supports displaying texture arrays directly
  79138. */
  79139. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79140. /**
  79141. * Initializes a VRMultiviewToSingleview
  79142. * @param name name of the post process
  79143. * @param camera camera to be applied to
  79144. * @param scaleFactor scaling factor to the size of the output texture
  79145. */
  79146. constructor(name: string, camera: Camera, scaleFactor: number);
  79147. }
  79148. }
  79149. declare module BABYLON {
  79150. interface Engine {
  79151. /** @hidden */
  79152. _vrDisplay: any;
  79153. /** @hidden */
  79154. _vrSupported: boolean;
  79155. /** @hidden */
  79156. _oldSize: Size;
  79157. /** @hidden */
  79158. _oldHardwareScaleFactor: number;
  79159. /** @hidden */
  79160. _vrExclusivePointerMode: boolean;
  79161. /** @hidden */
  79162. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79163. /** @hidden */
  79164. _onVRDisplayPointerRestricted: () => void;
  79165. /** @hidden */
  79166. _onVRDisplayPointerUnrestricted: () => void;
  79167. /** @hidden */
  79168. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79169. /** @hidden */
  79170. _onVrDisplayDisconnect: Nullable<() => void>;
  79171. /** @hidden */
  79172. _onVrDisplayPresentChange: Nullable<() => void>;
  79173. /**
  79174. * Observable signaled when VR display mode changes
  79175. */
  79176. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79177. /**
  79178. * Observable signaled when VR request present is complete
  79179. */
  79180. onVRRequestPresentComplete: Observable<boolean>;
  79181. /**
  79182. * Observable signaled when VR request present starts
  79183. */
  79184. onVRRequestPresentStart: Observable<Engine>;
  79185. /**
  79186. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79187. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79188. */
  79189. isInVRExclusivePointerMode: boolean;
  79190. /**
  79191. * Gets a boolean indicating if a webVR device was detected
  79192. * @returns true if a webVR device was detected
  79193. */
  79194. isVRDevicePresent(): boolean;
  79195. /**
  79196. * Gets the current webVR device
  79197. * @returns the current webVR device (or null)
  79198. */
  79199. getVRDevice(): any;
  79200. /**
  79201. * Initializes a webVR display and starts listening to display change events
  79202. * The onVRDisplayChangedObservable will be notified upon these changes
  79203. * @returns A promise containing a VRDisplay and if vr is supported
  79204. */
  79205. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79206. /** @hidden */
  79207. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79208. /**
  79209. * Call this function to switch to webVR mode
  79210. * Will do nothing if webVR is not supported or if there is no webVR device
  79211. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79212. */
  79213. enableVR(): void;
  79214. /** @hidden */
  79215. _onVRFullScreenTriggered(): void;
  79216. }
  79217. }
  79218. declare module BABYLON {
  79219. /**
  79220. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79221. * IMPORTANT!! The data is right-hand data.
  79222. * @export
  79223. * @interface DevicePose
  79224. */
  79225. export interface DevicePose {
  79226. /**
  79227. * The position of the device, values in array are [x,y,z].
  79228. */
  79229. readonly position: Nullable<Float32Array>;
  79230. /**
  79231. * The linearVelocity of the device, values in array are [x,y,z].
  79232. */
  79233. readonly linearVelocity: Nullable<Float32Array>;
  79234. /**
  79235. * The linearAcceleration of the device, values in array are [x,y,z].
  79236. */
  79237. readonly linearAcceleration: Nullable<Float32Array>;
  79238. /**
  79239. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79240. */
  79241. readonly orientation: Nullable<Float32Array>;
  79242. /**
  79243. * The angularVelocity of the device, values in array are [x,y,z].
  79244. */
  79245. readonly angularVelocity: Nullable<Float32Array>;
  79246. /**
  79247. * The angularAcceleration of the device, values in array are [x,y,z].
  79248. */
  79249. readonly angularAcceleration: Nullable<Float32Array>;
  79250. }
  79251. /**
  79252. * Interface representing a pose controlled object in Babylon.
  79253. * A pose controlled object has both regular pose values as well as pose values
  79254. * from an external device such as a VR head mounted display
  79255. */
  79256. export interface PoseControlled {
  79257. /**
  79258. * The position of the object in babylon space.
  79259. */
  79260. position: Vector3;
  79261. /**
  79262. * The rotation quaternion of the object in babylon space.
  79263. */
  79264. rotationQuaternion: Quaternion;
  79265. /**
  79266. * The position of the device in babylon space.
  79267. */
  79268. devicePosition?: Vector3;
  79269. /**
  79270. * The rotation quaternion of the device in babylon space.
  79271. */
  79272. deviceRotationQuaternion: Quaternion;
  79273. /**
  79274. * The raw pose coming from the device.
  79275. */
  79276. rawPose: Nullable<DevicePose>;
  79277. /**
  79278. * The scale of the device to be used when translating from device space to babylon space.
  79279. */
  79280. deviceScaleFactor: number;
  79281. /**
  79282. * Updates the poseControlled values based on the input device pose.
  79283. * @param poseData the pose data to update the object with
  79284. */
  79285. updateFromDevice(poseData: DevicePose): void;
  79286. }
  79287. /**
  79288. * Set of options to customize the webVRCamera
  79289. */
  79290. export interface WebVROptions {
  79291. /**
  79292. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79293. */
  79294. trackPosition?: boolean;
  79295. /**
  79296. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79297. */
  79298. positionScale?: number;
  79299. /**
  79300. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79301. */
  79302. displayName?: string;
  79303. /**
  79304. * Should the native controller meshes be initialized. (default: true)
  79305. */
  79306. controllerMeshes?: boolean;
  79307. /**
  79308. * Creating a default HemiLight only on controllers. (default: true)
  79309. */
  79310. defaultLightingOnControllers?: boolean;
  79311. /**
  79312. * If you don't want to use the default VR button of the helper. (default: false)
  79313. */
  79314. useCustomVRButton?: boolean;
  79315. /**
  79316. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79317. */
  79318. customVRButton?: HTMLButtonElement;
  79319. /**
  79320. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79321. */
  79322. rayLength?: number;
  79323. /**
  79324. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79325. */
  79326. defaultHeight?: number;
  79327. /**
  79328. * If multiview should be used if availible (default: false)
  79329. */
  79330. useMultiview?: boolean;
  79331. }
  79332. /**
  79333. * This represents a WebVR camera.
  79334. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79335. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79336. */
  79337. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79338. private webVROptions;
  79339. /**
  79340. * @hidden
  79341. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79342. */
  79343. _vrDevice: any;
  79344. /**
  79345. * The rawPose of the vrDevice.
  79346. */
  79347. rawPose: Nullable<DevicePose>;
  79348. private _onVREnabled;
  79349. private _specsVersion;
  79350. private _attached;
  79351. private _frameData;
  79352. protected _descendants: Array<Node>;
  79353. private _deviceRoomPosition;
  79354. /** @hidden */
  79355. _deviceRoomRotationQuaternion: Quaternion;
  79356. private _standingMatrix;
  79357. /**
  79358. * Represents device position in babylon space.
  79359. */
  79360. devicePosition: Vector3;
  79361. /**
  79362. * Represents device rotation in babylon space.
  79363. */
  79364. deviceRotationQuaternion: Quaternion;
  79365. /**
  79366. * The scale of the device to be used when translating from device space to babylon space.
  79367. */
  79368. deviceScaleFactor: number;
  79369. private _deviceToWorld;
  79370. private _worldToDevice;
  79371. /**
  79372. * References to the webVR controllers for the vrDevice.
  79373. */
  79374. controllers: Array<WebVRController>;
  79375. /**
  79376. * Emits an event when a controller is attached.
  79377. */
  79378. onControllersAttachedObservable: Observable<WebVRController[]>;
  79379. /**
  79380. * Emits an event when a controller's mesh has been loaded;
  79381. */
  79382. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79383. /**
  79384. * Emits an event when the HMD's pose has been updated.
  79385. */
  79386. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79387. private _poseSet;
  79388. /**
  79389. * If the rig cameras be used as parent instead of this camera.
  79390. */
  79391. rigParenting: boolean;
  79392. private _lightOnControllers;
  79393. private _defaultHeight?;
  79394. /**
  79395. * Instantiates a WebVRFreeCamera.
  79396. * @param name The name of the WebVRFreeCamera
  79397. * @param position The starting anchor position for the camera
  79398. * @param scene The scene the camera belongs to
  79399. * @param webVROptions a set of customizable options for the webVRCamera
  79400. */
  79401. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79402. /**
  79403. * Gets the device distance from the ground in meters.
  79404. * @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.
  79405. */
  79406. deviceDistanceToRoomGround(): number;
  79407. /**
  79408. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79409. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79410. */
  79411. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79412. /**
  79413. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79414. * @returns A promise with a boolean set to if the standing matrix is supported.
  79415. */
  79416. useStandingMatrixAsync(): Promise<boolean>;
  79417. /**
  79418. * Disposes the camera
  79419. */
  79420. dispose(): void;
  79421. /**
  79422. * Gets a vrController by name.
  79423. * @param name The name of the controller to retreive
  79424. * @returns the controller matching the name specified or null if not found
  79425. */
  79426. getControllerByName(name: string): Nullable<WebVRController>;
  79427. private _leftController;
  79428. /**
  79429. * The controller corresponding to the users left hand.
  79430. */
  79431. readonly leftController: Nullable<WebVRController>;
  79432. private _rightController;
  79433. /**
  79434. * The controller corresponding to the users right hand.
  79435. */
  79436. readonly rightController: Nullable<WebVRController>;
  79437. /**
  79438. * Casts a ray forward from the vrCamera's gaze.
  79439. * @param length Length of the ray (default: 100)
  79440. * @returns the ray corresponding to the gaze
  79441. */
  79442. getForwardRay(length?: number): Ray;
  79443. /**
  79444. * @hidden
  79445. * Updates the camera based on device's frame data
  79446. */
  79447. _checkInputs(): void;
  79448. /**
  79449. * Updates the poseControlled values based on the input device pose.
  79450. * @param poseData Pose coming from the device
  79451. */
  79452. updateFromDevice(poseData: DevicePose): void;
  79453. private _htmlElementAttached;
  79454. private _detachIfAttached;
  79455. /**
  79456. * WebVR's attach control will start broadcasting frames to the device.
  79457. * Note that in certain browsers (chrome for example) this function must be called
  79458. * within a user-interaction callback. Example:
  79459. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79460. *
  79461. * @param element html element to attach the vrDevice to
  79462. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79463. */
  79464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79465. /**
  79466. * Detaches the camera from the html element and disables VR
  79467. *
  79468. * @param element html element to detach from
  79469. */
  79470. detachControl(element: HTMLElement): void;
  79471. /**
  79472. * @returns the name of this class
  79473. */
  79474. getClassName(): string;
  79475. /**
  79476. * Calls resetPose on the vrDisplay
  79477. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79478. */
  79479. resetToCurrentRotation(): void;
  79480. /**
  79481. * @hidden
  79482. * Updates the rig cameras (left and right eye)
  79483. */
  79484. _updateRigCameras(): void;
  79485. private _workingVector;
  79486. private _oneVector;
  79487. private _workingMatrix;
  79488. private updateCacheCalled;
  79489. private _correctPositionIfNotTrackPosition;
  79490. /**
  79491. * @hidden
  79492. * Updates the cached values of the camera
  79493. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79494. */
  79495. _updateCache(ignoreParentClass?: boolean): void;
  79496. /**
  79497. * @hidden
  79498. * Get current device position in babylon world
  79499. */
  79500. _computeDevicePosition(): void;
  79501. /**
  79502. * Updates the current device position and rotation in the babylon world
  79503. */
  79504. update(): void;
  79505. /**
  79506. * @hidden
  79507. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79508. * @returns an identity matrix
  79509. */
  79510. _getViewMatrix(): Matrix;
  79511. private _tmpMatrix;
  79512. /**
  79513. * This function is called by the two RIG cameras.
  79514. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79515. * @hidden
  79516. */
  79517. _getWebVRViewMatrix(): Matrix;
  79518. /** @hidden */
  79519. _getWebVRProjectionMatrix(): Matrix;
  79520. private _onGamepadConnectedObserver;
  79521. private _onGamepadDisconnectedObserver;
  79522. private _updateCacheWhenTrackingDisabledObserver;
  79523. /**
  79524. * Initializes the controllers and their meshes
  79525. */
  79526. initControllers(): void;
  79527. }
  79528. }
  79529. declare module BABYLON {
  79530. /**
  79531. * Size options for a post process
  79532. */
  79533. export type PostProcessOptions = {
  79534. width: number;
  79535. height: number;
  79536. };
  79537. /**
  79538. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79539. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79540. */
  79541. export class PostProcess {
  79542. /** Name of the PostProcess. */
  79543. name: string;
  79544. /**
  79545. * Gets or sets the unique id of the post process
  79546. */
  79547. uniqueId: number;
  79548. /**
  79549. * Width of the texture to apply the post process on
  79550. */
  79551. width: number;
  79552. /**
  79553. * Height of the texture to apply the post process on
  79554. */
  79555. height: number;
  79556. /**
  79557. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79558. * @hidden
  79559. */
  79560. _outputTexture: Nullable<InternalTexture>;
  79561. /**
  79562. * Sampling mode used by the shader
  79563. * See https://doc.babylonjs.com/classes/3.1/texture
  79564. */
  79565. renderTargetSamplingMode: number;
  79566. /**
  79567. * Clear color to use when screen clearing
  79568. */
  79569. clearColor: Color4;
  79570. /**
  79571. * If the buffer needs to be cleared before applying the post process. (default: true)
  79572. * Should be set to false if shader will overwrite all previous pixels.
  79573. */
  79574. autoClear: boolean;
  79575. /**
  79576. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79577. */
  79578. alphaMode: number;
  79579. /**
  79580. * Sets the setAlphaBlendConstants of the babylon engine
  79581. */
  79582. alphaConstants: Color4;
  79583. /**
  79584. * Animations to be used for the post processing
  79585. */
  79586. animations: Animation[];
  79587. /**
  79588. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79589. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79590. */
  79591. enablePixelPerfectMode: boolean;
  79592. /**
  79593. * Force the postprocess to be applied without taking in account viewport
  79594. */
  79595. forceFullscreenViewport: boolean;
  79596. /**
  79597. * List of inspectable custom properties (used by the Inspector)
  79598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79599. */
  79600. inspectableCustomProperties: IInspectable[];
  79601. /**
  79602. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79603. *
  79604. * | Value | Type | Description |
  79605. * | ----- | ----------------------------------- | ----------- |
  79606. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79607. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79608. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79609. *
  79610. */
  79611. scaleMode: number;
  79612. /**
  79613. * Force textures to be a power of two (default: false)
  79614. */
  79615. alwaysForcePOT: boolean;
  79616. private _samples;
  79617. /**
  79618. * Number of sample textures (default: 1)
  79619. */
  79620. samples: number;
  79621. /**
  79622. * Modify the scale of the post process to be the same as the viewport (default: false)
  79623. */
  79624. adaptScaleToCurrentViewport: boolean;
  79625. private _camera;
  79626. private _scene;
  79627. private _engine;
  79628. private _options;
  79629. private _reusable;
  79630. private _textureType;
  79631. /**
  79632. * Smart array of input and output textures for the post process.
  79633. * @hidden
  79634. */
  79635. _textures: SmartArray<InternalTexture>;
  79636. /**
  79637. * The index in _textures that corresponds to the output texture.
  79638. * @hidden
  79639. */
  79640. _currentRenderTextureInd: number;
  79641. private _effect;
  79642. private _samplers;
  79643. private _fragmentUrl;
  79644. private _vertexUrl;
  79645. private _parameters;
  79646. private _scaleRatio;
  79647. protected _indexParameters: any;
  79648. private _shareOutputWithPostProcess;
  79649. private _texelSize;
  79650. private _forcedOutputTexture;
  79651. /**
  79652. * Returns the fragment url or shader name used in the post process.
  79653. * @returns the fragment url or name in the shader store.
  79654. */
  79655. getEffectName(): string;
  79656. /**
  79657. * An event triggered when the postprocess is activated.
  79658. */
  79659. onActivateObservable: Observable<Camera>;
  79660. private _onActivateObserver;
  79661. /**
  79662. * A function that is added to the onActivateObservable
  79663. */
  79664. onActivate: Nullable<(camera: Camera) => void>;
  79665. /**
  79666. * An event triggered when the postprocess changes its size.
  79667. */
  79668. onSizeChangedObservable: Observable<PostProcess>;
  79669. private _onSizeChangedObserver;
  79670. /**
  79671. * A function that is added to the onSizeChangedObservable
  79672. */
  79673. onSizeChanged: (postProcess: PostProcess) => void;
  79674. /**
  79675. * An event triggered when the postprocess applies its effect.
  79676. */
  79677. onApplyObservable: Observable<Effect>;
  79678. private _onApplyObserver;
  79679. /**
  79680. * A function that is added to the onApplyObservable
  79681. */
  79682. onApply: (effect: Effect) => void;
  79683. /**
  79684. * An event triggered before rendering the postprocess
  79685. */
  79686. onBeforeRenderObservable: Observable<Effect>;
  79687. private _onBeforeRenderObserver;
  79688. /**
  79689. * A function that is added to the onBeforeRenderObservable
  79690. */
  79691. onBeforeRender: (effect: Effect) => void;
  79692. /**
  79693. * An event triggered after rendering the postprocess
  79694. */
  79695. onAfterRenderObservable: Observable<Effect>;
  79696. private _onAfterRenderObserver;
  79697. /**
  79698. * A function that is added to the onAfterRenderObservable
  79699. */
  79700. onAfterRender: (efect: Effect) => void;
  79701. /**
  79702. * 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
  79703. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79704. */
  79705. inputTexture: InternalTexture;
  79706. /**
  79707. * Gets the camera which post process is applied to.
  79708. * @returns The camera the post process is applied to.
  79709. */
  79710. getCamera(): Camera;
  79711. /**
  79712. * Gets the texel size of the postprocess.
  79713. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79714. */
  79715. readonly texelSize: Vector2;
  79716. /**
  79717. * Creates a new instance PostProcess
  79718. * @param name The name of the PostProcess.
  79719. * @param fragmentUrl The url of the fragment shader to be used.
  79720. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79721. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79722. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79723. * @param camera The camera to apply the render pass to.
  79724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79725. * @param engine The engine which the post process will be applied. (default: current engine)
  79726. * @param reusable If the post process can be reused on the same frame. (default: false)
  79727. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79728. * @param textureType Type of textures used when performing the post process. (default: 0)
  79729. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79730. * @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
  79731. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79732. */
  79733. constructor(
  79734. /** Name of the PostProcess. */
  79735. 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);
  79736. /**
  79737. * Gets a string idenfifying the name of the class
  79738. * @returns "PostProcess" string
  79739. */
  79740. getClassName(): string;
  79741. /**
  79742. * Gets the engine which this post process belongs to.
  79743. * @returns The engine the post process was enabled with.
  79744. */
  79745. getEngine(): Engine;
  79746. /**
  79747. * The effect that is created when initializing the post process.
  79748. * @returns The created effect corresponding the the postprocess.
  79749. */
  79750. getEffect(): Effect;
  79751. /**
  79752. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79753. * @param postProcess The post process to share the output with.
  79754. * @returns This post process.
  79755. */
  79756. shareOutputWith(postProcess: PostProcess): PostProcess;
  79757. /**
  79758. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79759. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79760. */
  79761. useOwnOutput(): void;
  79762. /**
  79763. * Updates the effect with the current post process compile time values and recompiles the shader.
  79764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79767. * @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
  79768. * @param onCompiled Called when the shader has been compiled.
  79769. * @param onError Called if there is an error when compiling a shader.
  79770. */
  79771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79772. /**
  79773. * The post process is reusable if it can be used multiple times within one frame.
  79774. * @returns If the post process is reusable
  79775. */
  79776. isReusable(): boolean;
  79777. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79778. markTextureDirty(): void;
  79779. /**
  79780. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79781. * 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.
  79782. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79783. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79784. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79785. * @returns The target texture that was bound to be written to.
  79786. */
  79787. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79788. /**
  79789. * If the post process is supported.
  79790. */
  79791. readonly isSupported: boolean;
  79792. /**
  79793. * The aspect ratio of the output texture.
  79794. */
  79795. readonly aspectRatio: number;
  79796. /**
  79797. * Get a value indicating if the post-process is ready to be used
  79798. * @returns true if the post-process is ready (shader is compiled)
  79799. */
  79800. isReady(): boolean;
  79801. /**
  79802. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79803. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79804. */
  79805. apply(): Nullable<Effect>;
  79806. private _disposeTextures;
  79807. /**
  79808. * Disposes the post process.
  79809. * @param camera The camera to dispose the post process on.
  79810. */
  79811. dispose(camera?: Camera): void;
  79812. }
  79813. }
  79814. declare module BABYLON {
  79815. /** @hidden */
  79816. export var kernelBlurVaryingDeclaration: {
  79817. name: string;
  79818. shader: string;
  79819. };
  79820. }
  79821. declare module BABYLON {
  79822. /** @hidden */
  79823. export var kernelBlurFragment: {
  79824. name: string;
  79825. shader: string;
  79826. };
  79827. }
  79828. declare module BABYLON {
  79829. /** @hidden */
  79830. export var kernelBlurFragment2: {
  79831. name: string;
  79832. shader: string;
  79833. };
  79834. }
  79835. declare module BABYLON {
  79836. /** @hidden */
  79837. export var kernelBlurPixelShader: {
  79838. name: string;
  79839. shader: string;
  79840. };
  79841. }
  79842. declare module BABYLON {
  79843. /** @hidden */
  79844. export var kernelBlurVertex: {
  79845. name: string;
  79846. shader: string;
  79847. };
  79848. }
  79849. declare module BABYLON {
  79850. /** @hidden */
  79851. export var kernelBlurVertexShader: {
  79852. name: string;
  79853. shader: string;
  79854. };
  79855. }
  79856. declare module BABYLON {
  79857. /**
  79858. * The Blur Post Process which blurs an image based on a kernel and direction.
  79859. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79860. */
  79861. export class BlurPostProcess extends PostProcess {
  79862. /** The direction in which to blur the image. */
  79863. direction: Vector2;
  79864. private blockCompilation;
  79865. protected _kernel: number;
  79866. protected _idealKernel: number;
  79867. protected _packedFloat: boolean;
  79868. private _staticDefines;
  79869. /**
  79870. * Sets the length in pixels of the blur sample region
  79871. */
  79872. /**
  79873. * Gets the length in pixels of the blur sample region
  79874. */
  79875. kernel: number;
  79876. /**
  79877. * Sets wether or not the blur needs to unpack/repack floats
  79878. */
  79879. /**
  79880. * Gets wether or not the blur is unpacking/repacking floats
  79881. */
  79882. packedFloat: boolean;
  79883. /**
  79884. * Creates a new instance BlurPostProcess
  79885. * @param name The name of the effect.
  79886. * @param direction The direction in which to blur the image.
  79887. * @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.
  79888. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79889. * @param camera The camera to apply the render pass to.
  79890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79891. * @param engine The engine which the post process will be applied. (default: current engine)
  79892. * @param reusable If the post process can be reused on the same frame. (default: false)
  79893. * @param textureType Type of textures used when performing the post process. (default: 0)
  79894. * @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)
  79895. */
  79896. constructor(name: string,
  79897. /** The direction in which to blur the image. */
  79898. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79899. /**
  79900. * Updates the effect with the current post process compile time values and recompiles the shader.
  79901. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79902. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79903. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79904. * @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
  79905. * @param onCompiled Called when the shader has been compiled.
  79906. * @param onError Called if there is an error when compiling a shader.
  79907. */
  79908. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79909. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79910. /**
  79911. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79912. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79913. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79914. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79915. * The gaps between physical kernels are compensated for in the weighting of the samples
  79916. * @param idealKernel Ideal blur kernel.
  79917. * @return Nearest best kernel.
  79918. */
  79919. protected _nearestBestKernel(idealKernel: number): number;
  79920. /**
  79921. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79922. * @param x The point on the Gaussian distribution to sample.
  79923. * @return the value of the Gaussian function at x.
  79924. */
  79925. protected _gaussianWeight(x: number): number;
  79926. /**
  79927. * Generates a string that can be used as a floating point number in GLSL.
  79928. * @param x Value to print.
  79929. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79930. * @return GLSL float string.
  79931. */
  79932. protected _glslFloat(x: number, decimalFigures?: number): string;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /**
  79937. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79938. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79939. * You can then easily use it as a reflectionTexture on a flat surface.
  79940. * In case the surface is not a plane, please consider relying on reflection probes.
  79941. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79942. */
  79943. export class MirrorTexture extends RenderTargetTexture {
  79944. private scene;
  79945. /**
  79946. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79947. * 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.
  79948. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79949. */
  79950. mirrorPlane: Plane;
  79951. /**
  79952. * Define the blur ratio used to blur the reflection if needed.
  79953. */
  79954. blurRatio: number;
  79955. /**
  79956. * Define the adaptive blur kernel used to blur the reflection if needed.
  79957. * This will autocompute the closest best match for the `blurKernel`
  79958. */
  79959. adaptiveBlurKernel: number;
  79960. /**
  79961. * Define the blur kernel used to blur the reflection if needed.
  79962. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79963. */
  79964. blurKernel: number;
  79965. /**
  79966. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79968. */
  79969. blurKernelX: number;
  79970. /**
  79971. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79972. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79973. */
  79974. blurKernelY: number;
  79975. private _autoComputeBlurKernel;
  79976. protected _onRatioRescale(): void;
  79977. private _updateGammaSpace;
  79978. private _imageProcessingConfigChangeObserver;
  79979. private _transformMatrix;
  79980. private _mirrorMatrix;
  79981. private _savedViewMatrix;
  79982. private _blurX;
  79983. private _blurY;
  79984. private _adaptiveBlurKernel;
  79985. private _blurKernelX;
  79986. private _blurKernelY;
  79987. private _blurRatio;
  79988. /**
  79989. * Instantiates a Mirror Texture.
  79990. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79991. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79992. * You can then easily use it as a reflectionTexture on a flat surface.
  79993. * In case the surface is not a plane, please consider relying on reflection probes.
  79994. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79995. * @param name
  79996. * @param size
  79997. * @param scene
  79998. * @param generateMipMaps
  79999. * @param type
  80000. * @param samplingMode
  80001. * @param generateDepthBuffer
  80002. */
  80003. constructor(name: string, size: number | {
  80004. width: number;
  80005. height: number;
  80006. } | {
  80007. ratio: number;
  80008. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80009. private _preparePostProcesses;
  80010. /**
  80011. * Clone the mirror texture.
  80012. * @returns the cloned texture
  80013. */
  80014. clone(): MirrorTexture;
  80015. /**
  80016. * Serialize the texture to a JSON representation you could use in Parse later on
  80017. * @returns the serialized JSON representation
  80018. */
  80019. serialize(): any;
  80020. /**
  80021. * Dispose the texture and release its associated resources.
  80022. */
  80023. dispose(): void;
  80024. }
  80025. }
  80026. declare module BABYLON {
  80027. /**
  80028. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80029. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80030. */
  80031. export class Texture extends BaseTexture {
  80032. /** @hidden */
  80033. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80034. /** @hidden */
  80035. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80036. /** @hidden */
  80037. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80038. /** nearest is mag = nearest and min = nearest and mip = linear */
  80039. static readonly NEAREST_SAMPLINGMODE: number;
  80040. /** nearest is mag = nearest and min = nearest and mip = linear */
  80041. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80043. static readonly BILINEAR_SAMPLINGMODE: number;
  80044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80045. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80046. /** Trilinear is mag = linear and min = linear and mip = linear */
  80047. static readonly TRILINEAR_SAMPLINGMODE: number;
  80048. /** Trilinear is mag = linear and min = linear and mip = linear */
  80049. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80050. /** mag = nearest and min = nearest and mip = nearest */
  80051. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80052. /** mag = nearest and min = linear and mip = nearest */
  80053. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80054. /** mag = nearest and min = linear and mip = linear */
  80055. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80056. /** mag = nearest and min = linear and mip = none */
  80057. static readonly NEAREST_LINEAR: number;
  80058. /** mag = nearest and min = nearest and mip = none */
  80059. static readonly NEAREST_NEAREST: number;
  80060. /** mag = linear and min = nearest and mip = nearest */
  80061. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80062. /** mag = linear and min = nearest and mip = linear */
  80063. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80064. /** mag = linear and min = linear and mip = none */
  80065. static readonly LINEAR_LINEAR: number;
  80066. /** mag = linear and min = nearest and mip = none */
  80067. static readonly LINEAR_NEAREST: number;
  80068. /** Explicit coordinates mode */
  80069. static readonly EXPLICIT_MODE: number;
  80070. /** Spherical coordinates mode */
  80071. static readonly SPHERICAL_MODE: number;
  80072. /** Planar coordinates mode */
  80073. static readonly PLANAR_MODE: number;
  80074. /** Cubic coordinates mode */
  80075. static readonly CUBIC_MODE: number;
  80076. /** Projection coordinates mode */
  80077. static readonly PROJECTION_MODE: number;
  80078. /** Inverse Cubic coordinates mode */
  80079. static readonly SKYBOX_MODE: number;
  80080. /** Inverse Cubic coordinates mode */
  80081. static readonly INVCUBIC_MODE: number;
  80082. /** Equirectangular coordinates mode */
  80083. static readonly EQUIRECTANGULAR_MODE: number;
  80084. /** Equirectangular Fixed coordinates mode */
  80085. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80086. /** Equirectangular Fixed Mirrored coordinates mode */
  80087. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80088. /** Texture is not repeating outside of 0..1 UVs */
  80089. static readonly CLAMP_ADDRESSMODE: number;
  80090. /** Texture is repeating outside of 0..1 UVs */
  80091. static readonly WRAP_ADDRESSMODE: number;
  80092. /** Texture is repeating and mirrored */
  80093. static readonly MIRROR_ADDRESSMODE: number;
  80094. /**
  80095. * 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
  80096. */
  80097. static UseSerializedUrlIfAny: boolean;
  80098. /**
  80099. * Define the url of the texture.
  80100. */
  80101. url: Nullable<string>;
  80102. /**
  80103. * Define an offset on the texture to offset the u coordinates of the UVs
  80104. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80105. */
  80106. uOffset: number;
  80107. /**
  80108. * Define an offset on the texture to offset the v coordinates of the UVs
  80109. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80110. */
  80111. vOffset: number;
  80112. /**
  80113. * Define an offset on the texture to scale the u coordinates of the UVs
  80114. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80115. */
  80116. uScale: number;
  80117. /**
  80118. * Define an offset on the texture to scale the v coordinates of the UVs
  80119. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80120. */
  80121. vScale: number;
  80122. /**
  80123. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80124. * @see http://doc.babylonjs.com/how_to/more_materials
  80125. */
  80126. uAng: number;
  80127. /**
  80128. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80129. * @see http://doc.babylonjs.com/how_to/more_materials
  80130. */
  80131. vAng: number;
  80132. /**
  80133. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80134. * @see http://doc.babylonjs.com/how_to/more_materials
  80135. */
  80136. wAng: number;
  80137. /**
  80138. * Defines the center of rotation (U)
  80139. */
  80140. uRotationCenter: number;
  80141. /**
  80142. * Defines the center of rotation (V)
  80143. */
  80144. vRotationCenter: number;
  80145. /**
  80146. * Defines the center of rotation (W)
  80147. */
  80148. wRotationCenter: number;
  80149. /**
  80150. * Are mip maps generated for this texture or not.
  80151. */
  80152. readonly noMipmap: boolean;
  80153. /**
  80154. * List of inspectable custom properties (used by the Inspector)
  80155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80156. */
  80157. inspectableCustomProperties: Nullable<IInspectable[]>;
  80158. private _noMipmap;
  80159. /** @hidden */
  80160. _invertY: boolean;
  80161. private _rowGenerationMatrix;
  80162. private _cachedTextureMatrix;
  80163. private _projectionModeMatrix;
  80164. private _t0;
  80165. private _t1;
  80166. private _t2;
  80167. private _cachedUOffset;
  80168. private _cachedVOffset;
  80169. private _cachedUScale;
  80170. private _cachedVScale;
  80171. private _cachedUAng;
  80172. private _cachedVAng;
  80173. private _cachedWAng;
  80174. private _cachedProjectionMatrixId;
  80175. private _cachedCoordinatesMode;
  80176. /** @hidden */
  80177. protected _initialSamplingMode: number;
  80178. /** @hidden */
  80179. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80180. private _deleteBuffer;
  80181. protected _format: Nullable<number>;
  80182. private _delayedOnLoad;
  80183. private _delayedOnError;
  80184. /**
  80185. * Observable triggered once the texture has been loaded.
  80186. */
  80187. onLoadObservable: Observable<Texture>;
  80188. protected _isBlocking: boolean;
  80189. /**
  80190. * Is the texture preventing material to render while loading.
  80191. * If false, a default texture will be used instead of the loading one during the preparation step.
  80192. */
  80193. isBlocking: boolean;
  80194. /**
  80195. * Get the current sampling mode associated with the texture.
  80196. */
  80197. readonly samplingMode: number;
  80198. /**
  80199. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80200. */
  80201. readonly invertY: boolean;
  80202. /**
  80203. * Instantiates a new texture.
  80204. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80205. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80206. * @param url define the url of the picture to load as a texture
  80207. * @param scene define the scene or engine the texture will belong to
  80208. * @param noMipmap define if the texture will require mip maps or not
  80209. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80210. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80211. * @param onLoad define a callback triggered when the texture has been loaded
  80212. * @param onError define a callback triggered when an error occurred during the loading session
  80213. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80214. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80215. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80216. */
  80217. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80218. /**
  80219. * Update the url (and optional buffer) of this texture if url was null during construction.
  80220. * @param url the url of the texture
  80221. * @param buffer the buffer of the texture (defaults to null)
  80222. * @param onLoad callback called when the texture is loaded (defaults to null)
  80223. */
  80224. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80225. /**
  80226. * Finish the loading sequence of a texture flagged as delayed load.
  80227. * @hidden
  80228. */
  80229. delayLoad(): void;
  80230. private _prepareRowForTextureGeneration;
  80231. /**
  80232. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80233. * @returns the transform matrix of the texture.
  80234. */
  80235. getTextureMatrix(): Matrix;
  80236. /**
  80237. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80238. * @returns The reflection texture transform
  80239. */
  80240. getReflectionTextureMatrix(): Matrix;
  80241. /**
  80242. * Clones the texture.
  80243. * @returns the cloned texture
  80244. */
  80245. clone(): Texture;
  80246. /**
  80247. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80248. * @returns The JSON representation of the texture
  80249. */
  80250. serialize(): any;
  80251. /**
  80252. * Get the current class name of the texture useful for serialization or dynamic coding.
  80253. * @returns "Texture"
  80254. */
  80255. getClassName(): string;
  80256. /**
  80257. * Dispose the texture and release its associated resources.
  80258. */
  80259. dispose(): void;
  80260. /**
  80261. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80262. * @param parsedTexture Define the JSON representation of the texture
  80263. * @param scene Define the scene the parsed texture should be instantiated in
  80264. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80265. * @returns The parsed texture if successful
  80266. */
  80267. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80268. /**
  80269. * Creates a texture from its base 64 representation.
  80270. * @param data Define the base64 payload without the data: prefix
  80271. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80272. * @param scene Define the scene the texture should belong to
  80273. * @param noMipmap Forces the texture to not create mip map information if true
  80274. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80275. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80276. * @param onLoad define a callback triggered when the texture has been loaded
  80277. * @param onError define a callback triggered when an error occurred during the loading session
  80278. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80279. * @returns the created texture
  80280. */
  80281. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80282. /**
  80283. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80284. * @param data Define the base64 payload without the data: prefix
  80285. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80286. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80287. * @param scene Define the scene the texture should belong to
  80288. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80289. * @param noMipmap Forces the texture to not create mip map information if true
  80290. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80291. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80292. * @param onLoad define a callback triggered when the texture has been loaded
  80293. * @param onError define a callback triggered when an error occurred during the loading session
  80294. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80295. * @returns the created texture
  80296. */
  80297. 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;
  80298. }
  80299. }
  80300. declare module BABYLON {
  80301. /**
  80302. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80303. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80304. */
  80305. export class PostProcessManager {
  80306. private _scene;
  80307. private _indexBuffer;
  80308. private _vertexBuffers;
  80309. /**
  80310. * Creates a new instance PostProcess
  80311. * @param scene The scene that the post process is associated with.
  80312. */
  80313. constructor(scene: Scene);
  80314. private _prepareBuffers;
  80315. private _buildIndexBuffer;
  80316. /**
  80317. * Rebuilds the vertex buffers of the manager.
  80318. * @hidden
  80319. */
  80320. _rebuild(): void;
  80321. /**
  80322. * Prepares a frame to be run through a post process.
  80323. * @param sourceTexture The input texture to the post procesess. (default: null)
  80324. * @param postProcesses An array of post processes to be run. (default: null)
  80325. * @returns True if the post processes were able to be run.
  80326. * @hidden
  80327. */
  80328. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80329. /**
  80330. * Manually render a set of post processes to a texture.
  80331. * @param postProcesses An array of post processes to be run.
  80332. * @param targetTexture The target texture to render to.
  80333. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80334. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80335. * @param lodLevel defines which lod of the texture to render to
  80336. */
  80337. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80338. /**
  80339. * Finalize the result of the output of the postprocesses.
  80340. * @param doNotPresent If true the result will not be displayed to the screen.
  80341. * @param targetTexture The target texture to render to.
  80342. * @param faceIndex The index of the face to bind the target texture to.
  80343. * @param postProcesses The array of post processes to render.
  80344. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80345. * @hidden
  80346. */
  80347. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80348. /**
  80349. * Disposes of the post process manager.
  80350. */
  80351. dispose(): void;
  80352. }
  80353. }
  80354. declare module BABYLON {
  80355. /** Interface used by value gradients (color, factor, ...) */
  80356. export interface IValueGradient {
  80357. /**
  80358. * Gets or sets the gradient value (between 0 and 1)
  80359. */
  80360. gradient: number;
  80361. }
  80362. /** Class used to store color4 gradient */
  80363. export class ColorGradient implements IValueGradient {
  80364. /**
  80365. * Gets or sets the gradient value (between 0 and 1)
  80366. */
  80367. gradient: number;
  80368. /**
  80369. * Gets or sets first associated color
  80370. */
  80371. color1: Color4;
  80372. /**
  80373. * Gets or sets second associated color
  80374. */
  80375. color2?: Color4;
  80376. /**
  80377. * Will get a color picked randomly between color1 and color2.
  80378. * If color2 is undefined then color1 will be used
  80379. * @param result defines the target Color4 to store the result in
  80380. */
  80381. getColorToRef(result: Color4): void;
  80382. }
  80383. /** Class used to store color 3 gradient */
  80384. export class Color3Gradient implements IValueGradient {
  80385. /**
  80386. * Gets or sets the gradient value (between 0 and 1)
  80387. */
  80388. gradient: number;
  80389. /**
  80390. * Gets or sets the associated color
  80391. */
  80392. color: Color3;
  80393. }
  80394. /** Class used to store factor gradient */
  80395. export class FactorGradient implements IValueGradient {
  80396. /**
  80397. * Gets or sets the gradient value (between 0 and 1)
  80398. */
  80399. gradient: number;
  80400. /**
  80401. * Gets or sets first associated factor
  80402. */
  80403. factor1: number;
  80404. /**
  80405. * Gets or sets second associated factor
  80406. */
  80407. factor2?: number;
  80408. /**
  80409. * Will get a number picked randomly between factor1 and factor2.
  80410. * If factor2 is undefined then factor1 will be used
  80411. * @returns the picked number
  80412. */
  80413. getFactor(): number;
  80414. }
  80415. /**
  80416. * Helper used to simplify some generic gradient tasks
  80417. */
  80418. export class GradientHelper {
  80419. /**
  80420. * Gets the current gradient from an array of IValueGradient
  80421. * @param ratio defines the current ratio to get
  80422. * @param gradients defines the array of IValueGradient
  80423. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80424. */
  80425. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80426. }
  80427. }
  80428. declare module BABYLON {
  80429. interface AbstractScene {
  80430. /**
  80431. * The list of procedural textures added to the scene
  80432. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80433. */
  80434. proceduralTextures: Array<ProceduralTexture>;
  80435. }
  80436. /**
  80437. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80438. * in a given scene.
  80439. */
  80440. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80441. /**
  80442. * The component name helpfull to identify the component in the list of scene components.
  80443. */
  80444. readonly name: string;
  80445. /**
  80446. * The scene the component belongs to.
  80447. */
  80448. scene: Scene;
  80449. /**
  80450. * Creates a new instance of the component for the given scene
  80451. * @param scene Defines the scene to register the component in
  80452. */
  80453. constructor(scene: Scene);
  80454. /**
  80455. * Registers the component in a given scene
  80456. */
  80457. register(): void;
  80458. /**
  80459. * Rebuilds the elements related to this component in case of
  80460. * context lost for instance.
  80461. */
  80462. rebuild(): void;
  80463. /**
  80464. * Disposes the component and the associated ressources.
  80465. */
  80466. dispose(): void;
  80467. private _beforeClear;
  80468. }
  80469. }
  80470. declare module BABYLON {
  80471. interface Engine {
  80472. /**
  80473. * Creates a new render target cube texture
  80474. * @param size defines the size of the texture
  80475. * @param options defines the options used to create the texture
  80476. * @returns a new render target cube texture stored in an InternalTexture
  80477. */
  80478. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80479. }
  80480. }
  80481. declare module BABYLON {
  80482. /** @hidden */
  80483. export var proceduralVertexShader: {
  80484. name: string;
  80485. shader: string;
  80486. };
  80487. }
  80488. declare module BABYLON {
  80489. /**
  80490. * 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.
  80491. * This is the base class of any Procedural texture and contains most of the shareable code.
  80492. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80493. */
  80494. export class ProceduralTexture extends Texture {
  80495. isCube: boolean;
  80496. /**
  80497. * Define if the texture is enabled or not (disabled texture will not render)
  80498. */
  80499. isEnabled: boolean;
  80500. /**
  80501. * Define if the texture must be cleared before rendering (default is true)
  80502. */
  80503. autoClear: boolean;
  80504. /**
  80505. * Callback called when the texture is generated
  80506. */
  80507. onGenerated: () => void;
  80508. /**
  80509. * Event raised when the texture is generated
  80510. */
  80511. onGeneratedObservable: Observable<ProceduralTexture>;
  80512. /** @hidden */
  80513. _generateMipMaps: boolean;
  80514. /** @hidden **/
  80515. _effect: Effect;
  80516. /** @hidden */
  80517. _textures: {
  80518. [key: string]: Texture;
  80519. };
  80520. private _size;
  80521. private _currentRefreshId;
  80522. private _refreshRate;
  80523. private _vertexBuffers;
  80524. private _indexBuffer;
  80525. private _uniforms;
  80526. private _samplers;
  80527. private _fragment;
  80528. private _floats;
  80529. private _ints;
  80530. private _floatsArrays;
  80531. private _colors3;
  80532. private _colors4;
  80533. private _vectors2;
  80534. private _vectors3;
  80535. private _matrices;
  80536. private _fallbackTexture;
  80537. private _fallbackTextureUsed;
  80538. private _engine;
  80539. private _cachedDefines;
  80540. private _contentUpdateId;
  80541. private _contentData;
  80542. /**
  80543. * Instantiates a new procedural texture.
  80544. * 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.
  80545. * This is the base class of any Procedural texture and contains most of the shareable code.
  80546. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80547. * @param name Define the name of the texture
  80548. * @param size Define the size of the texture to create
  80549. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80550. * @param scene Define the scene the texture belongs to
  80551. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80552. * @param generateMipMaps Define if the texture should creates mip maps or not
  80553. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80554. */
  80555. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80556. /**
  80557. * The effect that is created when initializing the post process.
  80558. * @returns The created effect corresponding the the postprocess.
  80559. */
  80560. getEffect(): Effect;
  80561. /**
  80562. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80563. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80564. */
  80565. getContent(): Nullable<ArrayBufferView>;
  80566. private _createIndexBuffer;
  80567. /** @hidden */
  80568. _rebuild(): void;
  80569. /**
  80570. * Resets the texture in order to recreate its associated resources.
  80571. * This can be called in case of context loss
  80572. */
  80573. reset(): void;
  80574. protected _getDefines(): string;
  80575. /**
  80576. * Is the texture ready to be used ? (rendered at least once)
  80577. * @returns true if ready, otherwise, false.
  80578. */
  80579. isReady(): boolean;
  80580. /**
  80581. * Resets the refresh counter of the texture and start bak from scratch.
  80582. * Could be useful to regenerate the texture if it is setup to render only once.
  80583. */
  80584. resetRefreshCounter(): void;
  80585. /**
  80586. * Set the fragment shader to use in order to render the texture.
  80587. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80588. */
  80589. setFragment(fragment: any): void;
  80590. /**
  80591. * Define the refresh rate of the texture or the rendering frequency.
  80592. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80593. */
  80594. refreshRate: number;
  80595. /** @hidden */
  80596. _shouldRender(): boolean;
  80597. /**
  80598. * Get the size the texture is rendering at.
  80599. * @returns the size (texture is always squared)
  80600. */
  80601. getRenderSize(): number;
  80602. /**
  80603. * Resize the texture to new value.
  80604. * @param size Define the new size the texture should have
  80605. * @param generateMipMaps Define whether the new texture should create mip maps
  80606. */
  80607. resize(size: number, generateMipMaps: boolean): void;
  80608. private _checkUniform;
  80609. /**
  80610. * Set a texture in the shader program used to render.
  80611. * @param name Define the name of the uniform samplers as defined in the shader
  80612. * @param texture Define the texture to bind to this sampler
  80613. * @return the texture itself allowing "fluent" like uniform updates
  80614. */
  80615. setTexture(name: string, texture: Texture): ProceduralTexture;
  80616. /**
  80617. * Set a float in the shader.
  80618. * @param name Define the name of the uniform as defined in the shader
  80619. * @param value Define the value to give to the uniform
  80620. * @return the texture itself allowing "fluent" like uniform updates
  80621. */
  80622. setFloat(name: string, value: number): ProceduralTexture;
  80623. /**
  80624. * Set a int in the shader.
  80625. * @param name Define the name of the uniform as defined in the shader
  80626. * @param value Define the value to give to the uniform
  80627. * @return the texture itself allowing "fluent" like uniform updates
  80628. */
  80629. setInt(name: string, value: number): ProceduralTexture;
  80630. /**
  80631. * Set an array of floats in the shader.
  80632. * @param name Define the name of the uniform as defined in the shader
  80633. * @param value Define the value to give to the uniform
  80634. * @return the texture itself allowing "fluent" like uniform updates
  80635. */
  80636. setFloats(name: string, value: number[]): ProceduralTexture;
  80637. /**
  80638. * Set a vec3 in the shader from a Color3.
  80639. * @param name Define the name of the uniform as defined in the shader
  80640. * @param value Define the value to give to the uniform
  80641. * @return the texture itself allowing "fluent" like uniform updates
  80642. */
  80643. setColor3(name: string, value: Color3): ProceduralTexture;
  80644. /**
  80645. * Set a vec4 in the shader from a Color4.
  80646. * @param name Define the name of the uniform as defined in the shader
  80647. * @param value Define the value to give to the uniform
  80648. * @return the texture itself allowing "fluent" like uniform updates
  80649. */
  80650. setColor4(name: string, value: Color4): ProceduralTexture;
  80651. /**
  80652. * Set a vec2 in the shader from a Vector2.
  80653. * @param name Define the name of the uniform as defined in the shader
  80654. * @param value Define the value to give to the uniform
  80655. * @return the texture itself allowing "fluent" like uniform updates
  80656. */
  80657. setVector2(name: string, value: Vector2): ProceduralTexture;
  80658. /**
  80659. * Set a vec3 in the shader from a Vector3.
  80660. * @param name Define the name of the uniform as defined in the shader
  80661. * @param value Define the value to give to the uniform
  80662. * @return the texture itself allowing "fluent" like uniform updates
  80663. */
  80664. setVector3(name: string, value: Vector3): ProceduralTexture;
  80665. /**
  80666. * Set a mat4 in the shader from a MAtrix.
  80667. * @param name Define the name of the uniform as defined in the shader
  80668. * @param value Define the value to give to the uniform
  80669. * @return the texture itself allowing "fluent" like uniform updates
  80670. */
  80671. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80672. /**
  80673. * Render the texture to its associated render target.
  80674. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80675. */
  80676. render(useCameraPostProcess?: boolean): void;
  80677. /**
  80678. * Clone the texture.
  80679. * @returns the cloned texture
  80680. */
  80681. clone(): ProceduralTexture;
  80682. /**
  80683. * Dispose the texture and release its asoociated resources.
  80684. */
  80685. dispose(): void;
  80686. }
  80687. }
  80688. declare module BABYLON {
  80689. /**
  80690. * This represents the base class for particle system in Babylon.
  80691. * 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.
  80692. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80693. * @example https://doc.babylonjs.com/babylon101/particles
  80694. */
  80695. export class BaseParticleSystem {
  80696. /**
  80697. * Source color is added to the destination color without alpha affecting the result
  80698. */
  80699. static BLENDMODE_ONEONE: number;
  80700. /**
  80701. * Blend current color and particle color using particle’s alpha
  80702. */
  80703. static BLENDMODE_STANDARD: number;
  80704. /**
  80705. * Add current color and particle color multiplied by particle’s alpha
  80706. */
  80707. static BLENDMODE_ADD: number;
  80708. /**
  80709. * Multiply current color with particle color
  80710. */
  80711. static BLENDMODE_MULTIPLY: number;
  80712. /**
  80713. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80714. */
  80715. static BLENDMODE_MULTIPLYADD: number;
  80716. /**
  80717. * List of animations used by the particle system.
  80718. */
  80719. animations: Animation[];
  80720. /**
  80721. * The id of the Particle system.
  80722. */
  80723. id: string;
  80724. /**
  80725. * The friendly name of the Particle system.
  80726. */
  80727. name: string;
  80728. /**
  80729. * The rendering group used by the Particle system to chose when to render.
  80730. */
  80731. renderingGroupId: number;
  80732. /**
  80733. * The emitter represents the Mesh or position we are attaching the particle system to.
  80734. */
  80735. emitter: Nullable<AbstractMesh | Vector3>;
  80736. /**
  80737. * The maximum number of particles to emit per frame
  80738. */
  80739. emitRate: number;
  80740. /**
  80741. * If you want to launch only a few particles at once, that can be done, as well.
  80742. */
  80743. manualEmitCount: number;
  80744. /**
  80745. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80746. */
  80747. updateSpeed: number;
  80748. /**
  80749. * The amount of time the particle system is running (depends of the overall update speed).
  80750. */
  80751. targetStopDuration: number;
  80752. /**
  80753. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80754. */
  80755. disposeOnStop: boolean;
  80756. /**
  80757. * Minimum power of emitting particles.
  80758. */
  80759. minEmitPower: number;
  80760. /**
  80761. * Maximum power of emitting particles.
  80762. */
  80763. maxEmitPower: number;
  80764. /**
  80765. * Minimum life time of emitting particles.
  80766. */
  80767. minLifeTime: number;
  80768. /**
  80769. * Maximum life time of emitting particles.
  80770. */
  80771. maxLifeTime: number;
  80772. /**
  80773. * Minimum Size of emitting particles.
  80774. */
  80775. minSize: number;
  80776. /**
  80777. * Maximum Size of emitting particles.
  80778. */
  80779. maxSize: number;
  80780. /**
  80781. * Minimum scale of emitting particles on X axis.
  80782. */
  80783. minScaleX: number;
  80784. /**
  80785. * Maximum scale of emitting particles on X axis.
  80786. */
  80787. maxScaleX: number;
  80788. /**
  80789. * Minimum scale of emitting particles on Y axis.
  80790. */
  80791. minScaleY: number;
  80792. /**
  80793. * Maximum scale of emitting particles on Y axis.
  80794. */
  80795. maxScaleY: number;
  80796. /**
  80797. * Gets or sets the minimal initial rotation in radians.
  80798. */
  80799. minInitialRotation: number;
  80800. /**
  80801. * Gets or sets the maximal initial rotation in radians.
  80802. */
  80803. maxInitialRotation: number;
  80804. /**
  80805. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80806. */
  80807. minAngularSpeed: number;
  80808. /**
  80809. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80810. */
  80811. maxAngularSpeed: number;
  80812. /**
  80813. * The texture used to render each particle. (this can be a spritesheet)
  80814. */
  80815. particleTexture: Nullable<Texture>;
  80816. /**
  80817. * The layer mask we are rendering the particles through.
  80818. */
  80819. layerMask: number;
  80820. /**
  80821. * This can help using your own shader to render the particle system.
  80822. * The according effect will be created
  80823. */
  80824. customShader: any;
  80825. /**
  80826. * By default particle system starts as soon as they are created. This prevents the
  80827. * automatic start to happen and let you decide when to start emitting particles.
  80828. */
  80829. preventAutoStart: boolean;
  80830. private _noiseTexture;
  80831. /**
  80832. * Gets or sets a texture used to add random noise to particle positions
  80833. */
  80834. noiseTexture: Nullable<ProceduralTexture>;
  80835. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80836. noiseStrength: Vector3;
  80837. /**
  80838. * Callback triggered when the particle animation is ending.
  80839. */
  80840. onAnimationEnd: Nullable<() => void>;
  80841. /**
  80842. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80843. */
  80844. blendMode: number;
  80845. /**
  80846. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80847. * to override the particles.
  80848. */
  80849. forceDepthWrite: boolean;
  80850. /** 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 */
  80851. preWarmCycles: number;
  80852. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80853. preWarmStepOffset: number;
  80854. /**
  80855. * 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)
  80856. */
  80857. spriteCellChangeSpeed: number;
  80858. /**
  80859. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80860. */
  80861. startSpriteCellID: number;
  80862. /**
  80863. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80864. */
  80865. endSpriteCellID: number;
  80866. /**
  80867. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80868. */
  80869. spriteCellWidth: number;
  80870. /**
  80871. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80872. */
  80873. spriteCellHeight: number;
  80874. /**
  80875. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80876. */
  80877. spriteRandomStartCell: boolean;
  80878. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80879. translationPivot: Vector2;
  80880. /** @hidden */
  80881. protected _isAnimationSheetEnabled: boolean;
  80882. /**
  80883. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80884. */
  80885. beginAnimationOnStart: boolean;
  80886. /**
  80887. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80888. */
  80889. beginAnimationFrom: number;
  80890. /**
  80891. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80892. */
  80893. beginAnimationTo: number;
  80894. /**
  80895. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80896. */
  80897. beginAnimationLoop: boolean;
  80898. /**
  80899. * Gets or sets a world offset applied to all particles
  80900. */
  80901. worldOffset: Vector3;
  80902. /**
  80903. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80904. */
  80905. isAnimationSheetEnabled: boolean;
  80906. /**
  80907. * Get hosting scene
  80908. * @returns the scene
  80909. */
  80910. getScene(): Scene;
  80911. /**
  80912. * You can use gravity if you want to give an orientation to your particles.
  80913. */
  80914. gravity: Vector3;
  80915. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80916. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80917. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80918. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80919. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80920. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80921. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80922. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80923. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80924. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80925. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80926. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80927. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80928. /**
  80929. * Defines the delay in milliseconds before starting the system (0 by default)
  80930. */
  80931. startDelay: number;
  80932. /**
  80933. * Gets the current list of drag gradients.
  80934. * You must use addDragGradient and removeDragGradient to udpate this list
  80935. * @returns the list of drag gradients
  80936. */
  80937. getDragGradients(): Nullable<Array<FactorGradient>>;
  80938. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80939. limitVelocityDamping: number;
  80940. /**
  80941. * Gets the current list of limit velocity gradients.
  80942. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80943. * @returns the list of limit velocity gradients
  80944. */
  80945. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80946. /**
  80947. * Gets the current list of color gradients.
  80948. * You must use addColorGradient and removeColorGradient to udpate this list
  80949. * @returns the list of color gradients
  80950. */
  80951. getColorGradients(): Nullable<Array<ColorGradient>>;
  80952. /**
  80953. * Gets the current list of size gradients.
  80954. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80955. * @returns the list of size gradients
  80956. */
  80957. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80958. /**
  80959. * Gets the current list of color remap gradients.
  80960. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80961. * @returns the list of color remap gradients
  80962. */
  80963. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80964. /**
  80965. * Gets the current list of alpha remap gradients.
  80966. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80967. * @returns the list of alpha remap gradients
  80968. */
  80969. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80970. /**
  80971. * Gets the current list of life time gradients.
  80972. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80973. * @returns the list of life time gradients
  80974. */
  80975. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80976. /**
  80977. * Gets the current list of angular speed gradients.
  80978. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80979. * @returns the list of angular speed gradients
  80980. */
  80981. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80982. /**
  80983. * Gets the current list of velocity gradients.
  80984. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80985. * @returns the list of velocity gradients
  80986. */
  80987. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80988. /**
  80989. * Gets the current list of start size gradients.
  80990. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80991. * @returns the list of start size gradients
  80992. */
  80993. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80994. /**
  80995. * Gets the current list of emit rate gradients.
  80996. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80997. * @returns the list of emit rate gradients
  80998. */
  80999. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81000. /**
  81001. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81002. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81003. */
  81004. direction1: Vector3;
  81005. /**
  81006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81008. */
  81009. direction2: Vector3;
  81010. /**
  81011. * 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.
  81012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81013. */
  81014. minEmitBox: Vector3;
  81015. /**
  81016. * 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.
  81017. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81018. */
  81019. maxEmitBox: Vector3;
  81020. /**
  81021. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81022. */
  81023. color1: Color4;
  81024. /**
  81025. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81026. */
  81027. color2: Color4;
  81028. /**
  81029. * Color the particle will have at the end of its lifetime
  81030. */
  81031. colorDead: Color4;
  81032. /**
  81033. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81034. */
  81035. textureMask: Color4;
  81036. /**
  81037. * The particle emitter type defines the emitter used by the particle system.
  81038. * It can be for example box, sphere, or cone...
  81039. */
  81040. particleEmitterType: IParticleEmitterType;
  81041. /** @hidden */
  81042. _isSubEmitter: boolean;
  81043. /**
  81044. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81045. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81046. */
  81047. billboardMode: number;
  81048. protected _isBillboardBased: boolean;
  81049. /**
  81050. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81051. */
  81052. isBillboardBased: boolean;
  81053. /**
  81054. * The scene the particle system belongs to.
  81055. */
  81056. protected _scene: Scene;
  81057. /**
  81058. * Local cache of defines for image processing.
  81059. */
  81060. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81061. /**
  81062. * Default configuration related to image processing available in the standard Material.
  81063. */
  81064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81065. /**
  81066. * Gets the image processing configuration used either in this material.
  81067. */
  81068. /**
  81069. * Sets the Default image processing configuration used either in the this material.
  81070. *
  81071. * If sets to null, the scene one is in use.
  81072. */
  81073. imageProcessingConfiguration: ImageProcessingConfiguration;
  81074. /**
  81075. * Attaches a new image processing configuration to the Standard Material.
  81076. * @param configuration
  81077. */
  81078. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81079. /** @hidden */
  81080. protected _reset(): void;
  81081. /** @hidden */
  81082. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81083. /**
  81084. * Instantiates a particle system.
  81085. * 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.
  81086. * @param name The name of the particle system
  81087. */
  81088. constructor(name: string);
  81089. /**
  81090. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81091. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81092. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81093. * @returns the emitter
  81094. */
  81095. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81096. /**
  81097. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81098. * @param radius The radius of the hemisphere to emit from
  81099. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81100. * @returns the emitter
  81101. */
  81102. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81103. /**
  81104. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81105. * @param radius The radius of the sphere to emit from
  81106. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81107. * @returns the emitter
  81108. */
  81109. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81110. /**
  81111. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81112. * @param radius The radius of the sphere to emit from
  81113. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81114. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81115. * @returns the emitter
  81116. */
  81117. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81118. /**
  81119. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81120. * @param radius The radius of the emission cylinder
  81121. * @param height The height of the emission cylinder
  81122. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81123. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81124. * @returns the emitter
  81125. */
  81126. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81127. /**
  81128. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81129. * @param radius The radius of the cylinder to emit from
  81130. * @param height The height of the emission cylinder
  81131. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81134. * @returns the emitter
  81135. */
  81136. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81137. /**
  81138. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81139. * @param radius The radius of the cone to emit from
  81140. * @param angle The base angle of the cone
  81141. * @returns the emitter
  81142. */
  81143. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81144. /**
  81145. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81148. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81149. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81150. * @returns the emitter
  81151. */
  81152. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81153. }
  81154. }
  81155. declare module BABYLON {
  81156. /**
  81157. * Type of sub emitter
  81158. */
  81159. export enum SubEmitterType {
  81160. /**
  81161. * Attached to the particle over it's lifetime
  81162. */
  81163. ATTACHED = 0,
  81164. /**
  81165. * Created when the particle dies
  81166. */
  81167. END = 1
  81168. }
  81169. /**
  81170. * Sub emitter class used to emit particles from an existing particle
  81171. */
  81172. export class SubEmitter {
  81173. /**
  81174. * the particle system to be used by the sub emitter
  81175. */
  81176. particleSystem: ParticleSystem;
  81177. /**
  81178. * Type of the submitter (Default: END)
  81179. */
  81180. type: SubEmitterType;
  81181. /**
  81182. * 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)
  81183. * Note: This only is supported when using an emitter of type Mesh
  81184. */
  81185. inheritDirection: boolean;
  81186. /**
  81187. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81188. */
  81189. inheritedVelocityAmount: number;
  81190. /**
  81191. * Creates a sub emitter
  81192. * @param particleSystem the particle system to be used by the sub emitter
  81193. */
  81194. constructor(
  81195. /**
  81196. * the particle system to be used by the sub emitter
  81197. */
  81198. particleSystem: ParticleSystem);
  81199. /**
  81200. * Clones the sub emitter
  81201. * @returns the cloned sub emitter
  81202. */
  81203. clone(): SubEmitter;
  81204. /**
  81205. * Serialize current object to a JSON object
  81206. * @returns the serialized object
  81207. */
  81208. serialize(): any;
  81209. /** @hidden */
  81210. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81211. /**
  81212. * Creates a new SubEmitter from a serialized JSON version
  81213. * @param serializationObject defines the JSON object to read from
  81214. * @param scene defines the hosting scene
  81215. * @param rootUrl defines the rootUrl for data loading
  81216. * @returns a new SubEmitter
  81217. */
  81218. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81219. /** Release associated resources */
  81220. dispose(): void;
  81221. }
  81222. }
  81223. declare module BABYLON {
  81224. /** @hidden */
  81225. export var clipPlaneFragmentDeclaration: {
  81226. name: string;
  81227. shader: string;
  81228. };
  81229. }
  81230. declare module BABYLON {
  81231. /** @hidden */
  81232. export var imageProcessingDeclaration: {
  81233. name: string;
  81234. shader: string;
  81235. };
  81236. }
  81237. declare module BABYLON {
  81238. /** @hidden */
  81239. export var imageProcessingFunctions: {
  81240. name: string;
  81241. shader: string;
  81242. };
  81243. }
  81244. declare module BABYLON {
  81245. /** @hidden */
  81246. export var clipPlaneFragment: {
  81247. name: string;
  81248. shader: string;
  81249. };
  81250. }
  81251. declare module BABYLON {
  81252. /** @hidden */
  81253. export var particlesPixelShader: {
  81254. name: string;
  81255. shader: string;
  81256. };
  81257. }
  81258. declare module BABYLON {
  81259. /** @hidden */
  81260. export var clipPlaneVertexDeclaration: {
  81261. name: string;
  81262. shader: string;
  81263. };
  81264. }
  81265. declare module BABYLON {
  81266. /** @hidden */
  81267. export var clipPlaneVertex: {
  81268. name: string;
  81269. shader: string;
  81270. };
  81271. }
  81272. declare module BABYLON {
  81273. /** @hidden */
  81274. export var particlesVertexShader: {
  81275. name: string;
  81276. shader: string;
  81277. };
  81278. }
  81279. declare module BABYLON {
  81280. /**
  81281. * This represents a particle system in Babylon.
  81282. * 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.
  81283. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81284. * @example https://doc.babylonjs.com/babylon101/particles
  81285. */
  81286. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81287. /**
  81288. * Billboard mode will only apply to Y axis
  81289. */
  81290. static readonly BILLBOARDMODE_Y: number;
  81291. /**
  81292. * Billboard mode will apply to all axes
  81293. */
  81294. static readonly BILLBOARDMODE_ALL: number;
  81295. /**
  81296. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81297. */
  81298. static readonly BILLBOARDMODE_STRETCHED: number;
  81299. /**
  81300. * This function can be defined to provide custom update for active particles.
  81301. * This function will be called instead of regular update (age, position, color, etc.).
  81302. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81303. */
  81304. updateFunction: (particles: Particle[]) => void;
  81305. private _emitterWorldMatrix;
  81306. /**
  81307. * This function can be defined to specify initial direction for every new particle.
  81308. * It by default use the emitterType defined function
  81309. */
  81310. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81311. /**
  81312. * This function can be defined to specify initial position for every new particle.
  81313. * It by default use the emitterType defined function
  81314. */
  81315. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81316. /**
  81317. * @hidden
  81318. */
  81319. _inheritedVelocityOffset: Vector3;
  81320. /**
  81321. * An event triggered when the system is disposed
  81322. */
  81323. onDisposeObservable: Observable<ParticleSystem>;
  81324. private _onDisposeObserver;
  81325. /**
  81326. * Sets a callback that will be triggered when the system is disposed
  81327. */
  81328. onDispose: () => void;
  81329. private _particles;
  81330. private _epsilon;
  81331. private _capacity;
  81332. private _stockParticles;
  81333. private _newPartsExcess;
  81334. private _vertexData;
  81335. private _vertexBuffer;
  81336. private _vertexBuffers;
  81337. private _spriteBuffer;
  81338. private _indexBuffer;
  81339. private _effect;
  81340. private _customEffect;
  81341. private _cachedDefines;
  81342. private _scaledColorStep;
  81343. private _colorDiff;
  81344. private _scaledDirection;
  81345. private _scaledGravity;
  81346. private _currentRenderId;
  81347. private _alive;
  81348. private _useInstancing;
  81349. private _started;
  81350. private _stopped;
  81351. private _actualFrame;
  81352. private _scaledUpdateSpeed;
  81353. private _vertexBufferSize;
  81354. /** @hidden */
  81355. _currentEmitRateGradient: Nullable<FactorGradient>;
  81356. /** @hidden */
  81357. _currentEmitRate1: number;
  81358. /** @hidden */
  81359. _currentEmitRate2: number;
  81360. /** @hidden */
  81361. _currentStartSizeGradient: Nullable<FactorGradient>;
  81362. /** @hidden */
  81363. _currentStartSize1: number;
  81364. /** @hidden */
  81365. _currentStartSize2: number;
  81366. private readonly _rawTextureWidth;
  81367. private _rampGradientsTexture;
  81368. private _useRampGradients;
  81369. /** Gets or sets a boolean indicating that ramp gradients must be used
  81370. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81371. */
  81372. useRampGradients: boolean;
  81373. /**
  81374. * 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.
  81375. * 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: [])
  81376. */
  81377. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81378. private _subEmitters;
  81379. /**
  81380. * @hidden
  81381. * If the particle systems emitter should be disposed when the particle system is disposed
  81382. */
  81383. _disposeEmitterOnDispose: boolean;
  81384. /**
  81385. * The current active Sub-systems, this property is used by the root particle system only.
  81386. */
  81387. activeSubSystems: Array<ParticleSystem>;
  81388. private _rootParticleSystem;
  81389. /**
  81390. * Gets the current list of active particles
  81391. */
  81392. readonly particles: Particle[];
  81393. /**
  81394. * Returns the string "ParticleSystem"
  81395. * @returns a string containing the class name
  81396. */
  81397. getClassName(): string;
  81398. /**
  81399. * Instantiates a particle system.
  81400. * 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.
  81401. * @param name The name of the particle system
  81402. * @param capacity The max number of particles alive at the same time
  81403. * @param scene The scene the particle system belongs to
  81404. * @param customEffect a custom effect used to change the way particles are rendered by default
  81405. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81406. * @param epsilon Offset used to render the particles
  81407. */
  81408. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81409. private _addFactorGradient;
  81410. private _removeFactorGradient;
  81411. /**
  81412. * Adds a new life time gradient
  81413. * @param gradient defines the gradient to use (between 0 and 1)
  81414. * @param factor defines the life time factor to affect to the specified gradient
  81415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81416. * @returns the current particle system
  81417. */
  81418. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81419. /**
  81420. * Remove a specific life time gradient
  81421. * @param gradient defines the gradient to remove
  81422. * @returns the current particle system
  81423. */
  81424. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81425. /**
  81426. * Adds a new size gradient
  81427. * @param gradient defines the gradient to use (between 0 and 1)
  81428. * @param factor defines the size factor to affect to the specified gradient
  81429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81430. * @returns the current particle system
  81431. */
  81432. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81433. /**
  81434. * Remove a specific size gradient
  81435. * @param gradient defines the gradient to remove
  81436. * @returns the current particle system
  81437. */
  81438. removeSizeGradient(gradient: number): IParticleSystem;
  81439. /**
  81440. * Adds a new color remap gradient
  81441. * @param gradient defines the gradient to use (between 0 and 1)
  81442. * @param min defines the color remap minimal range
  81443. * @param max defines the color remap maximal range
  81444. * @returns the current particle system
  81445. */
  81446. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81447. /**
  81448. * Remove a specific color remap gradient
  81449. * @param gradient defines the gradient to remove
  81450. * @returns the current particle system
  81451. */
  81452. removeColorRemapGradient(gradient: number): IParticleSystem;
  81453. /**
  81454. * Adds a new alpha remap gradient
  81455. * @param gradient defines the gradient to use (between 0 and 1)
  81456. * @param min defines the alpha remap minimal range
  81457. * @param max defines the alpha remap maximal range
  81458. * @returns the current particle system
  81459. */
  81460. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81461. /**
  81462. * Remove a specific alpha remap gradient
  81463. * @param gradient defines the gradient to remove
  81464. * @returns the current particle system
  81465. */
  81466. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81467. /**
  81468. * Adds a new angular speed gradient
  81469. * @param gradient defines the gradient to use (between 0 and 1)
  81470. * @param factor defines the angular speed to affect to the specified gradient
  81471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81472. * @returns the current particle system
  81473. */
  81474. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81475. /**
  81476. * Remove a specific angular speed gradient
  81477. * @param gradient defines the gradient to remove
  81478. * @returns the current particle system
  81479. */
  81480. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81481. /**
  81482. * Adds a new velocity gradient
  81483. * @param gradient defines the gradient to use (between 0 and 1)
  81484. * @param factor defines the velocity to affect to the specified gradient
  81485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81486. * @returns the current particle system
  81487. */
  81488. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81489. /**
  81490. * Remove a specific velocity gradient
  81491. * @param gradient defines the gradient to remove
  81492. * @returns the current particle system
  81493. */
  81494. removeVelocityGradient(gradient: number): IParticleSystem;
  81495. /**
  81496. * Adds a new limit velocity gradient
  81497. * @param gradient defines the gradient to use (between 0 and 1)
  81498. * @param factor defines the limit velocity value to affect to the specified gradient
  81499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81500. * @returns the current particle system
  81501. */
  81502. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81503. /**
  81504. * Remove a specific limit velocity gradient
  81505. * @param gradient defines the gradient to remove
  81506. * @returns the current particle system
  81507. */
  81508. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81509. /**
  81510. * Adds a new drag gradient
  81511. * @param gradient defines the gradient to use (between 0 and 1)
  81512. * @param factor defines the drag value to affect to the specified gradient
  81513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81514. * @returns the current particle system
  81515. */
  81516. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81517. /**
  81518. * Remove a specific drag gradient
  81519. * @param gradient defines the gradient to remove
  81520. * @returns the current particle system
  81521. */
  81522. removeDragGradient(gradient: number): IParticleSystem;
  81523. /**
  81524. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81525. * @param gradient defines the gradient to use (between 0 and 1)
  81526. * @param factor defines the emit rate value to affect to the specified gradient
  81527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81528. * @returns the current particle system
  81529. */
  81530. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81531. /**
  81532. * Remove a specific emit rate gradient
  81533. * @param gradient defines the gradient to remove
  81534. * @returns the current particle system
  81535. */
  81536. removeEmitRateGradient(gradient: number): IParticleSystem;
  81537. /**
  81538. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81539. * @param gradient defines the gradient to use (between 0 and 1)
  81540. * @param factor defines the start size value to affect to the specified gradient
  81541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81542. * @returns the current particle system
  81543. */
  81544. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81545. /**
  81546. * Remove a specific start size gradient
  81547. * @param gradient defines the gradient to remove
  81548. * @returns the current particle system
  81549. */
  81550. removeStartSizeGradient(gradient: number): IParticleSystem;
  81551. private _createRampGradientTexture;
  81552. /**
  81553. * Gets the current list of ramp gradients.
  81554. * You must use addRampGradient and removeRampGradient to udpate this list
  81555. * @returns the list of ramp gradients
  81556. */
  81557. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81558. /**
  81559. * Adds a new ramp gradient used to remap particle colors
  81560. * @param gradient defines the gradient to use (between 0 and 1)
  81561. * @param color defines the color to affect to the specified gradient
  81562. * @returns the current particle system
  81563. */
  81564. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81565. /**
  81566. * Remove a specific ramp gradient
  81567. * @param gradient defines the gradient to remove
  81568. * @returns the current particle system
  81569. */
  81570. removeRampGradient(gradient: number): ParticleSystem;
  81571. /**
  81572. * Adds a new color gradient
  81573. * @param gradient defines the gradient to use (between 0 and 1)
  81574. * @param color1 defines the color to affect to the specified gradient
  81575. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81576. * @returns this particle system
  81577. */
  81578. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81579. /**
  81580. * Remove a specific color gradient
  81581. * @param gradient defines the gradient to remove
  81582. * @returns this particle system
  81583. */
  81584. removeColorGradient(gradient: number): IParticleSystem;
  81585. private _fetchR;
  81586. protected _reset(): void;
  81587. private _resetEffect;
  81588. private _createVertexBuffers;
  81589. private _createIndexBuffer;
  81590. /**
  81591. * Gets the maximum number of particles active at the same time.
  81592. * @returns The max number of active particles.
  81593. */
  81594. getCapacity(): number;
  81595. /**
  81596. * Gets whether there are still active particles in the system.
  81597. * @returns True if it is alive, otherwise false.
  81598. */
  81599. isAlive(): boolean;
  81600. /**
  81601. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81602. * @returns True if it has been started, otherwise false.
  81603. */
  81604. isStarted(): boolean;
  81605. private _prepareSubEmitterInternalArray;
  81606. /**
  81607. * Starts the particle system and begins to emit
  81608. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81609. */
  81610. start(delay?: number): void;
  81611. /**
  81612. * Stops the particle system.
  81613. * @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.
  81614. */
  81615. stop(stopSubEmitters?: boolean): void;
  81616. /**
  81617. * Remove all active particles
  81618. */
  81619. reset(): void;
  81620. /**
  81621. * @hidden (for internal use only)
  81622. */
  81623. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81624. /**
  81625. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81626. * Its lifetime will start back at 0.
  81627. */
  81628. recycleParticle: (particle: Particle) => void;
  81629. private _stopSubEmitters;
  81630. private _createParticle;
  81631. private _removeFromRoot;
  81632. private _emitFromParticle;
  81633. private _update;
  81634. /** @hidden */
  81635. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81636. /** @hidden */
  81637. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81638. /** @hidden */
  81639. private _getEffect;
  81640. /**
  81641. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81642. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81643. */
  81644. animate(preWarmOnly?: boolean): void;
  81645. private _appendParticleVertices;
  81646. /**
  81647. * Rebuilds the particle system.
  81648. */
  81649. rebuild(): void;
  81650. /**
  81651. * Is this system ready to be used/rendered
  81652. * @return true if the system is ready
  81653. */
  81654. isReady(): boolean;
  81655. private _render;
  81656. /**
  81657. * Renders the particle system in its current state.
  81658. * @returns the current number of particles
  81659. */
  81660. render(): number;
  81661. /**
  81662. * Disposes the particle system and free the associated resources
  81663. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81664. */
  81665. dispose(disposeTexture?: boolean): void;
  81666. /**
  81667. * Clones the particle system.
  81668. * @param name The name of the cloned object
  81669. * @param newEmitter The new emitter to use
  81670. * @returns the cloned particle system
  81671. */
  81672. clone(name: string, newEmitter: any): ParticleSystem;
  81673. /**
  81674. * Serializes the particle system to a JSON object.
  81675. * @returns the JSON object
  81676. */
  81677. serialize(): any;
  81678. /** @hidden */
  81679. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81680. /** @hidden */
  81681. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81682. /**
  81683. * Parses a JSON object to create a particle system.
  81684. * @param parsedParticleSystem The JSON object to parse
  81685. * @param scene The scene to create the particle system in
  81686. * @param rootUrl The root url to use to load external dependencies like texture
  81687. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81688. * @returns the Parsed particle system
  81689. */
  81690. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * A particle represents one of the element emitted by a particle system.
  81696. * This is mainly define by its coordinates, direction, velocity and age.
  81697. */
  81698. export class Particle {
  81699. /**
  81700. * The particle system the particle belongs to.
  81701. */
  81702. particleSystem: ParticleSystem;
  81703. private static _Count;
  81704. /**
  81705. * Unique ID of the particle
  81706. */
  81707. id: number;
  81708. /**
  81709. * The world position of the particle in the scene.
  81710. */
  81711. position: Vector3;
  81712. /**
  81713. * The world direction of the particle in the scene.
  81714. */
  81715. direction: Vector3;
  81716. /**
  81717. * The color of the particle.
  81718. */
  81719. color: Color4;
  81720. /**
  81721. * The color change of the particle per step.
  81722. */
  81723. colorStep: Color4;
  81724. /**
  81725. * Defines how long will the life of the particle be.
  81726. */
  81727. lifeTime: number;
  81728. /**
  81729. * The current age of the particle.
  81730. */
  81731. age: number;
  81732. /**
  81733. * The current size of the particle.
  81734. */
  81735. size: number;
  81736. /**
  81737. * The current scale of the particle.
  81738. */
  81739. scale: Vector2;
  81740. /**
  81741. * The current angle of the particle.
  81742. */
  81743. angle: number;
  81744. /**
  81745. * Defines how fast is the angle changing.
  81746. */
  81747. angularSpeed: number;
  81748. /**
  81749. * Defines the cell index used by the particle to be rendered from a sprite.
  81750. */
  81751. cellIndex: number;
  81752. /**
  81753. * The information required to support color remapping
  81754. */
  81755. remapData: Vector4;
  81756. /** @hidden */
  81757. _randomCellOffset?: number;
  81758. /** @hidden */
  81759. _initialDirection: Nullable<Vector3>;
  81760. /** @hidden */
  81761. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81762. /** @hidden */
  81763. _initialStartSpriteCellID: number;
  81764. /** @hidden */
  81765. _initialEndSpriteCellID: number;
  81766. /** @hidden */
  81767. _currentColorGradient: Nullable<ColorGradient>;
  81768. /** @hidden */
  81769. _currentColor1: Color4;
  81770. /** @hidden */
  81771. _currentColor2: Color4;
  81772. /** @hidden */
  81773. _currentSizeGradient: Nullable<FactorGradient>;
  81774. /** @hidden */
  81775. _currentSize1: number;
  81776. /** @hidden */
  81777. _currentSize2: number;
  81778. /** @hidden */
  81779. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81780. /** @hidden */
  81781. _currentAngularSpeed1: number;
  81782. /** @hidden */
  81783. _currentAngularSpeed2: number;
  81784. /** @hidden */
  81785. _currentVelocityGradient: Nullable<FactorGradient>;
  81786. /** @hidden */
  81787. _currentVelocity1: number;
  81788. /** @hidden */
  81789. _currentVelocity2: number;
  81790. /** @hidden */
  81791. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81792. /** @hidden */
  81793. _currentLimitVelocity1: number;
  81794. /** @hidden */
  81795. _currentLimitVelocity2: number;
  81796. /** @hidden */
  81797. _currentDragGradient: Nullable<FactorGradient>;
  81798. /** @hidden */
  81799. _currentDrag1: number;
  81800. /** @hidden */
  81801. _currentDrag2: number;
  81802. /** @hidden */
  81803. _randomNoiseCoordinates1: Vector3;
  81804. /** @hidden */
  81805. _randomNoiseCoordinates2: Vector3;
  81806. /**
  81807. * Creates a new instance Particle
  81808. * @param particleSystem the particle system the particle belongs to
  81809. */
  81810. constructor(
  81811. /**
  81812. * The particle system the particle belongs to.
  81813. */
  81814. particleSystem: ParticleSystem);
  81815. private updateCellInfoFromSystem;
  81816. /**
  81817. * Defines how the sprite cell index is updated for the particle
  81818. */
  81819. updateCellIndex(): void;
  81820. /** @hidden */
  81821. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81822. /** @hidden */
  81823. _inheritParticleInfoToSubEmitters(): void;
  81824. /** @hidden */
  81825. _reset(): void;
  81826. /**
  81827. * Copy the properties of particle to another one.
  81828. * @param other the particle to copy the information to.
  81829. */
  81830. copyTo(other: Particle): void;
  81831. }
  81832. }
  81833. declare module BABYLON {
  81834. /**
  81835. * Particle emitter represents a volume emitting particles.
  81836. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81837. */
  81838. export interface IParticleEmitterType {
  81839. /**
  81840. * Called by the particle System when the direction is computed for the created particle.
  81841. * @param worldMatrix is the world matrix of the particle system
  81842. * @param directionToUpdate is the direction vector to update with the result
  81843. * @param particle is the particle we are computed the direction for
  81844. */
  81845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81846. /**
  81847. * Called by the particle System when the position is computed for the created particle.
  81848. * @param worldMatrix is the world matrix of the particle system
  81849. * @param positionToUpdate is the position vector to update with the result
  81850. * @param particle is the particle we are computed the position for
  81851. */
  81852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81853. /**
  81854. * Clones the current emitter and returns a copy of it
  81855. * @returns the new emitter
  81856. */
  81857. clone(): IParticleEmitterType;
  81858. /**
  81859. * Called by the GPUParticleSystem to setup the update shader
  81860. * @param effect defines the update shader
  81861. */
  81862. applyToShader(effect: Effect): void;
  81863. /**
  81864. * Returns a string to use to update the GPU particles update shader
  81865. * @returns the effect defines string
  81866. */
  81867. getEffectDefines(): string;
  81868. /**
  81869. * Returns a string representing the class name
  81870. * @returns a string containing the class name
  81871. */
  81872. getClassName(): string;
  81873. /**
  81874. * Serializes the particle system to a JSON object.
  81875. * @returns the JSON object
  81876. */
  81877. serialize(): any;
  81878. /**
  81879. * Parse properties from a JSON object
  81880. * @param serializationObject defines the JSON object
  81881. */
  81882. parse(serializationObject: any): void;
  81883. }
  81884. }
  81885. declare module BABYLON {
  81886. /**
  81887. * Particle emitter emitting particles from the inside of a box.
  81888. * It emits the particles randomly between 2 given directions.
  81889. */
  81890. export class BoxParticleEmitter implements IParticleEmitterType {
  81891. /**
  81892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81893. */
  81894. direction1: Vector3;
  81895. /**
  81896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81897. */
  81898. direction2: Vector3;
  81899. /**
  81900. * 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.
  81901. */
  81902. minEmitBox: Vector3;
  81903. /**
  81904. * 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.
  81905. */
  81906. maxEmitBox: Vector3;
  81907. /**
  81908. * Creates a new instance BoxParticleEmitter
  81909. */
  81910. constructor();
  81911. /**
  81912. * Called by the particle System when the direction is computed for the created particle.
  81913. * @param worldMatrix is the world matrix of the particle system
  81914. * @param directionToUpdate is the direction vector to update with the result
  81915. * @param particle is the particle we are computed the direction for
  81916. */
  81917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81918. /**
  81919. * Called by the particle System when the position is computed for the created particle.
  81920. * @param worldMatrix is the world matrix of the particle system
  81921. * @param positionToUpdate is the position vector to update with the result
  81922. * @param particle is the particle we are computed the position for
  81923. */
  81924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81925. /**
  81926. * Clones the current emitter and returns a copy of it
  81927. * @returns the new emitter
  81928. */
  81929. clone(): BoxParticleEmitter;
  81930. /**
  81931. * Called by the GPUParticleSystem to setup the update shader
  81932. * @param effect defines the update shader
  81933. */
  81934. applyToShader(effect: Effect): void;
  81935. /**
  81936. * Returns a string to use to update the GPU particles update shader
  81937. * @returns a string containng the defines string
  81938. */
  81939. getEffectDefines(): string;
  81940. /**
  81941. * Returns the string "BoxParticleEmitter"
  81942. * @returns a string containing the class name
  81943. */
  81944. getClassName(): string;
  81945. /**
  81946. * Serializes the particle system to a JSON object.
  81947. * @returns the JSON object
  81948. */
  81949. serialize(): any;
  81950. /**
  81951. * Parse properties from a JSON object
  81952. * @param serializationObject defines the JSON object
  81953. */
  81954. parse(serializationObject: any): void;
  81955. }
  81956. }
  81957. declare module BABYLON {
  81958. /**
  81959. * Particle emitter emitting particles from the inside of a cone.
  81960. * It emits the particles alongside the cone volume from the base to the particle.
  81961. * The emission direction might be randomized.
  81962. */
  81963. export class ConeParticleEmitter implements IParticleEmitterType {
  81964. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81965. directionRandomizer: number;
  81966. private _radius;
  81967. private _angle;
  81968. private _height;
  81969. /**
  81970. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81971. */
  81972. radiusRange: number;
  81973. /**
  81974. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81975. */
  81976. heightRange: number;
  81977. /**
  81978. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81979. */
  81980. emitFromSpawnPointOnly: boolean;
  81981. /**
  81982. * Gets or sets the radius of the emission cone
  81983. */
  81984. radius: number;
  81985. /**
  81986. * Gets or sets the angle of the emission cone
  81987. */
  81988. angle: number;
  81989. private _buildHeight;
  81990. /**
  81991. * Creates a new instance ConeParticleEmitter
  81992. * @param radius the radius of the emission cone (1 by default)
  81993. * @param angle the cone base angle (PI by default)
  81994. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81995. */
  81996. constructor(radius?: number, angle?: number,
  81997. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81998. directionRandomizer?: number);
  81999. /**
  82000. * Called by the particle System when the direction is computed for the created particle.
  82001. * @param worldMatrix is the world matrix of the particle system
  82002. * @param directionToUpdate is the direction vector to update with the result
  82003. * @param particle is the particle we are computed the direction for
  82004. */
  82005. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82006. /**
  82007. * Called by the particle System when the position is computed for the created particle.
  82008. * @param worldMatrix is the world matrix of the particle system
  82009. * @param positionToUpdate is the position vector to update with the result
  82010. * @param particle is the particle we are computed the position for
  82011. */
  82012. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82013. /**
  82014. * Clones the current emitter and returns a copy of it
  82015. * @returns the new emitter
  82016. */
  82017. clone(): ConeParticleEmitter;
  82018. /**
  82019. * Called by the GPUParticleSystem to setup the update shader
  82020. * @param effect defines the update shader
  82021. */
  82022. applyToShader(effect: Effect): void;
  82023. /**
  82024. * Returns a string to use to update the GPU particles update shader
  82025. * @returns a string containng the defines string
  82026. */
  82027. getEffectDefines(): string;
  82028. /**
  82029. * Returns the string "ConeParticleEmitter"
  82030. * @returns a string containing the class name
  82031. */
  82032. getClassName(): string;
  82033. /**
  82034. * Serializes the particle system to a JSON object.
  82035. * @returns the JSON object
  82036. */
  82037. serialize(): any;
  82038. /**
  82039. * Parse properties from a JSON object
  82040. * @param serializationObject defines the JSON object
  82041. */
  82042. parse(serializationObject: any): void;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * Particle emitter emitting particles from the inside of a cylinder.
  82048. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82049. */
  82050. export class CylinderParticleEmitter implements IParticleEmitterType {
  82051. /**
  82052. * The radius of the emission cylinder.
  82053. */
  82054. radius: number;
  82055. /**
  82056. * The height of the emission cylinder.
  82057. */
  82058. height: number;
  82059. /**
  82060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82061. */
  82062. radiusRange: number;
  82063. /**
  82064. * How much to randomize the particle direction [0-1].
  82065. */
  82066. directionRandomizer: number;
  82067. /**
  82068. * Creates a new instance CylinderParticleEmitter
  82069. * @param radius the radius of the emission cylinder (1 by default)
  82070. * @param height the height of the emission cylinder (1 by default)
  82071. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82072. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82073. */
  82074. constructor(
  82075. /**
  82076. * The radius of the emission cylinder.
  82077. */
  82078. radius?: number,
  82079. /**
  82080. * The height of the emission cylinder.
  82081. */
  82082. height?: number,
  82083. /**
  82084. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82085. */
  82086. radiusRange?: number,
  82087. /**
  82088. * How much to randomize the particle direction [0-1].
  82089. */
  82090. directionRandomizer?: number);
  82091. /**
  82092. * Called by the particle System when the direction is computed for the created particle.
  82093. * @param worldMatrix is the world matrix of the particle system
  82094. * @param directionToUpdate is the direction vector to update with the result
  82095. * @param particle is the particle we are computed the direction for
  82096. */
  82097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82098. /**
  82099. * Called by the particle System when the position is computed for the created particle.
  82100. * @param worldMatrix is the world matrix of the particle system
  82101. * @param positionToUpdate is the position vector to update with the result
  82102. * @param particle is the particle we are computed the position for
  82103. */
  82104. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82105. /**
  82106. * Clones the current emitter and returns a copy of it
  82107. * @returns the new emitter
  82108. */
  82109. clone(): CylinderParticleEmitter;
  82110. /**
  82111. * Called by the GPUParticleSystem to setup the update shader
  82112. * @param effect defines the update shader
  82113. */
  82114. applyToShader(effect: Effect): void;
  82115. /**
  82116. * Returns a string to use to update the GPU particles update shader
  82117. * @returns a string containng the defines string
  82118. */
  82119. getEffectDefines(): string;
  82120. /**
  82121. * Returns the string "CylinderParticleEmitter"
  82122. * @returns a string containing the class name
  82123. */
  82124. getClassName(): string;
  82125. /**
  82126. * Serializes the particle system to a JSON object.
  82127. * @returns the JSON object
  82128. */
  82129. serialize(): any;
  82130. /**
  82131. * Parse properties from a JSON object
  82132. * @param serializationObject defines the JSON object
  82133. */
  82134. parse(serializationObject: any): void;
  82135. }
  82136. /**
  82137. * Particle emitter emitting particles from the inside of a cylinder.
  82138. * It emits the particles randomly between two vectors.
  82139. */
  82140. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82141. /**
  82142. * The min limit of the emission direction.
  82143. */
  82144. direction1: Vector3;
  82145. /**
  82146. * The max limit of the emission direction.
  82147. */
  82148. direction2: Vector3;
  82149. /**
  82150. * Creates a new instance CylinderDirectedParticleEmitter
  82151. * @param radius the radius of the emission cylinder (1 by default)
  82152. * @param height the height of the emission cylinder (1 by default)
  82153. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82154. * @param direction1 the min limit of the emission direction (up vector by default)
  82155. * @param direction2 the max limit of the emission direction (up vector by default)
  82156. */
  82157. constructor(radius?: number, height?: number, radiusRange?: number,
  82158. /**
  82159. * The min limit of the emission direction.
  82160. */
  82161. direction1?: Vector3,
  82162. /**
  82163. * The max limit of the emission direction.
  82164. */
  82165. direction2?: Vector3);
  82166. /**
  82167. * Called by the particle System when the direction is computed for the created particle.
  82168. * @param worldMatrix is the world matrix of the particle system
  82169. * @param directionToUpdate is the direction vector to update with the result
  82170. * @param particle is the particle we are computed the direction for
  82171. */
  82172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82173. /**
  82174. * Clones the current emitter and returns a copy of it
  82175. * @returns the new emitter
  82176. */
  82177. clone(): CylinderDirectedParticleEmitter;
  82178. /**
  82179. * Called by the GPUParticleSystem to setup the update shader
  82180. * @param effect defines the update shader
  82181. */
  82182. applyToShader(effect: Effect): void;
  82183. /**
  82184. * Returns a string to use to update the GPU particles update shader
  82185. * @returns a string containng the defines string
  82186. */
  82187. getEffectDefines(): string;
  82188. /**
  82189. * Returns the string "CylinderDirectedParticleEmitter"
  82190. * @returns a string containing the class name
  82191. */
  82192. getClassName(): string;
  82193. /**
  82194. * Serializes the particle system to a JSON object.
  82195. * @returns the JSON object
  82196. */
  82197. serialize(): any;
  82198. /**
  82199. * Parse properties from a JSON object
  82200. * @param serializationObject defines the JSON object
  82201. */
  82202. parse(serializationObject: any): void;
  82203. }
  82204. }
  82205. declare module BABYLON {
  82206. /**
  82207. * Particle emitter emitting particles from the inside of a hemisphere.
  82208. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82209. */
  82210. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82211. /**
  82212. * The radius of the emission hemisphere.
  82213. */
  82214. radius: number;
  82215. /**
  82216. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82217. */
  82218. radiusRange: number;
  82219. /**
  82220. * How much to randomize the particle direction [0-1].
  82221. */
  82222. directionRandomizer: number;
  82223. /**
  82224. * Creates a new instance HemisphericParticleEmitter
  82225. * @param radius the radius of the emission hemisphere (1 by default)
  82226. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82227. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82228. */
  82229. constructor(
  82230. /**
  82231. * The radius of the emission hemisphere.
  82232. */
  82233. radius?: number,
  82234. /**
  82235. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82236. */
  82237. radiusRange?: number,
  82238. /**
  82239. * How much to randomize the particle direction [0-1].
  82240. */
  82241. directionRandomizer?: number);
  82242. /**
  82243. * Called by the particle System when the direction is computed for the created particle.
  82244. * @param worldMatrix is the world matrix of the particle system
  82245. * @param directionToUpdate is the direction vector to update with the result
  82246. * @param particle is the particle we are computed the direction for
  82247. */
  82248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82249. /**
  82250. * Called by the particle System when the position is computed for the created particle.
  82251. * @param worldMatrix is the world matrix of the particle system
  82252. * @param positionToUpdate is the position vector to update with the result
  82253. * @param particle is the particle we are computed the position for
  82254. */
  82255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82256. /**
  82257. * Clones the current emitter and returns a copy of it
  82258. * @returns the new emitter
  82259. */
  82260. clone(): HemisphericParticleEmitter;
  82261. /**
  82262. * Called by the GPUParticleSystem to setup the update shader
  82263. * @param effect defines the update shader
  82264. */
  82265. applyToShader(effect: Effect): void;
  82266. /**
  82267. * Returns a string to use to update the GPU particles update shader
  82268. * @returns a string containng the defines string
  82269. */
  82270. getEffectDefines(): string;
  82271. /**
  82272. * Returns the string "HemisphericParticleEmitter"
  82273. * @returns a string containing the class name
  82274. */
  82275. getClassName(): string;
  82276. /**
  82277. * Serializes the particle system to a JSON object.
  82278. * @returns the JSON object
  82279. */
  82280. serialize(): any;
  82281. /**
  82282. * Parse properties from a JSON object
  82283. * @param serializationObject defines the JSON object
  82284. */
  82285. parse(serializationObject: any): void;
  82286. }
  82287. }
  82288. declare module BABYLON {
  82289. /**
  82290. * Particle emitter emitting particles from a point.
  82291. * It emits the particles randomly between 2 given directions.
  82292. */
  82293. export class PointParticleEmitter implements IParticleEmitterType {
  82294. /**
  82295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82296. */
  82297. direction1: Vector3;
  82298. /**
  82299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82300. */
  82301. direction2: Vector3;
  82302. /**
  82303. * Creates a new instance PointParticleEmitter
  82304. */
  82305. constructor();
  82306. /**
  82307. * Called by the particle System when the direction is computed for the created particle.
  82308. * @param worldMatrix is the world matrix of the particle system
  82309. * @param directionToUpdate is the direction vector to update with the result
  82310. * @param particle is the particle we are computed the direction for
  82311. */
  82312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82313. /**
  82314. * Called by the particle System when the position is computed for the created particle.
  82315. * @param worldMatrix is the world matrix of the particle system
  82316. * @param positionToUpdate is the position vector to update with the result
  82317. * @param particle is the particle we are computed the position for
  82318. */
  82319. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82320. /**
  82321. * Clones the current emitter and returns a copy of it
  82322. * @returns the new emitter
  82323. */
  82324. clone(): PointParticleEmitter;
  82325. /**
  82326. * Called by the GPUParticleSystem to setup the update shader
  82327. * @param effect defines the update shader
  82328. */
  82329. applyToShader(effect: Effect): void;
  82330. /**
  82331. * Returns a string to use to update the GPU particles update shader
  82332. * @returns a string containng the defines string
  82333. */
  82334. getEffectDefines(): string;
  82335. /**
  82336. * Returns the string "PointParticleEmitter"
  82337. * @returns a string containing the class name
  82338. */
  82339. getClassName(): string;
  82340. /**
  82341. * Serializes the particle system to a JSON object.
  82342. * @returns the JSON object
  82343. */
  82344. serialize(): any;
  82345. /**
  82346. * Parse properties from a JSON object
  82347. * @param serializationObject defines the JSON object
  82348. */
  82349. parse(serializationObject: any): void;
  82350. }
  82351. }
  82352. declare module BABYLON {
  82353. /**
  82354. * Particle emitter emitting particles from the inside of a sphere.
  82355. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82356. */
  82357. export class SphereParticleEmitter implements IParticleEmitterType {
  82358. /**
  82359. * The radius of the emission sphere.
  82360. */
  82361. radius: number;
  82362. /**
  82363. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82364. */
  82365. radiusRange: number;
  82366. /**
  82367. * How much to randomize the particle direction [0-1].
  82368. */
  82369. directionRandomizer: number;
  82370. /**
  82371. * Creates a new instance SphereParticleEmitter
  82372. * @param radius the radius of the emission sphere (1 by default)
  82373. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82374. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82375. */
  82376. constructor(
  82377. /**
  82378. * The radius of the emission sphere.
  82379. */
  82380. radius?: number,
  82381. /**
  82382. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82383. */
  82384. radiusRange?: number,
  82385. /**
  82386. * How much to randomize the particle direction [0-1].
  82387. */
  82388. directionRandomizer?: number);
  82389. /**
  82390. * Called by the particle System when the direction is computed for the created particle.
  82391. * @param worldMatrix is the world matrix of the particle system
  82392. * @param directionToUpdate is the direction vector to update with the result
  82393. * @param particle is the particle we are computed the direction for
  82394. */
  82395. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82396. /**
  82397. * Called by the particle System when the position is computed for the created particle.
  82398. * @param worldMatrix is the world matrix of the particle system
  82399. * @param positionToUpdate is the position vector to update with the result
  82400. * @param particle is the particle we are computed the position for
  82401. */
  82402. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82403. /**
  82404. * Clones the current emitter and returns a copy of it
  82405. * @returns the new emitter
  82406. */
  82407. clone(): SphereParticleEmitter;
  82408. /**
  82409. * Called by the GPUParticleSystem to setup the update shader
  82410. * @param effect defines the update shader
  82411. */
  82412. applyToShader(effect: Effect): void;
  82413. /**
  82414. * Returns a string to use to update the GPU particles update shader
  82415. * @returns a string containng the defines string
  82416. */
  82417. getEffectDefines(): string;
  82418. /**
  82419. * Returns the string "SphereParticleEmitter"
  82420. * @returns a string containing the class name
  82421. */
  82422. getClassName(): string;
  82423. /**
  82424. * Serializes the particle system to a JSON object.
  82425. * @returns the JSON object
  82426. */
  82427. serialize(): any;
  82428. /**
  82429. * Parse properties from a JSON object
  82430. * @param serializationObject defines the JSON object
  82431. */
  82432. parse(serializationObject: any): void;
  82433. }
  82434. /**
  82435. * Particle emitter emitting particles from the inside of a sphere.
  82436. * It emits the particles randomly between two vectors.
  82437. */
  82438. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82439. /**
  82440. * The min limit of the emission direction.
  82441. */
  82442. direction1: Vector3;
  82443. /**
  82444. * The max limit of the emission direction.
  82445. */
  82446. direction2: Vector3;
  82447. /**
  82448. * Creates a new instance SphereDirectedParticleEmitter
  82449. * @param radius the radius of the emission sphere (1 by default)
  82450. * @param direction1 the min limit of the emission direction (up vector by default)
  82451. * @param direction2 the max limit of the emission direction (up vector by default)
  82452. */
  82453. constructor(radius?: number,
  82454. /**
  82455. * The min limit of the emission direction.
  82456. */
  82457. direction1?: Vector3,
  82458. /**
  82459. * The max limit of the emission direction.
  82460. */
  82461. direction2?: Vector3);
  82462. /**
  82463. * Called by the particle System when the direction is computed for the created particle.
  82464. * @param worldMatrix is the world matrix of the particle system
  82465. * @param directionToUpdate is the direction vector to update with the result
  82466. * @param particle is the particle we are computed the direction for
  82467. */
  82468. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82469. /**
  82470. * Clones the current emitter and returns a copy of it
  82471. * @returns the new emitter
  82472. */
  82473. clone(): SphereDirectedParticleEmitter;
  82474. /**
  82475. * Called by the GPUParticleSystem to setup the update shader
  82476. * @param effect defines the update shader
  82477. */
  82478. applyToShader(effect: Effect): void;
  82479. /**
  82480. * Returns a string to use to update the GPU particles update shader
  82481. * @returns a string containng the defines string
  82482. */
  82483. getEffectDefines(): string;
  82484. /**
  82485. * Returns the string "SphereDirectedParticleEmitter"
  82486. * @returns a string containing the class name
  82487. */
  82488. getClassName(): string;
  82489. /**
  82490. * Serializes the particle system to a JSON object.
  82491. * @returns the JSON object
  82492. */
  82493. serialize(): any;
  82494. /**
  82495. * Parse properties from a JSON object
  82496. * @param serializationObject defines the JSON object
  82497. */
  82498. parse(serializationObject: any): void;
  82499. }
  82500. }
  82501. declare module BABYLON {
  82502. /**
  82503. * Interface representing a particle system in Babylon.js.
  82504. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82505. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82506. */
  82507. export interface IParticleSystem {
  82508. /**
  82509. * List of animations used by the particle system.
  82510. */
  82511. animations: Animation[];
  82512. /**
  82513. * The id of the Particle system.
  82514. */
  82515. id: string;
  82516. /**
  82517. * The name of the Particle system.
  82518. */
  82519. name: string;
  82520. /**
  82521. * The emitter represents the Mesh or position we are attaching the particle system to.
  82522. */
  82523. emitter: Nullable<AbstractMesh | Vector3>;
  82524. /**
  82525. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82526. */
  82527. isBillboardBased: boolean;
  82528. /**
  82529. * The rendering group used by the Particle system to chose when to render.
  82530. */
  82531. renderingGroupId: number;
  82532. /**
  82533. * The layer mask we are rendering the particles through.
  82534. */
  82535. layerMask: number;
  82536. /**
  82537. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82538. */
  82539. updateSpeed: number;
  82540. /**
  82541. * The amount of time the particle system is running (depends of the overall update speed).
  82542. */
  82543. targetStopDuration: number;
  82544. /**
  82545. * The texture used to render each particle. (this can be a spritesheet)
  82546. */
  82547. particleTexture: Nullable<Texture>;
  82548. /**
  82549. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82550. */
  82551. blendMode: number;
  82552. /**
  82553. * Minimum life time of emitting particles.
  82554. */
  82555. minLifeTime: number;
  82556. /**
  82557. * Maximum life time of emitting particles.
  82558. */
  82559. maxLifeTime: number;
  82560. /**
  82561. * Minimum Size of emitting particles.
  82562. */
  82563. minSize: number;
  82564. /**
  82565. * Maximum Size of emitting particles.
  82566. */
  82567. maxSize: number;
  82568. /**
  82569. * Minimum scale of emitting particles on X axis.
  82570. */
  82571. minScaleX: number;
  82572. /**
  82573. * Maximum scale of emitting particles on X axis.
  82574. */
  82575. maxScaleX: number;
  82576. /**
  82577. * Minimum scale of emitting particles on Y axis.
  82578. */
  82579. minScaleY: number;
  82580. /**
  82581. * Maximum scale of emitting particles on Y axis.
  82582. */
  82583. maxScaleY: number;
  82584. /**
  82585. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82586. */
  82587. color1: Color4;
  82588. /**
  82589. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82590. */
  82591. color2: Color4;
  82592. /**
  82593. * Color the particle will have at the end of its lifetime.
  82594. */
  82595. colorDead: Color4;
  82596. /**
  82597. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82598. */
  82599. emitRate: number;
  82600. /**
  82601. * You can use gravity if you want to give an orientation to your particles.
  82602. */
  82603. gravity: Vector3;
  82604. /**
  82605. * Minimum power of emitting particles.
  82606. */
  82607. minEmitPower: number;
  82608. /**
  82609. * Maximum power of emitting particles.
  82610. */
  82611. maxEmitPower: number;
  82612. /**
  82613. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82614. */
  82615. minAngularSpeed: number;
  82616. /**
  82617. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82618. */
  82619. maxAngularSpeed: number;
  82620. /**
  82621. * Gets or sets the minimal initial rotation in radians.
  82622. */
  82623. minInitialRotation: number;
  82624. /**
  82625. * Gets or sets the maximal initial rotation in radians.
  82626. */
  82627. maxInitialRotation: number;
  82628. /**
  82629. * The particle emitter type defines the emitter used by the particle system.
  82630. * It can be for example box, sphere, or cone...
  82631. */
  82632. particleEmitterType: Nullable<IParticleEmitterType>;
  82633. /**
  82634. * Defines the delay in milliseconds before starting the system (0 by default)
  82635. */
  82636. startDelay: number;
  82637. /**
  82638. * 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
  82639. */
  82640. preWarmCycles: number;
  82641. /**
  82642. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82643. */
  82644. preWarmStepOffset: number;
  82645. /**
  82646. * 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)
  82647. */
  82648. spriteCellChangeSpeed: number;
  82649. /**
  82650. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82651. */
  82652. startSpriteCellID: number;
  82653. /**
  82654. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82655. */
  82656. endSpriteCellID: number;
  82657. /**
  82658. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82659. */
  82660. spriteCellWidth: number;
  82661. /**
  82662. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82663. */
  82664. spriteCellHeight: number;
  82665. /**
  82666. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82667. */
  82668. spriteRandomStartCell: boolean;
  82669. /**
  82670. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82671. */
  82672. isAnimationSheetEnabled: boolean;
  82673. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82674. translationPivot: Vector2;
  82675. /**
  82676. * Gets or sets a texture used to add random noise to particle positions
  82677. */
  82678. noiseTexture: Nullable<BaseTexture>;
  82679. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82680. noiseStrength: Vector3;
  82681. /**
  82682. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82683. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82684. */
  82685. billboardMode: number;
  82686. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82687. limitVelocityDamping: number;
  82688. /**
  82689. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82690. */
  82691. beginAnimationOnStart: boolean;
  82692. /**
  82693. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82694. */
  82695. beginAnimationFrom: number;
  82696. /**
  82697. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82698. */
  82699. beginAnimationTo: number;
  82700. /**
  82701. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82702. */
  82703. beginAnimationLoop: boolean;
  82704. /**
  82705. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82706. */
  82707. disposeOnStop: boolean;
  82708. /**
  82709. * Gets the maximum number of particles active at the same time.
  82710. * @returns The max number of active particles.
  82711. */
  82712. getCapacity(): number;
  82713. /**
  82714. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82715. * @returns True if it has been started, otherwise false.
  82716. */
  82717. isStarted(): boolean;
  82718. /**
  82719. * Animates the particle system for this frame.
  82720. */
  82721. animate(): void;
  82722. /**
  82723. * Renders the particle system in its current state.
  82724. * @returns the current number of particles
  82725. */
  82726. render(): number;
  82727. /**
  82728. * Dispose the particle system and frees its associated resources.
  82729. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82730. */
  82731. dispose(disposeTexture?: boolean): void;
  82732. /**
  82733. * Clones the particle system.
  82734. * @param name The name of the cloned object
  82735. * @param newEmitter The new emitter to use
  82736. * @returns the cloned particle system
  82737. */
  82738. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82739. /**
  82740. * Serializes the particle system to a JSON object.
  82741. * @returns the JSON object
  82742. */
  82743. serialize(): any;
  82744. /**
  82745. * Rebuild the particle system
  82746. */
  82747. rebuild(): void;
  82748. /**
  82749. * Starts the particle system and begins to emit
  82750. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82751. */
  82752. start(delay?: number): void;
  82753. /**
  82754. * Stops the particle system.
  82755. */
  82756. stop(): void;
  82757. /**
  82758. * Remove all active particles
  82759. */
  82760. reset(): void;
  82761. /**
  82762. * Is this system ready to be used/rendered
  82763. * @return true if the system is ready
  82764. */
  82765. isReady(): boolean;
  82766. /**
  82767. * Adds a new color gradient
  82768. * @param gradient defines the gradient to use (between 0 and 1)
  82769. * @param color1 defines the color to affect to the specified gradient
  82770. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82771. * @returns the current particle system
  82772. */
  82773. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82774. /**
  82775. * Remove a specific color gradient
  82776. * @param gradient defines the gradient to remove
  82777. * @returns the current particle system
  82778. */
  82779. removeColorGradient(gradient: number): IParticleSystem;
  82780. /**
  82781. * Adds a new size gradient
  82782. * @param gradient defines the gradient to use (between 0 and 1)
  82783. * @param factor defines the size factor to affect to the specified gradient
  82784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82785. * @returns the current particle system
  82786. */
  82787. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82788. /**
  82789. * Remove a specific size gradient
  82790. * @param gradient defines the gradient to remove
  82791. * @returns the current particle system
  82792. */
  82793. removeSizeGradient(gradient: number): IParticleSystem;
  82794. /**
  82795. * Gets the current list of color gradients.
  82796. * You must use addColorGradient and removeColorGradient to udpate this list
  82797. * @returns the list of color gradients
  82798. */
  82799. getColorGradients(): Nullable<Array<ColorGradient>>;
  82800. /**
  82801. * Gets the current list of size gradients.
  82802. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82803. * @returns the list of size gradients
  82804. */
  82805. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82806. /**
  82807. * Gets the current list of angular speed gradients.
  82808. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82809. * @returns the list of angular speed gradients
  82810. */
  82811. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82812. /**
  82813. * Adds a new angular speed gradient
  82814. * @param gradient defines the gradient to use (between 0 and 1)
  82815. * @param factor defines the angular speed to affect to the specified gradient
  82816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82817. * @returns the current particle system
  82818. */
  82819. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82820. /**
  82821. * Remove a specific angular speed gradient
  82822. * @param gradient defines the gradient to remove
  82823. * @returns the current particle system
  82824. */
  82825. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82826. /**
  82827. * Gets the current list of velocity gradients.
  82828. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82829. * @returns the list of velocity gradients
  82830. */
  82831. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82832. /**
  82833. * Adds a new velocity gradient
  82834. * @param gradient defines the gradient to use (between 0 and 1)
  82835. * @param factor defines the velocity to affect to the specified gradient
  82836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82837. * @returns the current particle system
  82838. */
  82839. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82840. /**
  82841. * Remove a specific velocity gradient
  82842. * @param gradient defines the gradient to remove
  82843. * @returns the current particle system
  82844. */
  82845. removeVelocityGradient(gradient: number): IParticleSystem;
  82846. /**
  82847. * Gets the current list of limit velocity gradients.
  82848. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82849. * @returns the list of limit velocity gradients
  82850. */
  82851. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82852. /**
  82853. * Adds a new limit velocity gradient
  82854. * @param gradient defines the gradient to use (between 0 and 1)
  82855. * @param factor defines the limit velocity to affect to the specified gradient
  82856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82857. * @returns the current particle system
  82858. */
  82859. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82860. /**
  82861. * Remove a specific limit velocity gradient
  82862. * @param gradient defines the gradient to remove
  82863. * @returns the current particle system
  82864. */
  82865. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82866. /**
  82867. * Adds a new drag gradient
  82868. * @param gradient defines the gradient to use (between 0 and 1)
  82869. * @param factor defines the drag to affect to the specified gradient
  82870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82871. * @returns the current particle system
  82872. */
  82873. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82874. /**
  82875. * Remove a specific drag gradient
  82876. * @param gradient defines the gradient to remove
  82877. * @returns the current particle system
  82878. */
  82879. removeDragGradient(gradient: number): IParticleSystem;
  82880. /**
  82881. * Gets the current list of drag gradients.
  82882. * You must use addDragGradient and removeDragGradient to udpate this list
  82883. * @returns the list of drag gradients
  82884. */
  82885. getDragGradients(): Nullable<Array<FactorGradient>>;
  82886. /**
  82887. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82888. * @param gradient defines the gradient to use (between 0 and 1)
  82889. * @param factor defines the emit rate to affect to the specified gradient
  82890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82891. * @returns the current particle system
  82892. */
  82893. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82894. /**
  82895. * Remove a specific emit rate gradient
  82896. * @param gradient defines the gradient to remove
  82897. * @returns the current particle system
  82898. */
  82899. removeEmitRateGradient(gradient: number): IParticleSystem;
  82900. /**
  82901. * Gets the current list of emit rate gradients.
  82902. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82903. * @returns the list of emit rate gradients
  82904. */
  82905. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82906. /**
  82907. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82908. * @param gradient defines the gradient to use (between 0 and 1)
  82909. * @param factor defines the start size to affect to the specified gradient
  82910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82911. * @returns the current particle system
  82912. */
  82913. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82914. /**
  82915. * Remove a specific start size gradient
  82916. * @param gradient defines the gradient to remove
  82917. * @returns the current particle system
  82918. */
  82919. removeStartSizeGradient(gradient: number): IParticleSystem;
  82920. /**
  82921. * Gets the current list of start size gradients.
  82922. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82923. * @returns the list of start size gradients
  82924. */
  82925. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82926. /**
  82927. * Adds a new life time gradient
  82928. * @param gradient defines the gradient to use (between 0 and 1)
  82929. * @param factor defines the life time factor to affect to the specified gradient
  82930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82931. * @returns the current particle system
  82932. */
  82933. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82934. /**
  82935. * Remove a specific life time gradient
  82936. * @param gradient defines the gradient to remove
  82937. * @returns the current particle system
  82938. */
  82939. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82940. /**
  82941. * Gets the current list of life time gradients.
  82942. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82943. * @returns the list of life time gradients
  82944. */
  82945. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82946. /**
  82947. * Gets the current list of color gradients.
  82948. * You must use addColorGradient and removeColorGradient to udpate this list
  82949. * @returns the list of color gradients
  82950. */
  82951. getColorGradients(): Nullable<Array<ColorGradient>>;
  82952. /**
  82953. * Adds a new ramp gradient used to remap particle colors
  82954. * @param gradient defines the gradient to use (between 0 and 1)
  82955. * @param color defines the color to affect to the specified gradient
  82956. * @returns the current particle system
  82957. */
  82958. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82959. /**
  82960. * Gets the current list of ramp gradients.
  82961. * You must use addRampGradient and removeRampGradient to udpate this list
  82962. * @returns the list of ramp gradients
  82963. */
  82964. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82965. /** Gets or sets a boolean indicating that ramp gradients must be used
  82966. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82967. */
  82968. useRampGradients: boolean;
  82969. /**
  82970. * Adds a new color remap gradient
  82971. * @param gradient defines the gradient to use (between 0 and 1)
  82972. * @param min defines the color remap minimal range
  82973. * @param max defines the color remap maximal range
  82974. * @returns the current particle system
  82975. */
  82976. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82977. /**
  82978. * Gets the current list of color remap gradients.
  82979. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82980. * @returns the list of color remap gradients
  82981. */
  82982. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82983. /**
  82984. * Adds a new alpha remap gradient
  82985. * @param gradient defines the gradient to use (between 0 and 1)
  82986. * @param min defines the alpha remap minimal range
  82987. * @param max defines the alpha remap maximal range
  82988. * @returns the current particle system
  82989. */
  82990. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82991. /**
  82992. * Gets the current list of alpha remap gradients.
  82993. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82994. * @returns the list of alpha remap gradients
  82995. */
  82996. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82997. /**
  82998. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82999. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83000. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83001. * @returns the emitter
  83002. */
  83003. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83004. /**
  83005. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83006. * @param radius The radius of the hemisphere to emit from
  83007. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83008. * @returns the emitter
  83009. */
  83010. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83011. /**
  83012. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83013. * @param radius The radius of the sphere to emit from
  83014. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83015. * @returns the emitter
  83016. */
  83017. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83018. /**
  83019. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83020. * @param radius The radius of the sphere to emit from
  83021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83023. * @returns the emitter
  83024. */
  83025. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83026. /**
  83027. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83028. * @param radius The radius of the emission cylinder
  83029. * @param height The height of the emission cylinder
  83030. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83031. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83032. * @returns the emitter
  83033. */
  83034. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83035. /**
  83036. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83037. * @param radius The radius of the cylinder to emit from
  83038. * @param height The height of the emission cylinder
  83039. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83042. * @returns the emitter
  83043. */
  83044. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83045. /**
  83046. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83047. * @param radius The radius of the cone to emit from
  83048. * @param angle The base angle of the cone
  83049. * @returns the emitter
  83050. */
  83051. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83052. /**
  83053. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83056. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83057. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83058. * @returns the emitter
  83059. */
  83060. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83061. /**
  83062. * Get hosting scene
  83063. * @returns the scene
  83064. */
  83065. getScene(): Scene;
  83066. }
  83067. }
  83068. declare module BABYLON {
  83069. /**
  83070. * Creates an instance based on a source mesh.
  83071. */
  83072. export class InstancedMesh extends AbstractMesh {
  83073. private _sourceMesh;
  83074. private _currentLOD;
  83075. /** @hidden */
  83076. _indexInSourceMeshInstanceArray: number;
  83077. constructor(name: string, source: Mesh);
  83078. /**
  83079. * Returns the string "InstancedMesh".
  83080. */
  83081. getClassName(): string;
  83082. /** Gets the list of lights affecting that mesh */
  83083. readonly lightSources: Light[];
  83084. _resyncLightSources(): void;
  83085. _resyncLighSource(light: Light): void;
  83086. _removeLightSource(light: Light): void;
  83087. /**
  83088. * If the source mesh receives shadows
  83089. */
  83090. readonly receiveShadows: boolean;
  83091. /**
  83092. * The material of the source mesh
  83093. */
  83094. readonly material: Nullable<Material>;
  83095. /**
  83096. * Visibility of the source mesh
  83097. */
  83098. readonly visibility: number;
  83099. /**
  83100. * Skeleton of the source mesh
  83101. */
  83102. readonly skeleton: Nullable<Skeleton>;
  83103. /**
  83104. * Rendering ground id of the source mesh
  83105. */
  83106. renderingGroupId: number;
  83107. /**
  83108. * Returns the total number of vertices (integer).
  83109. */
  83110. getTotalVertices(): number;
  83111. /**
  83112. * Returns a positive integer : the total number of indices in this mesh geometry.
  83113. * @returns the numner of indices or zero if the mesh has no geometry.
  83114. */
  83115. getTotalIndices(): number;
  83116. /**
  83117. * The source mesh of the instance
  83118. */
  83119. readonly sourceMesh: Mesh;
  83120. /**
  83121. * Is this node ready to be used/rendered
  83122. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83123. * @return {boolean} is it ready
  83124. */
  83125. isReady(completeCheck?: boolean): boolean;
  83126. /**
  83127. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83128. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83129. * @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.
  83130. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83131. */
  83132. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83133. /**
  83134. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83135. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83136. * The `data` are either a numeric array either a Float32Array.
  83137. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83138. * 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).
  83139. * Note that a new underlying VertexBuffer object is created each call.
  83140. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83141. *
  83142. * Possible `kind` values :
  83143. * - VertexBuffer.PositionKind
  83144. * - VertexBuffer.UVKind
  83145. * - VertexBuffer.UV2Kind
  83146. * - VertexBuffer.UV3Kind
  83147. * - VertexBuffer.UV4Kind
  83148. * - VertexBuffer.UV5Kind
  83149. * - VertexBuffer.UV6Kind
  83150. * - VertexBuffer.ColorKind
  83151. * - VertexBuffer.MatricesIndicesKind
  83152. * - VertexBuffer.MatricesIndicesExtraKind
  83153. * - VertexBuffer.MatricesWeightsKind
  83154. * - VertexBuffer.MatricesWeightsExtraKind
  83155. *
  83156. * Returns the Mesh.
  83157. */
  83158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83159. /**
  83160. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83161. * If the mesh has no geometry, it is simply returned as it is.
  83162. * The `data` are either a numeric array either a Float32Array.
  83163. * No new underlying VertexBuffer object is created.
  83164. * 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.
  83165. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83166. *
  83167. * Possible `kind` values :
  83168. * - VertexBuffer.PositionKind
  83169. * - VertexBuffer.UVKind
  83170. * - VertexBuffer.UV2Kind
  83171. * - VertexBuffer.UV3Kind
  83172. * - VertexBuffer.UV4Kind
  83173. * - VertexBuffer.UV5Kind
  83174. * - VertexBuffer.UV6Kind
  83175. * - VertexBuffer.ColorKind
  83176. * - VertexBuffer.MatricesIndicesKind
  83177. * - VertexBuffer.MatricesIndicesExtraKind
  83178. * - VertexBuffer.MatricesWeightsKind
  83179. * - VertexBuffer.MatricesWeightsExtraKind
  83180. *
  83181. * Returns the Mesh.
  83182. */
  83183. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83184. /**
  83185. * Sets the mesh indices.
  83186. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83187. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83188. * This method creates a new index buffer each call.
  83189. * Returns the Mesh.
  83190. */
  83191. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83192. /**
  83193. * Boolean : True if the mesh owns the requested kind of data.
  83194. */
  83195. isVerticesDataPresent(kind: string): boolean;
  83196. /**
  83197. * Returns an array of indices (IndicesArray).
  83198. */
  83199. getIndices(): Nullable<IndicesArray>;
  83200. readonly _positions: Nullable<Vector3[]>;
  83201. /**
  83202. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83203. * This means the mesh underlying bounding box and sphere are recomputed.
  83204. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83205. * @returns the current mesh
  83206. */
  83207. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83208. /** @hidden */
  83209. _preActivate(): InstancedMesh;
  83210. /** @hidden */
  83211. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83212. /** @hidden */
  83213. _postActivate(): void;
  83214. getWorldMatrix(): Matrix;
  83215. readonly isAnInstance: boolean;
  83216. /**
  83217. * Returns the current associated LOD AbstractMesh.
  83218. */
  83219. getLOD(camera: Camera): AbstractMesh;
  83220. /** @hidden */
  83221. _syncSubMeshes(): InstancedMesh;
  83222. /** @hidden */
  83223. _generatePointsArray(): boolean;
  83224. /**
  83225. * Creates a new InstancedMesh from the current mesh.
  83226. * - name (string) : the cloned mesh name
  83227. * - newParent (optional Node) : the optional Node to parent the clone to.
  83228. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83229. *
  83230. * Returns the clone.
  83231. */
  83232. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  83233. /**
  83234. * Disposes the InstancedMesh.
  83235. * Returns nothing.
  83236. */
  83237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83238. }
  83239. }
  83240. declare module BABYLON {
  83241. /**
  83242. * Defines the options associated with the creation of a shader material.
  83243. */
  83244. export interface IShaderMaterialOptions {
  83245. /**
  83246. * Does the material work in alpha blend mode
  83247. */
  83248. needAlphaBlending: boolean;
  83249. /**
  83250. * Does the material work in alpha test mode
  83251. */
  83252. needAlphaTesting: boolean;
  83253. /**
  83254. * The list of attribute names used in the shader
  83255. */
  83256. attributes: string[];
  83257. /**
  83258. * The list of unifrom names used in the shader
  83259. */
  83260. uniforms: string[];
  83261. /**
  83262. * The list of UBO names used in the shader
  83263. */
  83264. uniformBuffers: string[];
  83265. /**
  83266. * The list of sampler names used in the shader
  83267. */
  83268. samplers: string[];
  83269. /**
  83270. * The list of defines used in the shader
  83271. */
  83272. defines: string[];
  83273. }
  83274. /**
  83275. * 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.
  83276. *
  83277. * This returned material effects how the mesh will look based on the code in the shaders.
  83278. *
  83279. * @see http://doc.babylonjs.com/how_to/shader_material
  83280. */
  83281. export class ShaderMaterial extends Material {
  83282. private _shaderPath;
  83283. private _options;
  83284. private _textures;
  83285. private _textureArrays;
  83286. private _floats;
  83287. private _ints;
  83288. private _floatsArrays;
  83289. private _colors3;
  83290. private _colors3Arrays;
  83291. private _colors4;
  83292. private _colors4Arrays;
  83293. private _vectors2;
  83294. private _vectors3;
  83295. private _vectors4;
  83296. private _matrices;
  83297. private _matrices3x3;
  83298. private _matrices2x2;
  83299. private _vectors2Arrays;
  83300. private _vectors3Arrays;
  83301. private _vectors4Arrays;
  83302. private _cachedWorldViewMatrix;
  83303. private _cachedWorldViewProjectionMatrix;
  83304. private _renderId;
  83305. /**
  83306. * Instantiate a new shader material.
  83307. * 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.
  83308. * This returned material effects how the mesh will look based on the code in the shaders.
  83309. * @see http://doc.babylonjs.com/how_to/shader_material
  83310. * @param name Define the name of the material in the scene
  83311. * @param scene Define the scene the material belongs to
  83312. * @param shaderPath Defines the route to the shader code in one of three ways:
  83313. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83314. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83315. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83316. * @param options Define the options used to create the shader
  83317. */
  83318. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83319. /**
  83320. * Gets the options used to compile the shader.
  83321. * They can be modified to trigger a new compilation
  83322. */
  83323. readonly options: IShaderMaterialOptions;
  83324. /**
  83325. * Gets the current class name of the material e.g. "ShaderMaterial"
  83326. * Mainly use in serialization.
  83327. * @returns the class name
  83328. */
  83329. getClassName(): string;
  83330. /**
  83331. * Specifies if the material will require alpha blending
  83332. * @returns a boolean specifying if alpha blending is needed
  83333. */
  83334. needAlphaBlending(): boolean;
  83335. /**
  83336. * Specifies if this material should be rendered in alpha test mode
  83337. * @returns a boolean specifying if an alpha test is needed.
  83338. */
  83339. needAlphaTesting(): boolean;
  83340. private _checkUniform;
  83341. /**
  83342. * Set a texture in the shader.
  83343. * @param name Define the name of the uniform samplers as defined in the shader
  83344. * @param texture Define the texture to bind to this sampler
  83345. * @return the material itself allowing "fluent" like uniform updates
  83346. */
  83347. setTexture(name: string, texture: Texture): ShaderMaterial;
  83348. /**
  83349. * Set a texture array in the shader.
  83350. * @param name Define the name of the uniform sampler array as defined in the shader
  83351. * @param textures Define the list of textures to bind to this sampler
  83352. * @return the material itself allowing "fluent" like uniform updates
  83353. */
  83354. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83355. /**
  83356. * Set a float in the shader.
  83357. * @param name Define the name of the uniform as defined in the shader
  83358. * @param value Define the value to give to the uniform
  83359. * @return the material itself allowing "fluent" like uniform updates
  83360. */
  83361. setFloat(name: string, value: number): ShaderMaterial;
  83362. /**
  83363. * Set a int in the shader.
  83364. * @param name Define the name of the uniform as defined in the shader
  83365. * @param value Define the value to give to the uniform
  83366. * @return the material itself allowing "fluent" like uniform updates
  83367. */
  83368. setInt(name: string, value: number): ShaderMaterial;
  83369. /**
  83370. * Set an array of floats in the shader.
  83371. * @param name Define the name of the uniform as defined in the shader
  83372. * @param value Define the value to give to the uniform
  83373. * @return the material itself allowing "fluent" like uniform updates
  83374. */
  83375. setFloats(name: string, value: number[]): ShaderMaterial;
  83376. /**
  83377. * Set a vec3 in the shader from a Color3.
  83378. * @param name Define the name of the uniform as defined in the shader
  83379. * @param value Define the value to give to the uniform
  83380. * @return the material itself allowing "fluent" like uniform updates
  83381. */
  83382. setColor3(name: string, value: Color3): ShaderMaterial;
  83383. /**
  83384. * Set a vec3 array in the shader from a Color3 array.
  83385. * @param name Define the name of the uniform as defined in the shader
  83386. * @param value Define the value to give to the uniform
  83387. * @return the material itself allowing "fluent" like uniform updates
  83388. */
  83389. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83390. /**
  83391. * Set a vec4 in the shader from a Color4.
  83392. * @param name Define the name of the uniform as defined in the shader
  83393. * @param value Define the value to give to the uniform
  83394. * @return the material itself allowing "fluent" like uniform updates
  83395. */
  83396. setColor4(name: string, value: Color4): ShaderMaterial;
  83397. /**
  83398. * Set a vec4 array in the shader from a Color4 array.
  83399. * @param name Define the name of the uniform as defined in the shader
  83400. * @param value Define the value to give to the uniform
  83401. * @return the material itself allowing "fluent" like uniform updates
  83402. */
  83403. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83404. /**
  83405. * Set a vec2 in the shader from a Vector2.
  83406. * @param name Define the name of the uniform as defined in the shader
  83407. * @param value Define the value to give to the uniform
  83408. * @return the material itself allowing "fluent" like uniform updates
  83409. */
  83410. setVector2(name: string, value: Vector2): ShaderMaterial;
  83411. /**
  83412. * Set a vec3 in the shader from a Vector3.
  83413. * @param name Define the name of the uniform as defined in the shader
  83414. * @param value Define the value to give to the uniform
  83415. * @return the material itself allowing "fluent" like uniform updates
  83416. */
  83417. setVector3(name: string, value: Vector3): ShaderMaterial;
  83418. /**
  83419. * Set a vec4 in the shader from a Vector4.
  83420. * @param name Define the name of the uniform as defined in the shader
  83421. * @param value Define the value to give to the uniform
  83422. * @return the material itself allowing "fluent" like uniform updates
  83423. */
  83424. setVector4(name: string, value: Vector4): ShaderMaterial;
  83425. /**
  83426. * Set a mat4 in the shader from a Matrix.
  83427. * @param name Define the name of the uniform as defined in the shader
  83428. * @param value Define the value to give to the uniform
  83429. * @return the material itself allowing "fluent" like uniform updates
  83430. */
  83431. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83432. /**
  83433. * Set a mat3 in the shader from a Float32Array.
  83434. * @param name Define the name of the uniform as defined in the shader
  83435. * @param value Define the value to give to the uniform
  83436. * @return the material itself allowing "fluent" like uniform updates
  83437. */
  83438. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83439. /**
  83440. * Set a mat2 in the shader from a Float32Array.
  83441. * @param name Define the name of the uniform as defined in the shader
  83442. * @param value Define the value to give to the uniform
  83443. * @return the material itself allowing "fluent" like uniform updates
  83444. */
  83445. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83446. /**
  83447. * Set a vec2 array in the shader from a number array.
  83448. * @param name Define the name of the uniform as defined in the shader
  83449. * @param value Define the value to give to the uniform
  83450. * @return the material itself allowing "fluent" like uniform updates
  83451. */
  83452. setArray2(name: string, value: number[]): ShaderMaterial;
  83453. /**
  83454. * Set a vec3 array in the shader from a number array.
  83455. * @param name Define the name of the uniform as defined in the shader
  83456. * @param value Define the value to give to the uniform
  83457. * @return the material itself allowing "fluent" like uniform updates
  83458. */
  83459. setArray3(name: string, value: number[]): ShaderMaterial;
  83460. /**
  83461. * Set a vec4 array in the shader from a number array.
  83462. * @param name Define the name of the uniform as defined in the shader
  83463. * @param value Define the value to give to the uniform
  83464. * @return the material itself allowing "fluent" like uniform updates
  83465. */
  83466. setArray4(name: string, value: number[]): ShaderMaterial;
  83467. private _checkCache;
  83468. /**
  83469. * Specifies that the submesh is ready to be used
  83470. * @param mesh defines the mesh to check
  83471. * @param subMesh defines which submesh to check
  83472. * @param useInstances specifies that instances should be used
  83473. * @returns a boolean indicating that the submesh is ready or not
  83474. */
  83475. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83476. /**
  83477. * Checks if the material is ready to render the requested mesh
  83478. * @param mesh Define the mesh to render
  83479. * @param useInstances Define whether or not the material is used with instances
  83480. * @returns true if ready, otherwise false
  83481. */
  83482. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83483. /**
  83484. * Binds the world matrix to the material
  83485. * @param world defines the world transformation matrix
  83486. */
  83487. bindOnlyWorldMatrix(world: Matrix): void;
  83488. /**
  83489. * Binds the material to the mesh
  83490. * @param world defines the world transformation matrix
  83491. * @param mesh defines the mesh to bind the material to
  83492. */
  83493. bind(world: Matrix, mesh?: Mesh): void;
  83494. /**
  83495. * Gets the active textures from the material
  83496. * @returns an array of textures
  83497. */
  83498. getActiveTextures(): BaseTexture[];
  83499. /**
  83500. * Specifies if the material uses a texture
  83501. * @param texture defines the texture to check against the material
  83502. * @returns a boolean specifying if the material uses the texture
  83503. */
  83504. hasTexture(texture: BaseTexture): boolean;
  83505. /**
  83506. * Makes a duplicate of the material, and gives it a new name
  83507. * @param name defines the new name for the duplicated material
  83508. * @returns the cloned material
  83509. */
  83510. clone(name: string): ShaderMaterial;
  83511. /**
  83512. * Disposes the material
  83513. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83514. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83515. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83516. */
  83517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83518. /**
  83519. * Serializes this material in a JSON representation
  83520. * @returns the serialized material object
  83521. */
  83522. serialize(): any;
  83523. /**
  83524. * Creates a shader material from parsed shader material data
  83525. * @param source defines the JSON represnetation of the material
  83526. * @param scene defines the hosting scene
  83527. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83528. * @returns a new material
  83529. */
  83530. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83531. }
  83532. }
  83533. declare module BABYLON {
  83534. /** @hidden */
  83535. export var colorPixelShader: {
  83536. name: string;
  83537. shader: string;
  83538. };
  83539. }
  83540. declare module BABYLON {
  83541. /** @hidden */
  83542. export var colorVertexShader: {
  83543. name: string;
  83544. shader: string;
  83545. };
  83546. }
  83547. declare module BABYLON {
  83548. /**
  83549. * Line mesh
  83550. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83551. */
  83552. export class LinesMesh extends Mesh {
  83553. /**
  83554. * If vertex color should be applied to the mesh
  83555. */
  83556. readonly useVertexColor?: boolean | undefined;
  83557. /**
  83558. * If vertex alpha should be applied to the mesh
  83559. */
  83560. readonly useVertexAlpha?: boolean | undefined;
  83561. /**
  83562. * Color of the line (Default: White)
  83563. */
  83564. color: Color3;
  83565. /**
  83566. * Alpha of the line (Default: 1)
  83567. */
  83568. alpha: number;
  83569. /**
  83570. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83571. * This margin is expressed in world space coordinates, so its value may vary.
  83572. * Default value is 0.1
  83573. */
  83574. intersectionThreshold: number;
  83575. private _colorShader;
  83576. private color4;
  83577. /**
  83578. * Creates a new LinesMesh
  83579. * @param name defines the name
  83580. * @param scene defines the hosting scene
  83581. * @param parent defines the parent mesh if any
  83582. * @param source defines the optional source LinesMesh used to clone data from
  83583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83584. * When false, achieved by calling a clone(), also passing False.
  83585. * This will make creation of children, recursive.
  83586. * @param useVertexColor defines if this LinesMesh supports vertex color
  83587. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83588. */
  83589. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83590. /**
  83591. * If vertex color should be applied to the mesh
  83592. */
  83593. useVertexColor?: boolean | undefined,
  83594. /**
  83595. * If vertex alpha should be applied to the mesh
  83596. */
  83597. useVertexAlpha?: boolean | undefined);
  83598. private _addClipPlaneDefine;
  83599. private _removeClipPlaneDefine;
  83600. isReady(): boolean;
  83601. /**
  83602. * Returns the string "LineMesh"
  83603. */
  83604. getClassName(): string;
  83605. /**
  83606. * @hidden
  83607. */
  83608. /**
  83609. * @hidden
  83610. */
  83611. material: Material;
  83612. /**
  83613. * @hidden
  83614. */
  83615. readonly checkCollisions: boolean;
  83616. /** @hidden */
  83617. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83618. /** @hidden */
  83619. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83620. /**
  83621. * Disposes of the line mesh
  83622. * @param doNotRecurse If children should be disposed
  83623. */
  83624. dispose(doNotRecurse?: boolean): void;
  83625. /**
  83626. * Returns a new LineMesh object cloned from the current one.
  83627. */
  83628. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83629. /**
  83630. * Creates a new InstancedLinesMesh object from the mesh model.
  83631. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83632. * @param name defines the name of the new instance
  83633. * @returns a new InstancedLinesMesh
  83634. */
  83635. createInstance(name: string): InstancedLinesMesh;
  83636. }
  83637. /**
  83638. * Creates an instance based on a source LinesMesh
  83639. */
  83640. export class InstancedLinesMesh extends InstancedMesh {
  83641. /**
  83642. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83643. * This margin is expressed in world space coordinates, so its value may vary.
  83644. * Initilized with the intersectionThreshold value of the source LinesMesh
  83645. */
  83646. intersectionThreshold: number;
  83647. constructor(name: string, source: LinesMesh);
  83648. /**
  83649. * Returns the string "InstancedLinesMesh".
  83650. */
  83651. getClassName(): string;
  83652. }
  83653. }
  83654. declare module BABYLON {
  83655. /** @hidden */
  83656. export var linePixelShader: {
  83657. name: string;
  83658. shader: string;
  83659. };
  83660. }
  83661. declare module BABYLON {
  83662. /** @hidden */
  83663. export var lineVertexShader: {
  83664. name: string;
  83665. shader: string;
  83666. };
  83667. }
  83668. declare module BABYLON {
  83669. interface AbstractMesh {
  83670. /**
  83671. * Gets the edgesRenderer associated with the mesh
  83672. */
  83673. edgesRenderer: Nullable<EdgesRenderer>;
  83674. }
  83675. interface LinesMesh {
  83676. /**
  83677. * Enables the edge rendering mode on the mesh.
  83678. * This mode makes the mesh edges visible
  83679. * @param epsilon defines the maximal distance between two angles to detect a face
  83680. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83681. * @returns the currentAbstractMesh
  83682. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83683. */
  83684. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83685. }
  83686. interface InstancedLinesMesh {
  83687. /**
  83688. * Enables the edge rendering mode on the mesh.
  83689. * This mode makes the mesh edges visible
  83690. * @param epsilon defines the maximal distance between two angles to detect a face
  83691. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83692. * @returns the current InstancedLinesMesh
  83693. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83694. */
  83695. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83696. }
  83697. /**
  83698. * Defines the minimum contract an Edges renderer should follow.
  83699. */
  83700. export interface IEdgesRenderer extends IDisposable {
  83701. /**
  83702. * Gets or sets a boolean indicating if the edgesRenderer is active
  83703. */
  83704. isEnabled: boolean;
  83705. /**
  83706. * Renders the edges of the attached mesh,
  83707. */
  83708. render(): void;
  83709. /**
  83710. * Checks wether or not the edges renderer is ready to render.
  83711. * @return true if ready, otherwise false.
  83712. */
  83713. isReady(): boolean;
  83714. }
  83715. /**
  83716. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83717. */
  83718. export class EdgesRenderer implements IEdgesRenderer {
  83719. /**
  83720. * Define the size of the edges with an orthographic camera
  83721. */
  83722. edgesWidthScalerForOrthographic: number;
  83723. /**
  83724. * Define the size of the edges with a perspective camera
  83725. */
  83726. edgesWidthScalerForPerspective: number;
  83727. protected _source: AbstractMesh;
  83728. protected _linesPositions: number[];
  83729. protected _linesNormals: number[];
  83730. protected _linesIndices: number[];
  83731. protected _epsilon: number;
  83732. protected _indicesCount: number;
  83733. protected _lineShader: ShaderMaterial;
  83734. protected _ib: DataBuffer;
  83735. protected _buffers: {
  83736. [key: string]: Nullable<VertexBuffer>;
  83737. };
  83738. protected _checkVerticesInsteadOfIndices: boolean;
  83739. private _meshRebuildObserver;
  83740. private _meshDisposeObserver;
  83741. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83742. isEnabled: boolean;
  83743. /**
  83744. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83745. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83746. * @param source Mesh used to create edges
  83747. * @param epsilon sum of angles in adjacency to check for edge
  83748. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83749. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83750. */
  83751. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83752. protected _prepareRessources(): void;
  83753. /** @hidden */
  83754. _rebuild(): void;
  83755. /**
  83756. * Releases the required resources for the edges renderer
  83757. */
  83758. dispose(): void;
  83759. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83760. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83761. /**
  83762. * Checks if the pair of p0 and p1 is en edge
  83763. * @param faceIndex
  83764. * @param edge
  83765. * @param faceNormals
  83766. * @param p0
  83767. * @param p1
  83768. * @private
  83769. */
  83770. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83771. /**
  83772. * push line into the position, normal and index buffer
  83773. * @protected
  83774. */
  83775. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83776. /**
  83777. * Generates lines edges from adjacencjes
  83778. * @private
  83779. */
  83780. _generateEdgesLines(): void;
  83781. /**
  83782. * Checks wether or not the edges renderer is ready to render.
  83783. * @return true if ready, otherwise false.
  83784. */
  83785. isReady(): boolean;
  83786. /**
  83787. * Renders the edges of the attached mesh,
  83788. */
  83789. render(): void;
  83790. }
  83791. /**
  83792. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83793. */
  83794. export class LineEdgesRenderer extends EdgesRenderer {
  83795. /**
  83796. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83797. * @param source LineMesh used to generate edges
  83798. * @param epsilon not important (specified angle for edge detection)
  83799. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83800. */
  83801. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83802. /**
  83803. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83804. */
  83805. _generateEdgesLines(): void;
  83806. }
  83807. }
  83808. declare module BABYLON {
  83809. /**
  83810. * This represents the object necessary to create a rendering group.
  83811. * This is exclusively used and created by the rendering manager.
  83812. * To modify the behavior, you use the available helpers in your scene or meshes.
  83813. * @hidden
  83814. */
  83815. export class RenderingGroup {
  83816. index: number;
  83817. private static _zeroVector;
  83818. private _scene;
  83819. private _opaqueSubMeshes;
  83820. private _transparentSubMeshes;
  83821. private _alphaTestSubMeshes;
  83822. private _depthOnlySubMeshes;
  83823. private _particleSystems;
  83824. private _spriteManagers;
  83825. private _opaqueSortCompareFn;
  83826. private _alphaTestSortCompareFn;
  83827. private _transparentSortCompareFn;
  83828. private _renderOpaque;
  83829. private _renderAlphaTest;
  83830. private _renderTransparent;
  83831. /** @hidden */
  83832. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83833. onBeforeTransparentRendering: () => void;
  83834. /**
  83835. * Set the opaque sort comparison function.
  83836. * If null the sub meshes will be render in the order they were created
  83837. */
  83838. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83839. /**
  83840. * Set the alpha test sort comparison function.
  83841. * If null the sub meshes will be render in the order they were created
  83842. */
  83843. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83844. /**
  83845. * Set the transparent sort comparison function.
  83846. * If null the sub meshes will be render in the order they were created
  83847. */
  83848. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83849. /**
  83850. * Creates a new rendering group.
  83851. * @param index The rendering group index
  83852. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83853. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83854. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83855. */
  83856. 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>);
  83857. /**
  83858. * Render all the sub meshes contained in the group.
  83859. * @param customRenderFunction Used to override the default render behaviour of the group.
  83860. * @returns true if rendered some submeshes.
  83861. */
  83862. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83863. /**
  83864. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83865. * @param subMeshes The submeshes to render
  83866. */
  83867. private renderOpaqueSorted;
  83868. /**
  83869. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83870. * @param subMeshes The submeshes to render
  83871. */
  83872. private renderAlphaTestSorted;
  83873. /**
  83874. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83875. * @param subMeshes The submeshes to render
  83876. */
  83877. private renderTransparentSorted;
  83878. /**
  83879. * Renders the submeshes in a specified order.
  83880. * @param subMeshes The submeshes to sort before render
  83881. * @param sortCompareFn The comparison function use to sort
  83882. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83883. * @param transparent Specifies to activate blending if true
  83884. */
  83885. private static renderSorted;
  83886. /**
  83887. * Renders the submeshes in the order they were dispatched (no sort applied).
  83888. * @param subMeshes The submeshes to render
  83889. */
  83890. private static renderUnsorted;
  83891. /**
  83892. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83893. * are rendered back to front if in the same alpha index.
  83894. *
  83895. * @param a The first submesh
  83896. * @param b The second submesh
  83897. * @returns The result of the comparison
  83898. */
  83899. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83900. /**
  83901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83902. * are rendered back to front.
  83903. *
  83904. * @param a The first submesh
  83905. * @param b The second submesh
  83906. * @returns The result of the comparison
  83907. */
  83908. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83909. /**
  83910. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83911. * are rendered front to back (prevent overdraw).
  83912. *
  83913. * @param a The first submesh
  83914. * @param b The second submesh
  83915. * @returns The result of the comparison
  83916. */
  83917. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83918. /**
  83919. * Resets the different lists of submeshes to prepare a new frame.
  83920. */
  83921. prepare(): void;
  83922. dispose(): void;
  83923. /**
  83924. * Inserts the submesh in its correct queue depending on its material.
  83925. * @param subMesh The submesh to dispatch
  83926. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83927. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83928. */
  83929. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83930. dispatchSprites(spriteManager: ISpriteManager): void;
  83931. dispatchParticles(particleSystem: IParticleSystem): void;
  83932. private _renderParticles;
  83933. private _renderSprites;
  83934. }
  83935. }
  83936. declare module BABYLON {
  83937. /**
  83938. * Interface describing the different options available in the rendering manager
  83939. * regarding Auto Clear between groups.
  83940. */
  83941. export interface IRenderingManagerAutoClearSetup {
  83942. /**
  83943. * Defines whether or not autoclear is enable.
  83944. */
  83945. autoClear: boolean;
  83946. /**
  83947. * Defines whether or not to autoclear the depth buffer.
  83948. */
  83949. depth: boolean;
  83950. /**
  83951. * Defines whether or not to autoclear the stencil buffer.
  83952. */
  83953. stencil: boolean;
  83954. }
  83955. /**
  83956. * This class is used by the onRenderingGroupObservable
  83957. */
  83958. export class RenderingGroupInfo {
  83959. /**
  83960. * The Scene that being rendered
  83961. */
  83962. scene: Scene;
  83963. /**
  83964. * The camera currently used for the rendering pass
  83965. */
  83966. camera: Nullable<Camera>;
  83967. /**
  83968. * The ID of the renderingGroup being processed
  83969. */
  83970. renderingGroupId: number;
  83971. }
  83972. /**
  83973. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83974. * It is enable to manage the different groups as well as the different necessary sort functions.
  83975. * This should not be used directly aside of the few static configurations
  83976. */
  83977. export class RenderingManager {
  83978. /**
  83979. * The max id used for rendering groups (not included)
  83980. */
  83981. static MAX_RENDERINGGROUPS: number;
  83982. /**
  83983. * The min id used for rendering groups (included)
  83984. */
  83985. static MIN_RENDERINGGROUPS: number;
  83986. /**
  83987. * Used to globally prevent autoclearing scenes.
  83988. */
  83989. static AUTOCLEAR: boolean;
  83990. /**
  83991. * @hidden
  83992. */
  83993. _useSceneAutoClearSetup: boolean;
  83994. private _scene;
  83995. private _renderingGroups;
  83996. private _depthStencilBufferAlreadyCleaned;
  83997. private _autoClearDepthStencil;
  83998. private _customOpaqueSortCompareFn;
  83999. private _customAlphaTestSortCompareFn;
  84000. private _customTransparentSortCompareFn;
  84001. private _renderingGroupInfo;
  84002. /**
  84003. * Instantiates a new rendering group for a particular scene
  84004. * @param scene Defines the scene the groups belongs to
  84005. */
  84006. constructor(scene: Scene);
  84007. private _clearDepthStencilBuffer;
  84008. /**
  84009. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84010. * @hidden
  84011. */
  84012. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84013. /**
  84014. * Resets the different information of the group to prepare a new frame
  84015. * @hidden
  84016. */
  84017. reset(): void;
  84018. /**
  84019. * Dispose and release the group and its associated resources.
  84020. * @hidden
  84021. */
  84022. dispose(): void;
  84023. /**
  84024. * Clear the info related to rendering groups preventing retention points during dispose.
  84025. */
  84026. freeRenderingGroups(): void;
  84027. private _prepareRenderingGroup;
  84028. /**
  84029. * Add a sprite manager to the rendering manager in order to render it this frame.
  84030. * @param spriteManager Define the sprite manager to render
  84031. */
  84032. dispatchSprites(spriteManager: ISpriteManager): void;
  84033. /**
  84034. * Add a particle system to the rendering manager in order to render it this frame.
  84035. * @param particleSystem Define the particle system to render
  84036. */
  84037. dispatchParticles(particleSystem: IParticleSystem): void;
  84038. /**
  84039. * Add a submesh to the manager in order to render it this frame
  84040. * @param subMesh The submesh to dispatch
  84041. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84042. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84043. */
  84044. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84045. /**
  84046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84047. * This allowed control for front to back rendering or reversly depending of the special needs.
  84048. *
  84049. * @param renderingGroupId The rendering group id corresponding to its index
  84050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84053. */
  84054. 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;
  84055. /**
  84056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84057. *
  84058. * @param renderingGroupId The rendering group id corresponding to its index
  84059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84062. */
  84063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84064. /**
  84065. * Gets the current auto clear configuration for one rendering group of the rendering
  84066. * manager.
  84067. * @param index the rendering group index to get the information for
  84068. * @returns The auto clear setup for the requested rendering group
  84069. */
  84070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84071. }
  84072. }
  84073. declare module BABYLON {
  84074. /**
  84075. * This Helps creating a texture that will be created from a camera in your scene.
  84076. * It is basically a dynamic texture that could be used to create special effects for instance.
  84077. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84078. */
  84079. export class RenderTargetTexture extends Texture {
  84080. isCube: boolean;
  84081. /**
  84082. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84083. */
  84084. static readonly REFRESHRATE_RENDER_ONCE: number;
  84085. /**
  84086. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84087. */
  84088. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84089. /**
  84090. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84091. * the central point of your effect and can save a lot of performances.
  84092. */
  84093. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84094. /**
  84095. * Use this predicate to dynamically define the list of mesh you want to render.
  84096. * If set, the renderList property will be overwritten.
  84097. */
  84098. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84099. private _renderList;
  84100. /**
  84101. * Use this list to define the list of mesh you want to render.
  84102. */
  84103. renderList: Nullable<Array<AbstractMesh>>;
  84104. private _hookArray;
  84105. /**
  84106. * Define if particles should be rendered in your texture.
  84107. */
  84108. renderParticles: boolean;
  84109. /**
  84110. * Define if sprites should be rendered in your texture.
  84111. */
  84112. renderSprites: boolean;
  84113. /**
  84114. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84115. */
  84116. coordinatesMode: number;
  84117. /**
  84118. * Define the camera used to render the texture.
  84119. */
  84120. activeCamera: Nullable<Camera>;
  84121. /**
  84122. * Override the render function of the texture with your own one.
  84123. */
  84124. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84125. /**
  84126. * Define if camera post processes should be use while rendering the texture.
  84127. */
  84128. useCameraPostProcesses: boolean;
  84129. /**
  84130. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84131. */
  84132. ignoreCameraViewport: boolean;
  84133. private _postProcessManager;
  84134. private _postProcesses;
  84135. private _resizeObserver;
  84136. /**
  84137. * An event triggered when the texture is unbind.
  84138. */
  84139. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84140. /**
  84141. * An event triggered when the texture is unbind.
  84142. */
  84143. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84144. private _onAfterUnbindObserver;
  84145. /**
  84146. * Set a after unbind callback in the texture.
  84147. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84148. */
  84149. onAfterUnbind: () => void;
  84150. /**
  84151. * An event triggered before rendering the texture
  84152. */
  84153. onBeforeRenderObservable: Observable<number>;
  84154. private _onBeforeRenderObserver;
  84155. /**
  84156. * Set a before render callback in the texture.
  84157. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84158. */
  84159. onBeforeRender: (faceIndex: number) => void;
  84160. /**
  84161. * An event triggered after rendering the texture
  84162. */
  84163. onAfterRenderObservable: Observable<number>;
  84164. private _onAfterRenderObserver;
  84165. /**
  84166. * Set a after render callback in the texture.
  84167. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84168. */
  84169. onAfterRender: (faceIndex: number) => void;
  84170. /**
  84171. * An event triggered after the texture clear
  84172. */
  84173. onClearObservable: Observable<Engine>;
  84174. private _onClearObserver;
  84175. /**
  84176. * Set a clear callback in the texture.
  84177. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84178. */
  84179. onClear: (Engine: Engine) => void;
  84180. /**
  84181. * An event triggered when the texture is resized.
  84182. */
  84183. onResizeObservable: Observable<RenderTargetTexture>;
  84184. /**
  84185. * Define the clear color of the Render Target if it should be different from the scene.
  84186. */
  84187. clearColor: Color4;
  84188. protected _size: number | {
  84189. width: number;
  84190. height: number;
  84191. };
  84192. protected _initialSizeParameter: number | {
  84193. width: number;
  84194. height: number;
  84195. } | {
  84196. ratio: number;
  84197. };
  84198. protected _sizeRatio: Nullable<number>;
  84199. /** @hidden */
  84200. _generateMipMaps: boolean;
  84201. protected _renderingManager: RenderingManager;
  84202. /** @hidden */
  84203. _waitingRenderList: string[];
  84204. protected _doNotChangeAspectRatio: boolean;
  84205. protected _currentRefreshId: number;
  84206. protected _refreshRate: number;
  84207. protected _textureMatrix: Matrix;
  84208. protected _samples: number;
  84209. protected _renderTargetOptions: RenderTargetCreationOptions;
  84210. /**
  84211. * Gets render target creation options that were used.
  84212. */
  84213. readonly renderTargetOptions: RenderTargetCreationOptions;
  84214. protected _engine: Engine;
  84215. protected _onRatioRescale(): void;
  84216. /**
  84217. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84218. * It must define where the camera used to render the texture is set
  84219. */
  84220. boundingBoxPosition: Vector3;
  84221. private _boundingBoxSize;
  84222. /**
  84223. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84224. * When defined, the cubemap will switch to local mode
  84225. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84226. * @example https://www.babylonjs-playground.com/#RNASML
  84227. */
  84228. boundingBoxSize: Vector3;
  84229. /**
  84230. * In case the RTT has been created with a depth texture, get the associated
  84231. * depth texture.
  84232. * Otherwise, return null.
  84233. */
  84234. depthStencilTexture: Nullable<InternalTexture>;
  84235. /**
  84236. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84237. * or used a shadow, depth texture...
  84238. * @param name The friendly name of the texture
  84239. * @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)
  84240. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84241. * @param generateMipMaps True if mip maps need to be generated after render.
  84242. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84243. * @param type The type of the buffer in the RTT (int, half float, float...)
  84244. * @param isCube True if a cube texture needs to be created
  84245. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84246. * @param generateDepthBuffer True to generate a depth buffer
  84247. * @param generateStencilBuffer True to generate a stencil buffer
  84248. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84249. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84250. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84251. */
  84252. constructor(name: string, size: number | {
  84253. width: number;
  84254. height: number;
  84255. } | {
  84256. ratio: number;
  84257. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84258. /**
  84259. * Creates a depth stencil texture.
  84260. * This is only available in WebGL 2 or with the depth texture extension available.
  84261. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84262. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84263. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84264. */
  84265. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84266. private _processSizeParameter;
  84267. /**
  84268. * Define the number of samples to use in case of MSAA.
  84269. * It defaults to one meaning no MSAA has been enabled.
  84270. */
  84271. samples: number;
  84272. /**
  84273. * Resets the refresh counter of the texture and start bak from scratch.
  84274. * Could be useful to regenerate the texture if it is setup to render only once.
  84275. */
  84276. resetRefreshCounter(): void;
  84277. /**
  84278. * Define the refresh rate of the texture or the rendering frequency.
  84279. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84280. */
  84281. refreshRate: number;
  84282. /**
  84283. * Adds a post process to the render target rendering passes.
  84284. * @param postProcess define the post process to add
  84285. */
  84286. addPostProcess(postProcess: PostProcess): void;
  84287. /**
  84288. * Clear all the post processes attached to the render target
  84289. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84290. */
  84291. clearPostProcesses(dispose?: boolean): void;
  84292. /**
  84293. * Remove one of the post process from the list of attached post processes to the texture
  84294. * @param postProcess define the post process to remove from the list
  84295. */
  84296. removePostProcess(postProcess: PostProcess): void;
  84297. /** @hidden */
  84298. _shouldRender(): boolean;
  84299. /**
  84300. * Gets the actual render size of the texture.
  84301. * @returns the width of the render size
  84302. */
  84303. getRenderSize(): number;
  84304. /**
  84305. * Gets the actual render width of the texture.
  84306. * @returns the width of the render size
  84307. */
  84308. getRenderWidth(): number;
  84309. /**
  84310. * Gets the actual render height of the texture.
  84311. * @returns the height of the render size
  84312. */
  84313. getRenderHeight(): number;
  84314. /**
  84315. * Get if the texture can be rescaled or not.
  84316. */
  84317. readonly canRescale: boolean;
  84318. /**
  84319. * Resize the texture using a ratio.
  84320. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84321. */
  84322. scale(ratio: number): void;
  84323. /**
  84324. * Get the texture reflection matrix used to rotate/transform the reflection.
  84325. * @returns the reflection matrix
  84326. */
  84327. getReflectionTextureMatrix(): Matrix;
  84328. /**
  84329. * Resize the texture to a new desired size.
  84330. * Be carrefull as it will recreate all the data in the new texture.
  84331. * @param size Define the new size. It can be:
  84332. * - a number for squared texture,
  84333. * - an object containing { width: number, height: number }
  84334. * - or an object containing a ratio { ratio: number }
  84335. */
  84336. resize(size: number | {
  84337. width: number;
  84338. height: number;
  84339. } | {
  84340. ratio: number;
  84341. }): void;
  84342. /**
  84343. * Renders all the objects from the render list into the texture.
  84344. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84345. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84346. */
  84347. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84348. private _bestReflectionRenderTargetDimension;
  84349. /**
  84350. * @hidden
  84351. * @param faceIndex face index to bind to if this is a cubetexture
  84352. */
  84353. _bindFrameBuffer(faceIndex?: number): void;
  84354. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84355. private renderToTarget;
  84356. /**
  84357. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84358. * This allowed control for front to back rendering or reversly depending of the special needs.
  84359. *
  84360. * @param renderingGroupId The rendering group id corresponding to its index
  84361. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84362. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84363. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84364. */
  84365. 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;
  84366. /**
  84367. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84368. *
  84369. * @param renderingGroupId The rendering group id corresponding to its index
  84370. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84371. */
  84372. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84373. /**
  84374. * Clones the texture.
  84375. * @returns the cloned texture
  84376. */
  84377. clone(): RenderTargetTexture;
  84378. /**
  84379. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84380. * @returns The JSON representation of the texture
  84381. */
  84382. serialize(): any;
  84383. /**
  84384. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84385. */
  84386. disposeFramebufferObjects(): void;
  84387. /**
  84388. * Dispose the texture and release its associated resources.
  84389. */
  84390. dispose(): void;
  84391. /** @hidden */
  84392. _rebuild(): void;
  84393. /**
  84394. * Clear the info related to rendering groups preventing retention point in material dispose.
  84395. */
  84396. freeRenderingGroups(): void;
  84397. /**
  84398. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84399. * @returns the view count
  84400. */
  84401. getViewCount(): number;
  84402. }
  84403. }
  84404. declare module BABYLON {
  84405. /**
  84406. * Base class for the main features of a material in Babylon.js
  84407. */
  84408. export class Material implements IAnimatable {
  84409. /**
  84410. * Returns the triangle fill mode
  84411. */
  84412. static readonly TriangleFillMode: number;
  84413. /**
  84414. * Returns the wireframe mode
  84415. */
  84416. static readonly WireFrameFillMode: number;
  84417. /**
  84418. * Returns the point fill mode
  84419. */
  84420. static readonly PointFillMode: number;
  84421. /**
  84422. * Returns the point list draw mode
  84423. */
  84424. static readonly PointListDrawMode: number;
  84425. /**
  84426. * Returns the line list draw mode
  84427. */
  84428. static readonly LineListDrawMode: number;
  84429. /**
  84430. * Returns the line loop draw mode
  84431. */
  84432. static readonly LineLoopDrawMode: number;
  84433. /**
  84434. * Returns the line strip draw mode
  84435. */
  84436. static readonly LineStripDrawMode: number;
  84437. /**
  84438. * Returns the triangle strip draw mode
  84439. */
  84440. static readonly TriangleStripDrawMode: number;
  84441. /**
  84442. * Returns the triangle fan draw mode
  84443. */
  84444. static readonly TriangleFanDrawMode: number;
  84445. /**
  84446. * Stores the clock-wise side orientation
  84447. */
  84448. static readonly ClockWiseSideOrientation: number;
  84449. /**
  84450. * Stores the counter clock-wise side orientation
  84451. */
  84452. static readonly CounterClockWiseSideOrientation: number;
  84453. /**
  84454. * The dirty texture flag value
  84455. */
  84456. static readonly TextureDirtyFlag: number;
  84457. /**
  84458. * The dirty light flag value
  84459. */
  84460. static readonly LightDirtyFlag: number;
  84461. /**
  84462. * The dirty fresnel flag value
  84463. */
  84464. static readonly FresnelDirtyFlag: number;
  84465. /**
  84466. * The dirty attribute flag value
  84467. */
  84468. static readonly AttributesDirtyFlag: number;
  84469. /**
  84470. * The dirty misc flag value
  84471. */
  84472. static readonly MiscDirtyFlag: number;
  84473. /**
  84474. * The all dirty flag value
  84475. */
  84476. static readonly AllDirtyFlag: number;
  84477. /**
  84478. * The ID of the material
  84479. */
  84480. id: string;
  84481. /**
  84482. * Gets or sets the unique id of the material
  84483. */
  84484. uniqueId: number;
  84485. /**
  84486. * The name of the material
  84487. */
  84488. name: string;
  84489. /**
  84490. * Gets or sets user defined metadata
  84491. */
  84492. metadata: any;
  84493. /**
  84494. * For internal use only. Please do not use.
  84495. */
  84496. reservedDataStore: any;
  84497. /**
  84498. * Specifies if the ready state should be checked on each call
  84499. */
  84500. checkReadyOnEveryCall: boolean;
  84501. /**
  84502. * Specifies if the ready state should be checked once
  84503. */
  84504. checkReadyOnlyOnce: boolean;
  84505. /**
  84506. * The state of the material
  84507. */
  84508. state: string;
  84509. /**
  84510. * The alpha value of the material
  84511. */
  84512. protected _alpha: number;
  84513. /**
  84514. * List of inspectable custom properties (used by the Inspector)
  84515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84516. */
  84517. inspectableCustomProperties: IInspectable[];
  84518. /**
  84519. * Sets the alpha value of the material
  84520. */
  84521. /**
  84522. * Gets the alpha value of the material
  84523. */
  84524. alpha: number;
  84525. /**
  84526. * Specifies if back face culling is enabled
  84527. */
  84528. protected _backFaceCulling: boolean;
  84529. /**
  84530. * Sets the back-face culling state
  84531. */
  84532. /**
  84533. * Gets the back-face culling state
  84534. */
  84535. backFaceCulling: boolean;
  84536. /**
  84537. * Stores the value for side orientation
  84538. */
  84539. sideOrientation: number;
  84540. /**
  84541. * Callback triggered when the material is compiled
  84542. */
  84543. onCompiled: Nullable<(effect: Effect) => void>;
  84544. /**
  84545. * Callback triggered when an error occurs
  84546. */
  84547. onError: Nullable<(effect: Effect, errors: string) => void>;
  84548. /**
  84549. * Callback triggered to get the render target textures
  84550. */
  84551. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84552. /**
  84553. * Gets a boolean indicating that current material needs to register RTT
  84554. */
  84555. readonly hasRenderTargetTextures: boolean;
  84556. /**
  84557. * Specifies if the material should be serialized
  84558. */
  84559. doNotSerialize: boolean;
  84560. /**
  84561. * @hidden
  84562. */
  84563. _storeEffectOnSubMeshes: boolean;
  84564. /**
  84565. * Stores the animations for the material
  84566. */
  84567. animations: Nullable<Array<Animation>>;
  84568. /**
  84569. * An event triggered when the material is disposed
  84570. */
  84571. onDisposeObservable: Observable<Material>;
  84572. /**
  84573. * An observer which watches for dispose events
  84574. */
  84575. private _onDisposeObserver;
  84576. private _onUnBindObservable;
  84577. /**
  84578. * Called during a dispose event
  84579. */
  84580. onDispose: () => void;
  84581. private _onBindObservable;
  84582. /**
  84583. * An event triggered when the material is bound
  84584. */
  84585. readonly onBindObservable: Observable<AbstractMesh>;
  84586. /**
  84587. * An observer which watches for bind events
  84588. */
  84589. private _onBindObserver;
  84590. /**
  84591. * Called during a bind event
  84592. */
  84593. onBind: (Mesh: AbstractMesh) => void;
  84594. /**
  84595. * An event triggered when the material is unbound
  84596. */
  84597. readonly onUnBindObservable: Observable<Material>;
  84598. /**
  84599. * Stores the value of the alpha mode
  84600. */
  84601. private _alphaMode;
  84602. /**
  84603. * Sets the value of the alpha mode.
  84604. *
  84605. * | Value | Type | Description |
  84606. * | --- | --- | --- |
  84607. * | 0 | ALPHA_DISABLE | |
  84608. * | 1 | ALPHA_ADD | |
  84609. * | 2 | ALPHA_COMBINE | |
  84610. * | 3 | ALPHA_SUBTRACT | |
  84611. * | 4 | ALPHA_MULTIPLY | |
  84612. * | 5 | ALPHA_MAXIMIZED | |
  84613. * | 6 | ALPHA_ONEONE | |
  84614. * | 7 | ALPHA_PREMULTIPLIED | |
  84615. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84616. * | 9 | ALPHA_INTERPOLATE | |
  84617. * | 10 | ALPHA_SCREENMODE | |
  84618. *
  84619. */
  84620. /**
  84621. * Gets the value of the alpha mode
  84622. */
  84623. alphaMode: number;
  84624. /**
  84625. * Stores the state of the need depth pre-pass value
  84626. */
  84627. private _needDepthPrePass;
  84628. /**
  84629. * Sets the need depth pre-pass value
  84630. */
  84631. /**
  84632. * Gets the depth pre-pass value
  84633. */
  84634. needDepthPrePass: boolean;
  84635. /**
  84636. * Specifies if depth writing should be disabled
  84637. */
  84638. disableDepthWrite: boolean;
  84639. /**
  84640. * Specifies if depth writing should be forced
  84641. */
  84642. forceDepthWrite: boolean;
  84643. /**
  84644. * Specifies if there should be a separate pass for culling
  84645. */
  84646. separateCullingPass: boolean;
  84647. /**
  84648. * Stores the state specifing if fog should be enabled
  84649. */
  84650. private _fogEnabled;
  84651. /**
  84652. * Sets the state for enabling fog
  84653. */
  84654. /**
  84655. * Gets the value of the fog enabled state
  84656. */
  84657. fogEnabled: boolean;
  84658. /**
  84659. * Stores the size of points
  84660. */
  84661. pointSize: number;
  84662. /**
  84663. * Stores the z offset value
  84664. */
  84665. zOffset: number;
  84666. /**
  84667. * Gets a value specifying if wireframe mode is enabled
  84668. */
  84669. /**
  84670. * Sets the state of wireframe mode
  84671. */
  84672. wireframe: boolean;
  84673. /**
  84674. * Gets the value specifying if point clouds are enabled
  84675. */
  84676. /**
  84677. * Sets the state of point cloud mode
  84678. */
  84679. pointsCloud: boolean;
  84680. /**
  84681. * Gets the material fill mode
  84682. */
  84683. /**
  84684. * Sets the material fill mode
  84685. */
  84686. fillMode: number;
  84687. /**
  84688. * @hidden
  84689. * Stores the effects for the material
  84690. */
  84691. _effect: Nullable<Effect>;
  84692. /**
  84693. * @hidden
  84694. * Specifies if the material was previously ready
  84695. */
  84696. _wasPreviouslyReady: boolean;
  84697. /**
  84698. * Specifies if uniform buffers should be used
  84699. */
  84700. private _useUBO;
  84701. /**
  84702. * Stores a reference to the scene
  84703. */
  84704. private _scene;
  84705. /**
  84706. * Stores the fill mode state
  84707. */
  84708. private _fillMode;
  84709. /**
  84710. * Specifies if the depth write state should be cached
  84711. */
  84712. private _cachedDepthWriteState;
  84713. /**
  84714. * Stores the uniform buffer
  84715. */
  84716. protected _uniformBuffer: UniformBuffer;
  84717. /** @hidden */
  84718. _indexInSceneMaterialArray: number;
  84719. /** @hidden */
  84720. meshMap: Nullable<{
  84721. [id: string]: AbstractMesh | undefined;
  84722. }>;
  84723. /**
  84724. * Creates a material instance
  84725. * @param name defines the name of the material
  84726. * @param scene defines the scene to reference
  84727. * @param doNotAdd specifies if the material should be added to the scene
  84728. */
  84729. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84730. /**
  84731. * Returns a string representation of the current material
  84732. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84733. * @returns a string with material information
  84734. */
  84735. toString(fullDetails?: boolean): string;
  84736. /**
  84737. * Gets the class name of the material
  84738. * @returns a string with the class name of the material
  84739. */
  84740. getClassName(): string;
  84741. /**
  84742. * Specifies if updates for the material been locked
  84743. */
  84744. readonly isFrozen: boolean;
  84745. /**
  84746. * Locks updates for the material
  84747. */
  84748. freeze(): void;
  84749. /**
  84750. * Unlocks updates for the material
  84751. */
  84752. unfreeze(): void;
  84753. /**
  84754. * Specifies if the material is ready to be used
  84755. * @param mesh defines the mesh to check
  84756. * @param useInstances specifies if instances should be used
  84757. * @returns a boolean indicating if the material is ready to be used
  84758. */
  84759. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84760. /**
  84761. * Specifies that the submesh is ready to be used
  84762. * @param mesh defines the mesh to check
  84763. * @param subMesh defines which submesh to check
  84764. * @param useInstances specifies that instances should be used
  84765. * @returns a boolean indicating that the submesh is ready or not
  84766. */
  84767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84768. /**
  84769. * Returns the material effect
  84770. * @returns the effect associated with the material
  84771. */
  84772. getEffect(): Nullable<Effect>;
  84773. /**
  84774. * Returns the current scene
  84775. * @returns a Scene
  84776. */
  84777. getScene(): Scene;
  84778. /**
  84779. * Specifies if the material will require alpha blending
  84780. * @returns a boolean specifying if alpha blending is needed
  84781. */
  84782. needAlphaBlending(): boolean;
  84783. /**
  84784. * Specifies if the mesh will require alpha blending
  84785. * @param mesh defines the mesh to check
  84786. * @returns a boolean specifying if alpha blending is needed for the mesh
  84787. */
  84788. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84789. /**
  84790. * Specifies if this material should be rendered in alpha test mode
  84791. * @returns a boolean specifying if an alpha test is needed.
  84792. */
  84793. needAlphaTesting(): boolean;
  84794. /**
  84795. * Gets the texture used for the alpha test
  84796. * @returns the texture to use for alpha testing
  84797. */
  84798. getAlphaTestTexture(): Nullable<BaseTexture>;
  84799. /**
  84800. * Marks the material to indicate that it needs to be re-calculated
  84801. */
  84802. markDirty(): void;
  84803. /** @hidden */
  84804. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84805. /**
  84806. * Binds the material to the mesh
  84807. * @param world defines the world transformation matrix
  84808. * @param mesh defines the mesh to bind the material to
  84809. */
  84810. bind(world: Matrix, mesh?: Mesh): void;
  84811. /**
  84812. * Binds the submesh to the material
  84813. * @param world defines the world transformation matrix
  84814. * @param mesh defines the mesh containing the submesh
  84815. * @param subMesh defines the submesh to bind the material to
  84816. */
  84817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84818. /**
  84819. * Binds the world matrix to the material
  84820. * @param world defines the world transformation matrix
  84821. */
  84822. bindOnlyWorldMatrix(world: Matrix): void;
  84823. /**
  84824. * Binds the scene's uniform buffer to the effect.
  84825. * @param effect defines the effect to bind to the scene uniform buffer
  84826. * @param sceneUbo defines the uniform buffer storing scene data
  84827. */
  84828. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84829. /**
  84830. * Binds the view matrix to the effect
  84831. * @param effect defines the effect to bind the view matrix to
  84832. */
  84833. bindView(effect: Effect): void;
  84834. /**
  84835. * Binds the view projection matrix to the effect
  84836. * @param effect defines the effect to bind the view projection matrix to
  84837. */
  84838. bindViewProjection(effect: Effect): void;
  84839. /**
  84840. * Specifies if material alpha testing should be turned on for the mesh
  84841. * @param mesh defines the mesh to check
  84842. */
  84843. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84844. /**
  84845. * Processes to execute after binding the material to a mesh
  84846. * @param mesh defines the rendered mesh
  84847. */
  84848. protected _afterBind(mesh?: Mesh): void;
  84849. /**
  84850. * Unbinds the material from the mesh
  84851. */
  84852. unbind(): void;
  84853. /**
  84854. * Gets the active textures from the material
  84855. * @returns an array of textures
  84856. */
  84857. getActiveTextures(): BaseTexture[];
  84858. /**
  84859. * Specifies if the material uses a texture
  84860. * @param texture defines the texture to check against the material
  84861. * @returns a boolean specifying if the material uses the texture
  84862. */
  84863. hasTexture(texture: BaseTexture): boolean;
  84864. /**
  84865. * Makes a duplicate of the material, and gives it a new name
  84866. * @param name defines the new name for the duplicated material
  84867. * @returns the cloned material
  84868. */
  84869. clone(name: string): Nullable<Material>;
  84870. /**
  84871. * Gets the meshes bound to the material
  84872. * @returns an array of meshes bound to the material
  84873. */
  84874. getBindedMeshes(): AbstractMesh[];
  84875. /**
  84876. * Force shader compilation
  84877. * @param mesh defines the mesh associated with this material
  84878. * @param onCompiled defines a function to execute once the material is compiled
  84879. * @param options defines the options to configure the compilation
  84880. */
  84881. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84882. clipPlane: boolean;
  84883. }>): void;
  84884. /**
  84885. * Force shader compilation
  84886. * @param mesh defines the mesh that will use this material
  84887. * @param options defines additional options for compiling the shaders
  84888. * @returns a promise that resolves when the compilation completes
  84889. */
  84890. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84891. clipPlane: boolean;
  84892. }>): Promise<void>;
  84893. private static readonly _AllDirtyCallBack;
  84894. private static readonly _ImageProcessingDirtyCallBack;
  84895. private static readonly _TextureDirtyCallBack;
  84896. private static readonly _FresnelDirtyCallBack;
  84897. private static readonly _MiscDirtyCallBack;
  84898. private static readonly _LightsDirtyCallBack;
  84899. private static readonly _AttributeDirtyCallBack;
  84900. private static _FresnelAndMiscDirtyCallBack;
  84901. private static _TextureAndMiscDirtyCallBack;
  84902. private static readonly _DirtyCallbackArray;
  84903. private static readonly _RunDirtyCallBacks;
  84904. /**
  84905. * Marks a define in the material to indicate that it needs to be re-computed
  84906. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84907. */
  84908. markAsDirty(flag: number): void;
  84909. /**
  84910. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84911. * @param func defines a function which checks material defines against the submeshes
  84912. */
  84913. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84914. /**
  84915. * Indicates that we need to re-calculated for all submeshes
  84916. */
  84917. protected _markAllSubMeshesAsAllDirty(): void;
  84918. /**
  84919. * Indicates that image processing needs to be re-calculated for all submeshes
  84920. */
  84921. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84922. /**
  84923. * Indicates that textures need to be re-calculated for all submeshes
  84924. */
  84925. protected _markAllSubMeshesAsTexturesDirty(): void;
  84926. /**
  84927. * Indicates that fresnel needs to be re-calculated for all submeshes
  84928. */
  84929. protected _markAllSubMeshesAsFresnelDirty(): void;
  84930. /**
  84931. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84932. */
  84933. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84934. /**
  84935. * Indicates that lights need to be re-calculated for all submeshes
  84936. */
  84937. protected _markAllSubMeshesAsLightsDirty(): void;
  84938. /**
  84939. * Indicates that attributes need to be re-calculated for all submeshes
  84940. */
  84941. protected _markAllSubMeshesAsAttributesDirty(): void;
  84942. /**
  84943. * Indicates that misc needs to be re-calculated for all submeshes
  84944. */
  84945. protected _markAllSubMeshesAsMiscDirty(): void;
  84946. /**
  84947. * Indicates that textures and misc need to be re-calculated for all submeshes
  84948. */
  84949. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84950. /**
  84951. * Disposes the material
  84952. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84953. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84954. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84955. */
  84956. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84957. /** @hidden */
  84958. private releaseVertexArrayObject;
  84959. /**
  84960. * Serializes this material
  84961. * @returns the serialized material object
  84962. */
  84963. serialize(): any;
  84964. /**
  84965. * Creates a material from parsed material data
  84966. * @param parsedMaterial defines parsed material data
  84967. * @param scene defines the hosting scene
  84968. * @param rootUrl defines the root URL to use to load textures
  84969. * @returns a new material
  84970. */
  84971. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84972. }
  84973. }
  84974. declare module BABYLON {
  84975. /**
  84976. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84977. * separate meshes. This can be use to improve performances.
  84978. * @see http://doc.babylonjs.com/how_to/multi_materials
  84979. */
  84980. export class MultiMaterial extends Material {
  84981. private _subMaterials;
  84982. /**
  84983. * Gets or Sets the list of Materials used within the multi material.
  84984. * They need to be ordered according to the submeshes order in the associated mesh
  84985. */
  84986. subMaterials: Nullable<Material>[];
  84987. /**
  84988. * Function used to align with Node.getChildren()
  84989. * @returns the list of Materials used within the multi material
  84990. */
  84991. getChildren(): Nullable<Material>[];
  84992. /**
  84993. * Instantiates a new Multi Material
  84994. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84995. * separate meshes. This can be use to improve performances.
  84996. * @see http://doc.babylonjs.com/how_to/multi_materials
  84997. * @param name Define the name in the scene
  84998. * @param scene Define the scene the material belongs to
  84999. */
  85000. constructor(name: string, scene: Scene);
  85001. private _hookArray;
  85002. /**
  85003. * Get one of the submaterial by its index in the submaterials array
  85004. * @param index The index to look the sub material at
  85005. * @returns The Material if the index has been defined
  85006. */
  85007. getSubMaterial(index: number): Nullable<Material>;
  85008. /**
  85009. * Get the list of active textures for the whole sub materials list.
  85010. * @returns All the textures that will be used during the rendering
  85011. */
  85012. getActiveTextures(): BaseTexture[];
  85013. /**
  85014. * Gets the current class name of the material e.g. "MultiMaterial"
  85015. * Mainly use in serialization.
  85016. * @returns the class name
  85017. */
  85018. getClassName(): string;
  85019. /**
  85020. * Checks if the material is ready to render the requested sub mesh
  85021. * @param mesh Define the mesh the submesh belongs to
  85022. * @param subMesh Define the sub mesh to look readyness for
  85023. * @param useInstances Define whether or not the material is used with instances
  85024. * @returns true if ready, otherwise false
  85025. */
  85026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85027. /**
  85028. * Clones the current material and its related sub materials
  85029. * @param name Define the name of the newly cloned material
  85030. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85031. * @returns the cloned material
  85032. */
  85033. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85034. /**
  85035. * Serializes the materials into a JSON representation.
  85036. * @returns the JSON representation
  85037. */
  85038. serialize(): any;
  85039. /**
  85040. * Dispose the material and release its associated resources
  85041. * @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)
  85042. * @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)
  85043. * @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)
  85044. */
  85045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85046. /**
  85047. * Creates a MultiMaterial from parsed MultiMaterial data.
  85048. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85049. * @param scene defines the hosting scene
  85050. * @returns a new MultiMaterial
  85051. */
  85052. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85053. }
  85054. }
  85055. declare module BABYLON {
  85056. /**
  85057. * Base class for submeshes
  85058. */
  85059. export class BaseSubMesh {
  85060. /** @hidden */
  85061. _materialDefines: Nullable<MaterialDefines>;
  85062. /** @hidden */
  85063. _materialEffect: Nullable<Effect>;
  85064. /**
  85065. * Gets associated effect
  85066. */
  85067. readonly effect: Nullable<Effect>;
  85068. /**
  85069. * Sets associated effect (effect used to render this submesh)
  85070. * @param effect defines the effect to associate with
  85071. * @param defines defines the set of defines used to compile this effect
  85072. */
  85073. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85074. }
  85075. /**
  85076. * Defines a subdivision inside a mesh
  85077. */
  85078. export class SubMesh extends BaseSubMesh implements ICullable {
  85079. /** the material index to use */
  85080. materialIndex: number;
  85081. /** vertex index start */
  85082. verticesStart: number;
  85083. /** vertices count */
  85084. verticesCount: number;
  85085. /** index start */
  85086. indexStart: number;
  85087. /** indices count */
  85088. indexCount: number;
  85089. /** @hidden */
  85090. _linesIndexCount: number;
  85091. private _mesh;
  85092. private _renderingMesh;
  85093. private _boundingInfo;
  85094. private _linesIndexBuffer;
  85095. /** @hidden */
  85096. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85097. /** @hidden */
  85098. _trianglePlanes: Plane[];
  85099. /** @hidden */
  85100. _lastColliderTransformMatrix: Nullable<Matrix>;
  85101. /** @hidden */
  85102. _renderId: number;
  85103. /** @hidden */
  85104. _alphaIndex: number;
  85105. /** @hidden */
  85106. _distanceToCamera: number;
  85107. /** @hidden */
  85108. _id: number;
  85109. private _currentMaterial;
  85110. /**
  85111. * Add a new submesh to a mesh
  85112. * @param materialIndex defines the material index to use
  85113. * @param verticesStart defines vertex index start
  85114. * @param verticesCount defines vertices count
  85115. * @param indexStart defines index start
  85116. * @param indexCount defines indices count
  85117. * @param mesh defines the parent mesh
  85118. * @param renderingMesh defines an optional rendering mesh
  85119. * @param createBoundingBox defines if bounding box should be created for this submesh
  85120. * @returns the new submesh
  85121. */
  85122. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85123. /**
  85124. * Creates a new submesh
  85125. * @param materialIndex defines the material index to use
  85126. * @param verticesStart defines vertex index start
  85127. * @param verticesCount defines vertices count
  85128. * @param indexStart defines index start
  85129. * @param indexCount defines indices count
  85130. * @param mesh defines the parent mesh
  85131. * @param renderingMesh defines an optional rendering mesh
  85132. * @param createBoundingBox defines if bounding box should be created for this submesh
  85133. */
  85134. constructor(
  85135. /** the material index to use */
  85136. materialIndex: number,
  85137. /** vertex index start */
  85138. verticesStart: number,
  85139. /** vertices count */
  85140. verticesCount: number,
  85141. /** index start */
  85142. indexStart: number,
  85143. /** indices count */
  85144. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85145. /**
  85146. * Returns true if this submesh covers the entire parent mesh
  85147. * @ignorenaming
  85148. */
  85149. readonly IsGlobal: boolean;
  85150. /**
  85151. * Returns the submesh BoudingInfo object
  85152. * @returns current bounding info (or mesh's one if the submesh is global)
  85153. */
  85154. getBoundingInfo(): BoundingInfo;
  85155. /**
  85156. * Sets the submesh BoundingInfo
  85157. * @param boundingInfo defines the new bounding info to use
  85158. * @returns the SubMesh
  85159. */
  85160. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85161. /**
  85162. * Returns the mesh of the current submesh
  85163. * @return the parent mesh
  85164. */
  85165. getMesh(): AbstractMesh;
  85166. /**
  85167. * Returns the rendering mesh of the submesh
  85168. * @returns the rendering mesh (could be different from parent mesh)
  85169. */
  85170. getRenderingMesh(): Mesh;
  85171. /**
  85172. * Returns the submesh material
  85173. * @returns null or the current material
  85174. */
  85175. getMaterial(): Nullable<Material>;
  85176. /**
  85177. * Sets a new updated BoundingInfo object to the submesh
  85178. * @param data defines an optional position array to use to determine the bounding info
  85179. * @returns the SubMesh
  85180. */
  85181. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85182. /** @hidden */
  85183. _checkCollision(collider: Collider): boolean;
  85184. /**
  85185. * Updates the submesh BoundingInfo
  85186. * @param world defines the world matrix to use to update the bounding info
  85187. * @returns the submesh
  85188. */
  85189. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85190. /**
  85191. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85192. * @param frustumPlanes defines the frustum planes
  85193. * @returns true if the submesh is intersecting with the frustum
  85194. */
  85195. isInFrustum(frustumPlanes: Plane[]): boolean;
  85196. /**
  85197. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85198. * @param frustumPlanes defines the frustum planes
  85199. * @returns true if the submesh is inside the frustum
  85200. */
  85201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85202. /**
  85203. * Renders the submesh
  85204. * @param enableAlphaMode defines if alpha needs to be used
  85205. * @returns the submesh
  85206. */
  85207. render(enableAlphaMode: boolean): SubMesh;
  85208. /**
  85209. * @hidden
  85210. */
  85211. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85212. /**
  85213. * Checks if the submesh intersects with a ray
  85214. * @param ray defines the ray to test
  85215. * @returns true is the passed ray intersects the submesh bounding box
  85216. */
  85217. canIntersects(ray: Ray): boolean;
  85218. /**
  85219. * Intersects current submesh with a ray
  85220. * @param ray defines the ray to test
  85221. * @param positions defines mesh's positions array
  85222. * @param indices defines mesh's indices array
  85223. * @param fastCheck defines if only bounding info should be used
  85224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85225. * @returns intersection info or null if no intersection
  85226. */
  85227. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85228. /** @hidden */
  85229. private _intersectLines;
  85230. /** @hidden */
  85231. private _intersectUnIndexedLines;
  85232. /** @hidden */
  85233. private _intersectTriangles;
  85234. /** @hidden */
  85235. private _intersectUnIndexedTriangles;
  85236. /** @hidden */
  85237. _rebuild(): void;
  85238. /**
  85239. * Creates a new submesh from the passed mesh
  85240. * @param newMesh defines the new hosting mesh
  85241. * @param newRenderingMesh defines an optional rendering mesh
  85242. * @returns the new submesh
  85243. */
  85244. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85245. /**
  85246. * Release associated resources
  85247. */
  85248. dispose(): void;
  85249. /**
  85250. * Gets the class name
  85251. * @returns the string "SubMesh".
  85252. */
  85253. getClassName(): string;
  85254. /**
  85255. * Creates a new submesh from indices data
  85256. * @param materialIndex the index of the main mesh material
  85257. * @param startIndex the index where to start the copy in the mesh indices array
  85258. * @param indexCount the number of indices to copy then from the startIndex
  85259. * @param mesh the main mesh to create the submesh from
  85260. * @param renderingMesh the optional rendering mesh
  85261. * @returns a new submesh
  85262. */
  85263. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85264. }
  85265. }
  85266. declare module BABYLON {
  85267. /**
  85268. * Class used to represent data loading progression
  85269. */
  85270. export class SceneLoaderFlags {
  85271. private static _ForceFullSceneLoadingForIncremental;
  85272. private static _ShowLoadingScreen;
  85273. private static _CleanBoneMatrixWeights;
  85274. private static _loggingLevel;
  85275. /**
  85276. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85277. */
  85278. static ForceFullSceneLoadingForIncremental: boolean;
  85279. /**
  85280. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85281. */
  85282. static ShowLoadingScreen: boolean;
  85283. /**
  85284. * Defines the current logging level (while loading the scene)
  85285. * @ignorenaming
  85286. */
  85287. static loggingLevel: number;
  85288. /**
  85289. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85290. */
  85291. static CleanBoneMatrixWeights: boolean;
  85292. }
  85293. }
  85294. declare module BABYLON {
  85295. /**
  85296. * Class used to store geometry data (vertex buffers + index buffer)
  85297. */
  85298. export class Geometry implements IGetSetVerticesData {
  85299. /**
  85300. * Gets or sets the ID of the geometry
  85301. */
  85302. id: string;
  85303. /**
  85304. * Gets or sets the unique ID of the geometry
  85305. */
  85306. uniqueId: number;
  85307. /**
  85308. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85309. */
  85310. delayLoadState: number;
  85311. /**
  85312. * Gets the file containing the data to load when running in delay load state
  85313. */
  85314. delayLoadingFile: Nullable<string>;
  85315. /**
  85316. * Callback called when the geometry is updated
  85317. */
  85318. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85319. private _scene;
  85320. private _engine;
  85321. private _meshes;
  85322. private _totalVertices;
  85323. /** @hidden */
  85324. _indices: IndicesArray;
  85325. /** @hidden */
  85326. _vertexBuffers: {
  85327. [key: string]: VertexBuffer;
  85328. };
  85329. private _isDisposed;
  85330. private _extend;
  85331. private _boundingBias;
  85332. /** @hidden */
  85333. _delayInfo: Array<string>;
  85334. private _indexBuffer;
  85335. private _indexBufferIsUpdatable;
  85336. /** @hidden */
  85337. _boundingInfo: Nullable<BoundingInfo>;
  85338. /** @hidden */
  85339. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85340. /** @hidden */
  85341. _softwareSkinningFrameId: number;
  85342. private _vertexArrayObjects;
  85343. private _updatable;
  85344. /** @hidden */
  85345. _positions: Nullable<Vector3[]>;
  85346. /**
  85347. * 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
  85348. */
  85349. /**
  85350. * 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
  85351. */
  85352. boundingBias: Vector2;
  85353. /**
  85354. * Static function used to attach a new empty geometry to a mesh
  85355. * @param mesh defines the mesh to attach the geometry to
  85356. * @returns the new Geometry
  85357. */
  85358. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85359. /**
  85360. * Creates a new geometry
  85361. * @param id defines the unique ID
  85362. * @param scene defines the hosting scene
  85363. * @param vertexData defines the VertexData used to get geometry data
  85364. * @param updatable defines if geometry must be updatable (false by default)
  85365. * @param mesh defines the mesh that will be associated with the geometry
  85366. */
  85367. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85368. /**
  85369. * Gets the current extend of the geometry
  85370. */
  85371. readonly extend: {
  85372. minimum: Vector3;
  85373. maximum: Vector3;
  85374. };
  85375. /**
  85376. * Gets the hosting scene
  85377. * @returns the hosting Scene
  85378. */
  85379. getScene(): Scene;
  85380. /**
  85381. * Gets the hosting engine
  85382. * @returns the hosting Engine
  85383. */
  85384. getEngine(): Engine;
  85385. /**
  85386. * Defines if the geometry is ready to use
  85387. * @returns true if the geometry is ready to be used
  85388. */
  85389. isReady(): boolean;
  85390. /**
  85391. * Gets a value indicating that the geometry should not be serialized
  85392. */
  85393. readonly doNotSerialize: boolean;
  85394. /** @hidden */
  85395. _rebuild(): void;
  85396. /**
  85397. * Affects all geometry data in one call
  85398. * @param vertexData defines the geometry data
  85399. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85400. */
  85401. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85402. /**
  85403. * Set specific vertex data
  85404. * @param kind defines the data kind (Position, normal, etc...)
  85405. * @param data defines the vertex data to use
  85406. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85407. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85408. */
  85409. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85410. /**
  85411. * Removes a specific vertex data
  85412. * @param kind defines the data kind (Position, normal, etc...)
  85413. */
  85414. removeVerticesData(kind: string): void;
  85415. /**
  85416. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85417. * @param buffer defines the vertex buffer to use
  85418. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85419. */
  85420. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85421. /**
  85422. * Update a specific vertex buffer
  85423. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85424. * It will do nothing if the buffer is not updatable
  85425. * @param kind defines the data kind (Position, normal, etc...)
  85426. * @param data defines the data to use
  85427. * @param offset defines the offset in the target buffer where to store the data
  85428. * @param useBytes set to true if the offset is in bytes
  85429. */
  85430. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85431. /**
  85432. * Update a specific vertex buffer
  85433. * This function will create a new buffer if the current one is not updatable
  85434. * @param kind defines the data kind (Position, normal, etc...)
  85435. * @param data defines the data to use
  85436. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85437. */
  85438. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85439. private _updateBoundingInfo;
  85440. /** @hidden */
  85441. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85442. /**
  85443. * Gets total number of vertices
  85444. * @returns the total number of vertices
  85445. */
  85446. getTotalVertices(): number;
  85447. /**
  85448. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85449. * @param kind defines the data kind (Position, normal, etc...)
  85450. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85451. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85452. * @returns a float array containing vertex data
  85453. */
  85454. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85455. /**
  85456. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85457. * @param kind defines the data kind (Position, normal, etc...)
  85458. * @returns true if the vertex buffer with the specified kind is updatable
  85459. */
  85460. isVertexBufferUpdatable(kind: string): boolean;
  85461. /**
  85462. * Gets a specific vertex buffer
  85463. * @param kind defines the data kind (Position, normal, etc...)
  85464. * @returns a VertexBuffer
  85465. */
  85466. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85467. /**
  85468. * Returns all vertex buffers
  85469. * @return an object holding all vertex buffers indexed by kind
  85470. */
  85471. getVertexBuffers(): Nullable<{
  85472. [key: string]: VertexBuffer;
  85473. }>;
  85474. /**
  85475. * Gets a boolean indicating if specific vertex buffer is present
  85476. * @param kind defines the data kind (Position, normal, etc...)
  85477. * @returns true if data is present
  85478. */
  85479. isVerticesDataPresent(kind: string): boolean;
  85480. /**
  85481. * Gets a list of all attached data kinds (Position, normal, etc...)
  85482. * @returns a list of string containing all kinds
  85483. */
  85484. getVerticesDataKinds(): string[];
  85485. /**
  85486. * Update index buffer
  85487. * @param indices defines the indices to store in the index buffer
  85488. * @param offset defines the offset in the target buffer where to store the data
  85489. * @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)
  85490. */
  85491. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85492. /**
  85493. * Creates a new index buffer
  85494. * @param indices defines the indices to store in the index buffer
  85495. * @param totalVertices defines the total number of vertices (could be null)
  85496. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85497. */
  85498. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85499. /**
  85500. * Return the total number of indices
  85501. * @returns the total number of indices
  85502. */
  85503. getTotalIndices(): number;
  85504. /**
  85505. * Gets the index buffer array
  85506. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85508. * @returns the index buffer array
  85509. */
  85510. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85511. /**
  85512. * Gets the index buffer
  85513. * @return the index buffer
  85514. */
  85515. getIndexBuffer(): Nullable<DataBuffer>;
  85516. /** @hidden */
  85517. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85518. /**
  85519. * Release the associated resources for a specific mesh
  85520. * @param mesh defines the source mesh
  85521. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85522. */
  85523. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85524. /**
  85525. * Apply current geometry to a given mesh
  85526. * @param mesh defines the mesh to apply geometry to
  85527. */
  85528. applyToMesh(mesh: Mesh): void;
  85529. private _updateExtend;
  85530. private _applyToMesh;
  85531. private notifyUpdate;
  85532. /**
  85533. * Load the geometry if it was flagged as delay loaded
  85534. * @param scene defines the hosting scene
  85535. * @param onLoaded defines a callback called when the geometry is loaded
  85536. */
  85537. load(scene: Scene, onLoaded?: () => void): void;
  85538. private _queueLoad;
  85539. /**
  85540. * Invert the geometry to move from a right handed system to a left handed one.
  85541. */
  85542. toLeftHanded(): void;
  85543. /** @hidden */
  85544. _resetPointsArrayCache(): void;
  85545. /** @hidden */
  85546. _generatePointsArray(): boolean;
  85547. /**
  85548. * Gets a value indicating if the geometry is disposed
  85549. * @returns true if the geometry was disposed
  85550. */
  85551. isDisposed(): boolean;
  85552. private _disposeVertexArrayObjects;
  85553. /**
  85554. * Free all associated resources
  85555. */
  85556. dispose(): void;
  85557. /**
  85558. * Clone the current geometry into a new geometry
  85559. * @param id defines the unique ID of the new geometry
  85560. * @returns a new geometry object
  85561. */
  85562. copy(id: string): Geometry;
  85563. /**
  85564. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85565. * @return a JSON representation of the current geometry data (without the vertices data)
  85566. */
  85567. serialize(): any;
  85568. private toNumberArray;
  85569. /**
  85570. * Serialize all vertices data into a JSON oject
  85571. * @returns a JSON representation of the current geometry data
  85572. */
  85573. serializeVerticeData(): any;
  85574. /**
  85575. * Extracts a clone of a mesh geometry
  85576. * @param mesh defines the source mesh
  85577. * @param id defines the unique ID of the new geometry object
  85578. * @returns the new geometry object
  85579. */
  85580. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85581. /**
  85582. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85583. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85584. * Be aware Math.random() could cause collisions, but:
  85585. * "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"
  85586. * @returns a string containing a new GUID
  85587. */
  85588. static RandomId(): string;
  85589. /** @hidden */
  85590. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85591. private static _CleanMatricesWeights;
  85592. /**
  85593. * Create a new geometry from persisted data (Using .babylon file format)
  85594. * @param parsedVertexData defines the persisted data
  85595. * @param scene defines the hosting scene
  85596. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85597. * @returns the new geometry object
  85598. */
  85599. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85600. }
  85601. }
  85602. declare module BABYLON {
  85603. /**
  85604. * Define an interface for all classes that will get and set the data on vertices
  85605. */
  85606. export interface IGetSetVerticesData {
  85607. /**
  85608. * Gets a boolean indicating if specific vertex data is present
  85609. * @param kind defines the vertex data kind to use
  85610. * @returns true is data kind is present
  85611. */
  85612. isVerticesDataPresent(kind: string): boolean;
  85613. /**
  85614. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85615. * @param kind defines the data kind (Position, normal, etc...)
  85616. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85618. * @returns a float array containing vertex data
  85619. */
  85620. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85621. /**
  85622. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85623. * @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.
  85624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85625. * @returns the indices array or an empty array if the mesh has no geometry
  85626. */
  85627. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85628. /**
  85629. * Set specific vertex data
  85630. * @param kind defines the data kind (Position, normal, etc...)
  85631. * @param data defines the vertex data to use
  85632. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85633. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85634. */
  85635. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85636. /**
  85637. * Update a specific associated vertex buffer
  85638. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85639. * - VertexBuffer.PositionKind
  85640. * - VertexBuffer.UVKind
  85641. * - VertexBuffer.UV2Kind
  85642. * - VertexBuffer.UV3Kind
  85643. * - VertexBuffer.UV4Kind
  85644. * - VertexBuffer.UV5Kind
  85645. * - VertexBuffer.UV6Kind
  85646. * - VertexBuffer.ColorKind
  85647. * - VertexBuffer.MatricesIndicesKind
  85648. * - VertexBuffer.MatricesIndicesExtraKind
  85649. * - VertexBuffer.MatricesWeightsKind
  85650. * - VertexBuffer.MatricesWeightsExtraKind
  85651. * @param data defines the data source
  85652. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85653. * @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)
  85654. */
  85655. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85656. /**
  85657. * Creates a new index buffer
  85658. * @param indices defines the indices to store in the index buffer
  85659. * @param totalVertices defines the total number of vertices (could be null)
  85660. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85661. */
  85662. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85663. }
  85664. /**
  85665. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85666. */
  85667. export class VertexData {
  85668. /**
  85669. * Mesh side orientation : usually the external or front surface
  85670. */
  85671. static readonly FRONTSIDE: number;
  85672. /**
  85673. * Mesh side orientation : usually the internal or back surface
  85674. */
  85675. static readonly BACKSIDE: number;
  85676. /**
  85677. * Mesh side orientation : both internal and external or front and back surfaces
  85678. */
  85679. static readonly DOUBLESIDE: number;
  85680. /**
  85681. * Mesh side orientation : by default, `FRONTSIDE`
  85682. */
  85683. static readonly DEFAULTSIDE: number;
  85684. /**
  85685. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85686. */
  85687. positions: Nullable<FloatArray>;
  85688. /**
  85689. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85690. */
  85691. normals: Nullable<FloatArray>;
  85692. /**
  85693. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85694. */
  85695. tangents: Nullable<FloatArray>;
  85696. /**
  85697. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85698. */
  85699. uvs: Nullable<FloatArray>;
  85700. /**
  85701. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85702. */
  85703. uvs2: Nullable<FloatArray>;
  85704. /**
  85705. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85706. */
  85707. uvs3: Nullable<FloatArray>;
  85708. /**
  85709. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85710. */
  85711. uvs4: Nullable<FloatArray>;
  85712. /**
  85713. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85714. */
  85715. uvs5: Nullable<FloatArray>;
  85716. /**
  85717. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85718. */
  85719. uvs6: Nullable<FloatArray>;
  85720. /**
  85721. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85722. */
  85723. colors: Nullable<FloatArray>;
  85724. /**
  85725. * 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).
  85726. */
  85727. matricesIndices: Nullable<FloatArray>;
  85728. /**
  85729. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85730. */
  85731. matricesWeights: Nullable<FloatArray>;
  85732. /**
  85733. * An array extending the number of possible indices
  85734. */
  85735. matricesIndicesExtra: Nullable<FloatArray>;
  85736. /**
  85737. * An array extending the number of possible weights when the number of indices is extended
  85738. */
  85739. matricesWeightsExtra: Nullable<FloatArray>;
  85740. /**
  85741. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85742. */
  85743. indices: Nullable<IndicesArray>;
  85744. /**
  85745. * Uses the passed data array to set the set the values for the specified kind of data
  85746. * @param data a linear array of floating numbers
  85747. * @param kind the type of data that is being set, eg positions, colors etc
  85748. */
  85749. set(data: FloatArray, kind: string): void;
  85750. /**
  85751. * Associates the vertexData to the passed Mesh.
  85752. * Sets it as updatable or not (default `false`)
  85753. * @param mesh the mesh the vertexData is applied to
  85754. * @param updatable when used and having the value true allows new data to update the vertexData
  85755. * @returns the VertexData
  85756. */
  85757. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85758. /**
  85759. * Associates the vertexData to the passed Geometry.
  85760. * Sets it as updatable or not (default `false`)
  85761. * @param geometry the geometry the vertexData is applied to
  85762. * @param updatable when used and having the value true allows new data to update the vertexData
  85763. * @returns VertexData
  85764. */
  85765. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85766. /**
  85767. * Updates the associated mesh
  85768. * @param mesh the mesh to be updated
  85769. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85770. * @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
  85771. * @returns VertexData
  85772. */
  85773. updateMesh(mesh: Mesh): VertexData;
  85774. /**
  85775. * Updates the associated geometry
  85776. * @param geometry the geometry to be updated
  85777. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85778. * @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
  85779. * @returns VertexData.
  85780. */
  85781. updateGeometry(geometry: Geometry): VertexData;
  85782. private _applyTo;
  85783. private _update;
  85784. /**
  85785. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85786. * @param matrix the transforming matrix
  85787. * @returns the VertexData
  85788. */
  85789. transform(matrix: Matrix): VertexData;
  85790. /**
  85791. * Merges the passed VertexData into the current one
  85792. * @param other the VertexData to be merged into the current one
  85793. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85794. * @returns the modified VertexData
  85795. */
  85796. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85797. private _mergeElement;
  85798. private _validate;
  85799. /**
  85800. * Serializes the VertexData
  85801. * @returns a serialized object
  85802. */
  85803. serialize(): any;
  85804. /**
  85805. * Extracts the vertexData from a mesh
  85806. * @param mesh the mesh from which to extract the VertexData
  85807. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85808. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85809. * @returns the object VertexData associated to the passed mesh
  85810. */
  85811. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85812. /**
  85813. * Extracts the vertexData from the geometry
  85814. * @param geometry the geometry from which to extract the VertexData
  85815. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85816. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85817. * @returns the object VertexData associated to the passed mesh
  85818. */
  85819. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85820. private static _ExtractFrom;
  85821. /**
  85822. * Creates the VertexData for a Ribbon
  85823. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85824. * * pathArray array of paths, each of which an array of successive Vector3
  85825. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85826. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85827. * * 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
  85828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85829. * * 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)
  85830. * * 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)
  85831. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85832. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85833. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85834. * @returns the VertexData of the ribbon
  85835. */
  85836. static CreateRibbon(options: {
  85837. pathArray: Vector3[][];
  85838. closeArray?: boolean;
  85839. closePath?: boolean;
  85840. offset?: number;
  85841. sideOrientation?: number;
  85842. frontUVs?: Vector4;
  85843. backUVs?: Vector4;
  85844. invertUV?: boolean;
  85845. uvs?: Vector2[];
  85846. colors?: Color4[];
  85847. }): VertexData;
  85848. /**
  85849. * Creates the VertexData for a box
  85850. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85851. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85852. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85853. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85854. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85855. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85856. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85858. * * 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)
  85859. * * 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)
  85860. * @returns the VertexData of the box
  85861. */
  85862. static CreateBox(options: {
  85863. size?: number;
  85864. width?: number;
  85865. height?: number;
  85866. depth?: number;
  85867. faceUV?: Vector4[];
  85868. faceColors?: Color4[];
  85869. sideOrientation?: number;
  85870. frontUVs?: Vector4;
  85871. backUVs?: Vector4;
  85872. }): VertexData;
  85873. /**
  85874. * Creates the VertexData for a tiled box
  85875. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85876. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85877. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85878. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85880. * @returns the VertexData of the box
  85881. */
  85882. static CreateTiledBox(options: {
  85883. pattern?: number;
  85884. width?: number;
  85885. height?: number;
  85886. depth?: number;
  85887. tileSize?: number;
  85888. tileWidth?: number;
  85889. tileHeight?: number;
  85890. alignHorizontal?: number;
  85891. alignVertical?: number;
  85892. faceUV?: Vector4[];
  85893. faceColors?: Color4[];
  85894. sideOrientation?: number;
  85895. }): VertexData;
  85896. /**
  85897. * Creates the VertexData for a tiled plane
  85898. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85899. * * pattern a limited pattern arrangement depending on the number
  85900. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85901. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85902. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85904. * * 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)
  85905. * * 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)
  85906. * @returns the VertexData of the tiled plane
  85907. */
  85908. static CreateTiledPlane(options: {
  85909. pattern?: number;
  85910. tileSize?: number;
  85911. tileWidth?: number;
  85912. tileHeight?: number;
  85913. size?: number;
  85914. width?: number;
  85915. height?: number;
  85916. alignHorizontal?: number;
  85917. alignVertical?: number;
  85918. sideOrientation?: number;
  85919. frontUVs?: Vector4;
  85920. backUVs?: Vector4;
  85921. }): VertexData;
  85922. /**
  85923. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85925. * * segments sets the number of horizontal strips optional, default 32
  85926. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85927. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85928. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85929. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85930. * * 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
  85931. * * 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
  85932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85933. * * 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)
  85934. * * 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)
  85935. * @returns the VertexData of the ellipsoid
  85936. */
  85937. static CreateSphere(options: {
  85938. segments?: number;
  85939. diameter?: number;
  85940. diameterX?: number;
  85941. diameterY?: number;
  85942. diameterZ?: number;
  85943. arc?: number;
  85944. slice?: number;
  85945. sideOrientation?: number;
  85946. frontUVs?: Vector4;
  85947. backUVs?: Vector4;
  85948. }): VertexData;
  85949. /**
  85950. * Creates the VertexData for a cylinder, cone or prism
  85951. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85952. * * height sets the height (y direction) of the cylinder, optional, default 2
  85953. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85954. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85955. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85956. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85957. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85958. * * 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
  85959. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85960. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85961. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85962. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85964. * * 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)
  85965. * * 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)
  85966. * @returns the VertexData of the cylinder, cone or prism
  85967. */
  85968. static CreateCylinder(options: {
  85969. height?: number;
  85970. diameterTop?: number;
  85971. diameterBottom?: number;
  85972. diameter?: number;
  85973. tessellation?: number;
  85974. subdivisions?: number;
  85975. arc?: number;
  85976. faceColors?: Color4[];
  85977. faceUV?: Vector4[];
  85978. hasRings?: boolean;
  85979. enclose?: boolean;
  85980. sideOrientation?: number;
  85981. frontUVs?: Vector4;
  85982. backUVs?: Vector4;
  85983. }): VertexData;
  85984. /**
  85985. * Creates the VertexData for a torus
  85986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85987. * * diameter the diameter of the torus, optional default 1
  85988. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85989. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85991. * * 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)
  85992. * * 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)
  85993. * @returns the VertexData of the torus
  85994. */
  85995. static CreateTorus(options: {
  85996. diameter?: number;
  85997. thickness?: number;
  85998. tessellation?: number;
  85999. sideOrientation?: number;
  86000. frontUVs?: Vector4;
  86001. backUVs?: Vector4;
  86002. }): VertexData;
  86003. /**
  86004. * Creates the VertexData of the LineSystem
  86005. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86006. * - lines an array of lines, each line being an array of successive Vector3
  86007. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86008. * @returns the VertexData of the LineSystem
  86009. */
  86010. static CreateLineSystem(options: {
  86011. lines: Vector3[][];
  86012. colors?: Nullable<Color4[][]>;
  86013. }): VertexData;
  86014. /**
  86015. * Create the VertexData for a DashedLines
  86016. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86017. * - points an array successive Vector3
  86018. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86019. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86020. * - dashNb the intended total number of dashes, optional, default 200
  86021. * @returns the VertexData for the DashedLines
  86022. */
  86023. static CreateDashedLines(options: {
  86024. points: Vector3[];
  86025. dashSize?: number;
  86026. gapSize?: number;
  86027. dashNb?: number;
  86028. }): VertexData;
  86029. /**
  86030. * Creates the VertexData for a Ground
  86031. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86032. * - width the width (x direction) of the ground, optional, default 1
  86033. * - height the height (z direction) of the ground, optional, default 1
  86034. * - subdivisions the number of subdivisions per side, optional, default 1
  86035. * @returns the VertexData of the Ground
  86036. */
  86037. static CreateGround(options: {
  86038. width?: number;
  86039. height?: number;
  86040. subdivisions?: number;
  86041. subdivisionsX?: number;
  86042. subdivisionsY?: number;
  86043. }): VertexData;
  86044. /**
  86045. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86046. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86047. * * xmin the ground minimum X coordinate, optional, default -1
  86048. * * zmin the ground minimum Z coordinate, optional, default -1
  86049. * * xmax the ground maximum X coordinate, optional, default 1
  86050. * * zmax the ground maximum Z coordinate, optional, default 1
  86051. * * 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}
  86052. * * 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}
  86053. * @returns the VertexData of the TiledGround
  86054. */
  86055. static CreateTiledGround(options: {
  86056. xmin: number;
  86057. zmin: number;
  86058. xmax: number;
  86059. zmax: number;
  86060. subdivisions?: {
  86061. w: number;
  86062. h: number;
  86063. };
  86064. precision?: {
  86065. w: number;
  86066. h: number;
  86067. };
  86068. }): VertexData;
  86069. /**
  86070. * Creates the VertexData of the Ground designed from a heightmap
  86071. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86072. * * width the width (x direction) of the ground
  86073. * * height the height (z direction) of the ground
  86074. * * subdivisions the number of subdivisions per side
  86075. * * minHeight the minimum altitude on the ground, optional, default 0
  86076. * * maxHeight the maximum altitude on the ground, optional default 1
  86077. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86078. * * buffer the array holding the image color data
  86079. * * bufferWidth the width of image
  86080. * * bufferHeight the height of image
  86081. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86082. * @returns the VertexData of the Ground designed from a heightmap
  86083. */
  86084. static CreateGroundFromHeightMap(options: {
  86085. width: number;
  86086. height: number;
  86087. subdivisions: number;
  86088. minHeight: number;
  86089. maxHeight: number;
  86090. colorFilter: Color3;
  86091. buffer: Uint8Array;
  86092. bufferWidth: number;
  86093. bufferHeight: number;
  86094. alphaFilter: number;
  86095. }): VertexData;
  86096. /**
  86097. * Creates the VertexData for a Plane
  86098. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86099. * * size sets the width and height of the plane to the value of size, optional default 1
  86100. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86101. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86103. * * 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)
  86104. * * 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)
  86105. * @returns the VertexData of the box
  86106. */
  86107. static CreatePlane(options: {
  86108. size?: number;
  86109. width?: number;
  86110. height?: number;
  86111. sideOrientation?: number;
  86112. frontUVs?: Vector4;
  86113. backUVs?: Vector4;
  86114. }): VertexData;
  86115. /**
  86116. * Creates the VertexData of the Disc or regular Polygon
  86117. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86118. * * radius the radius of the disc, optional default 0.5
  86119. * * tessellation the number of polygon sides, optional, default 64
  86120. * * 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
  86121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86122. * * 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)
  86123. * * 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)
  86124. * @returns the VertexData of the box
  86125. */
  86126. static CreateDisc(options: {
  86127. radius?: number;
  86128. tessellation?: number;
  86129. arc?: number;
  86130. sideOrientation?: number;
  86131. frontUVs?: Vector4;
  86132. backUVs?: Vector4;
  86133. }): VertexData;
  86134. /**
  86135. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86136. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86137. * @param polygon a mesh built from polygonTriangulation.build()
  86138. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86139. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86140. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86141. * @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)
  86142. * @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)
  86143. * @returns the VertexData of the Polygon
  86144. */
  86145. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86146. /**
  86147. * Creates the VertexData of the IcoSphere
  86148. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86149. * * radius the radius of the IcoSphere, optional default 1
  86150. * * radiusX allows stretching in the x direction, optional, default radius
  86151. * * radiusY allows stretching in the y direction, optional, default radius
  86152. * * radiusZ allows stretching in the z direction, optional, default radius
  86153. * * flat when true creates a flat shaded mesh, optional, default true
  86154. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86156. * * 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)
  86157. * * 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)
  86158. * @returns the VertexData of the IcoSphere
  86159. */
  86160. static CreateIcoSphere(options: {
  86161. radius?: number;
  86162. radiusX?: number;
  86163. radiusY?: number;
  86164. radiusZ?: number;
  86165. flat?: boolean;
  86166. subdivisions?: number;
  86167. sideOrientation?: number;
  86168. frontUVs?: Vector4;
  86169. backUVs?: Vector4;
  86170. }): VertexData;
  86171. /**
  86172. * Creates the VertexData for a Polyhedron
  86173. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86174. * * type provided types are:
  86175. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86176. * * 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)
  86177. * * size the size of the IcoSphere, optional default 1
  86178. * * sizeX allows stretching in the x direction, optional, default size
  86179. * * sizeY allows stretching in the y direction, optional, default size
  86180. * * sizeZ allows stretching in the z direction, optional, default size
  86181. * * 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
  86182. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86183. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86184. * * flat when true creates a flat shaded mesh, optional, default true
  86185. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86187. * * 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)
  86188. * * 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)
  86189. * @returns the VertexData of the Polyhedron
  86190. */
  86191. static CreatePolyhedron(options: {
  86192. type?: number;
  86193. size?: number;
  86194. sizeX?: number;
  86195. sizeY?: number;
  86196. sizeZ?: number;
  86197. custom?: any;
  86198. faceUV?: Vector4[];
  86199. faceColors?: Color4[];
  86200. flat?: boolean;
  86201. sideOrientation?: number;
  86202. frontUVs?: Vector4;
  86203. backUVs?: Vector4;
  86204. }): VertexData;
  86205. /**
  86206. * Creates the VertexData for a TorusKnot
  86207. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86208. * * radius the radius of the torus knot, optional, default 2
  86209. * * tube the thickness of the tube, optional, default 0.5
  86210. * * radialSegments the number of sides on each tube segments, optional, default 32
  86211. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86212. * * p the number of windings around the z axis, optional, default 2
  86213. * * q the number of windings around the x axis, optional, default 3
  86214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86215. * * 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)
  86216. * * 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)
  86217. * @returns the VertexData of the Torus Knot
  86218. */
  86219. static CreateTorusKnot(options: {
  86220. radius?: number;
  86221. tube?: number;
  86222. radialSegments?: number;
  86223. tubularSegments?: number;
  86224. p?: number;
  86225. q?: number;
  86226. sideOrientation?: number;
  86227. frontUVs?: Vector4;
  86228. backUVs?: Vector4;
  86229. }): VertexData;
  86230. /**
  86231. * Compute normals for given positions and indices
  86232. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86233. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86234. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86235. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86236. * * facetNormals : optional array of facet normals (vector3)
  86237. * * facetPositions : optional array of facet positions (vector3)
  86238. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86239. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86240. * * bInfo : optional bounding info, required for facetPartitioning computation
  86241. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86242. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86243. * * useRightHandedSystem: optional boolean to for right handed system computation
  86244. * * depthSort : optional boolean to enable the facet depth sort computation
  86245. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86246. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86247. */
  86248. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86249. facetNormals?: any;
  86250. facetPositions?: any;
  86251. facetPartitioning?: any;
  86252. ratio?: number;
  86253. bInfo?: any;
  86254. bbSize?: Vector3;
  86255. subDiv?: any;
  86256. useRightHandedSystem?: boolean;
  86257. depthSort?: boolean;
  86258. distanceTo?: Vector3;
  86259. depthSortedFacets?: any;
  86260. }): void;
  86261. /** @hidden */
  86262. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86263. /**
  86264. * Applies VertexData created from the imported parameters to the geometry
  86265. * @param parsedVertexData the parsed data from an imported file
  86266. * @param geometry the geometry to apply the VertexData to
  86267. */
  86268. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86269. }
  86270. }
  86271. declare module BABYLON {
  86272. /**
  86273. * Defines a target to use with MorphTargetManager
  86274. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86275. */
  86276. export class MorphTarget implements IAnimatable {
  86277. /** defines the name of the target */
  86278. name: string;
  86279. /**
  86280. * Gets or sets the list of animations
  86281. */
  86282. animations: Animation[];
  86283. private _scene;
  86284. private _positions;
  86285. private _normals;
  86286. private _tangents;
  86287. private _uvs;
  86288. private _influence;
  86289. /**
  86290. * Observable raised when the influence changes
  86291. */
  86292. onInfluenceChanged: Observable<boolean>;
  86293. /** @hidden */
  86294. _onDataLayoutChanged: Observable<void>;
  86295. /**
  86296. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86297. */
  86298. influence: number;
  86299. /**
  86300. * Gets or sets the id of the morph Target
  86301. */
  86302. id: string;
  86303. private _animationPropertiesOverride;
  86304. /**
  86305. * Gets or sets the animation properties override
  86306. */
  86307. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86308. /**
  86309. * Creates a new MorphTarget
  86310. * @param name defines the name of the target
  86311. * @param influence defines the influence to use
  86312. * @param scene defines the scene the morphtarget belongs to
  86313. */
  86314. constructor(
  86315. /** defines the name of the target */
  86316. name: string, influence?: number, scene?: Nullable<Scene>);
  86317. /**
  86318. * Gets a boolean defining if the target contains position data
  86319. */
  86320. readonly hasPositions: boolean;
  86321. /**
  86322. * Gets a boolean defining if the target contains normal data
  86323. */
  86324. readonly hasNormals: boolean;
  86325. /**
  86326. * Gets a boolean defining if the target contains tangent data
  86327. */
  86328. readonly hasTangents: boolean;
  86329. /**
  86330. * Gets a boolean defining if the target contains texture coordinates data
  86331. */
  86332. readonly hasUVs: boolean;
  86333. /**
  86334. * Affects position data to this target
  86335. * @param data defines the position data to use
  86336. */
  86337. setPositions(data: Nullable<FloatArray>): void;
  86338. /**
  86339. * Gets the position data stored in this target
  86340. * @returns a FloatArray containing the position data (or null if not present)
  86341. */
  86342. getPositions(): Nullable<FloatArray>;
  86343. /**
  86344. * Affects normal data to this target
  86345. * @param data defines the normal data to use
  86346. */
  86347. setNormals(data: Nullable<FloatArray>): void;
  86348. /**
  86349. * Gets the normal data stored in this target
  86350. * @returns a FloatArray containing the normal data (or null if not present)
  86351. */
  86352. getNormals(): Nullable<FloatArray>;
  86353. /**
  86354. * Affects tangent data to this target
  86355. * @param data defines the tangent data to use
  86356. */
  86357. setTangents(data: Nullable<FloatArray>): void;
  86358. /**
  86359. * Gets the tangent data stored in this target
  86360. * @returns a FloatArray containing the tangent data (or null if not present)
  86361. */
  86362. getTangents(): Nullable<FloatArray>;
  86363. /**
  86364. * Affects texture coordinates data to this target
  86365. * @param data defines the texture coordinates data to use
  86366. */
  86367. setUVs(data: Nullable<FloatArray>): void;
  86368. /**
  86369. * Gets the texture coordinates data stored in this target
  86370. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86371. */
  86372. getUVs(): Nullable<FloatArray>;
  86373. /**
  86374. * Serializes the current target into a Serialization object
  86375. * @returns the serialized object
  86376. */
  86377. serialize(): any;
  86378. /**
  86379. * Returns the string "MorphTarget"
  86380. * @returns "MorphTarget"
  86381. */
  86382. getClassName(): string;
  86383. /**
  86384. * Creates a new target from serialized data
  86385. * @param serializationObject defines the serialized data to use
  86386. * @returns a new MorphTarget
  86387. */
  86388. static Parse(serializationObject: any): MorphTarget;
  86389. /**
  86390. * Creates a MorphTarget from mesh data
  86391. * @param mesh defines the source mesh
  86392. * @param name defines the name to use for the new target
  86393. * @param influence defines the influence to attach to the target
  86394. * @returns a new MorphTarget
  86395. */
  86396. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86397. }
  86398. }
  86399. declare module BABYLON {
  86400. /**
  86401. * This class is used to deform meshes using morphing between different targets
  86402. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86403. */
  86404. export class MorphTargetManager {
  86405. private _targets;
  86406. private _targetInfluenceChangedObservers;
  86407. private _targetDataLayoutChangedObservers;
  86408. private _activeTargets;
  86409. private _scene;
  86410. private _influences;
  86411. private _supportsNormals;
  86412. private _supportsTangents;
  86413. private _supportsUVs;
  86414. private _vertexCount;
  86415. private _uniqueId;
  86416. private _tempInfluences;
  86417. /**
  86418. * Gets or sets a boolean indicating if normals must be morphed
  86419. */
  86420. enableNormalMorphing: boolean;
  86421. /**
  86422. * Gets or sets a boolean indicating if tangents must be morphed
  86423. */
  86424. enableTangentMorphing: boolean;
  86425. /**
  86426. * Gets or sets a boolean indicating if UV must be morphed
  86427. */
  86428. enableUVMorphing: boolean;
  86429. /**
  86430. * Creates a new MorphTargetManager
  86431. * @param scene defines the current scene
  86432. */
  86433. constructor(scene?: Nullable<Scene>);
  86434. /**
  86435. * Gets the unique ID of this manager
  86436. */
  86437. readonly uniqueId: number;
  86438. /**
  86439. * Gets the number of vertices handled by this manager
  86440. */
  86441. readonly vertexCount: number;
  86442. /**
  86443. * Gets a boolean indicating if this manager supports morphing of normals
  86444. */
  86445. readonly supportsNormals: boolean;
  86446. /**
  86447. * Gets a boolean indicating if this manager supports morphing of tangents
  86448. */
  86449. readonly supportsTangents: boolean;
  86450. /**
  86451. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86452. */
  86453. readonly supportsUVs: boolean;
  86454. /**
  86455. * Gets the number of targets stored in this manager
  86456. */
  86457. readonly numTargets: number;
  86458. /**
  86459. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86460. */
  86461. readonly numInfluencers: number;
  86462. /**
  86463. * Gets the list of influences (one per target)
  86464. */
  86465. readonly influences: Float32Array;
  86466. /**
  86467. * Gets the active target at specified index. An active target is a target with an influence > 0
  86468. * @param index defines the index to check
  86469. * @returns the requested target
  86470. */
  86471. getActiveTarget(index: number): MorphTarget;
  86472. /**
  86473. * Gets the target at specified index
  86474. * @param index defines the index to check
  86475. * @returns the requested target
  86476. */
  86477. getTarget(index: number): MorphTarget;
  86478. /**
  86479. * Add a new target to this manager
  86480. * @param target defines the target to add
  86481. */
  86482. addTarget(target: MorphTarget): void;
  86483. /**
  86484. * Removes a target from the manager
  86485. * @param target defines the target to remove
  86486. */
  86487. removeTarget(target: MorphTarget): void;
  86488. /**
  86489. * Serializes the current manager into a Serialization object
  86490. * @returns the serialized object
  86491. */
  86492. serialize(): any;
  86493. private _syncActiveTargets;
  86494. /**
  86495. * Syncrhonize the targets with all the meshes using this morph target manager
  86496. */
  86497. synchronize(): void;
  86498. /**
  86499. * Creates a new MorphTargetManager from serialized data
  86500. * @param serializationObject defines the serialized data
  86501. * @param scene defines the hosting scene
  86502. * @returns the new MorphTargetManager
  86503. */
  86504. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86505. }
  86506. }
  86507. declare module BABYLON {
  86508. /**
  86509. * Class used to represent a specific level of detail of a mesh
  86510. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86511. */
  86512. export class MeshLODLevel {
  86513. /** Defines the distance where this level should star being displayed */
  86514. distance: number;
  86515. /** Defines the mesh to use to render this level */
  86516. mesh: Nullable<Mesh>;
  86517. /**
  86518. * Creates a new LOD level
  86519. * @param distance defines the distance where this level should star being displayed
  86520. * @param mesh defines the mesh to use to render this level
  86521. */
  86522. constructor(
  86523. /** Defines the distance where this level should star being displayed */
  86524. distance: number,
  86525. /** Defines the mesh to use to render this level */
  86526. mesh: Nullable<Mesh>);
  86527. }
  86528. }
  86529. declare module BABYLON {
  86530. /**
  86531. * Mesh representing the gorund
  86532. */
  86533. export class GroundMesh extends Mesh {
  86534. /** If octree should be generated */
  86535. generateOctree: boolean;
  86536. private _heightQuads;
  86537. /** @hidden */
  86538. _subdivisionsX: number;
  86539. /** @hidden */
  86540. _subdivisionsY: number;
  86541. /** @hidden */
  86542. _width: number;
  86543. /** @hidden */
  86544. _height: number;
  86545. /** @hidden */
  86546. _minX: number;
  86547. /** @hidden */
  86548. _maxX: number;
  86549. /** @hidden */
  86550. _minZ: number;
  86551. /** @hidden */
  86552. _maxZ: number;
  86553. constructor(name: string, scene: Scene);
  86554. /**
  86555. * "GroundMesh"
  86556. * @returns "GroundMesh"
  86557. */
  86558. getClassName(): string;
  86559. /**
  86560. * The minimum of x and y subdivisions
  86561. */
  86562. readonly subdivisions: number;
  86563. /**
  86564. * X subdivisions
  86565. */
  86566. readonly subdivisionsX: number;
  86567. /**
  86568. * Y subdivisions
  86569. */
  86570. readonly subdivisionsY: number;
  86571. /**
  86572. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86573. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86574. * @param chunksCount the number of subdivisions for x and y
  86575. * @param octreeBlocksSize (Default: 32)
  86576. */
  86577. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86578. /**
  86579. * Returns a height (y) value in the Worl system :
  86580. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86581. * @param x x coordinate
  86582. * @param z z coordinate
  86583. * @returns the ground y position if (x, z) are outside the ground surface.
  86584. */
  86585. getHeightAtCoordinates(x: number, z: number): number;
  86586. /**
  86587. * Returns a normalized vector (Vector3) orthogonal to the ground
  86588. * at the ground coordinates (x, z) expressed in the World system.
  86589. * @param x x coordinate
  86590. * @param z z coordinate
  86591. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86592. */
  86593. getNormalAtCoordinates(x: number, z: number): Vector3;
  86594. /**
  86595. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86596. * at the ground coordinates (x, z) expressed in the World system.
  86597. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86598. * @param x x coordinate
  86599. * @param z z coordinate
  86600. * @param ref vector to store the result
  86601. * @returns the GroundMesh.
  86602. */
  86603. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86604. /**
  86605. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86606. * if the ground has been updated.
  86607. * This can be used in the render loop.
  86608. * @returns the GroundMesh.
  86609. */
  86610. updateCoordinateHeights(): GroundMesh;
  86611. private _getFacetAt;
  86612. private _initHeightQuads;
  86613. private _computeHeightQuads;
  86614. /**
  86615. * Serializes this ground mesh
  86616. * @param serializationObject object to write serialization to
  86617. */
  86618. serialize(serializationObject: any): void;
  86619. /**
  86620. * Parses a serialized ground mesh
  86621. * @param parsedMesh the serialized mesh
  86622. * @param scene the scene to create the ground mesh in
  86623. * @returns the created ground mesh
  86624. */
  86625. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86626. }
  86627. }
  86628. declare module BABYLON {
  86629. /**
  86630. * Interface for Physics-Joint data
  86631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86632. */
  86633. export interface PhysicsJointData {
  86634. /**
  86635. * The main pivot of the joint
  86636. */
  86637. mainPivot?: Vector3;
  86638. /**
  86639. * The connected pivot of the joint
  86640. */
  86641. connectedPivot?: Vector3;
  86642. /**
  86643. * The main axis of the joint
  86644. */
  86645. mainAxis?: Vector3;
  86646. /**
  86647. * The connected axis of the joint
  86648. */
  86649. connectedAxis?: Vector3;
  86650. /**
  86651. * The collision of the joint
  86652. */
  86653. collision?: boolean;
  86654. /**
  86655. * Native Oimo/Cannon/Energy data
  86656. */
  86657. nativeParams?: any;
  86658. }
  86659. /**
  86660. * This is a holder class for the physics joint created by the physics plugin
  86661. * It holds a set of functions to control the underlying joint
  86662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86663. */
  86664. export class PhysicsJoint {
  86665. /**
  86666. * The type of the physics joint
  86667. */
  86668. type: number;
  86669. /**
  86670. * The data for the physics joint
  86671. */
  86672. jointData: PhysicsJointData;
  86673. private _physicsJoint;
  86674. protected _physicsPlugin: IPhysicsEnginePlugin;
  86675. /**
  86676. * Initializes the physics joint
  86677. * @param type The type of the physics joint
  86678. * @param jointData The data for the physics joint
  86679. */
  86680. constructor(
  86681. /**
  86682. * The type of the physics joint
  86683. */
  86684. type: number,
  86685. /**
  86686. * The data for the physics joint
  86687. */
  86688. jointData: PhysicsJointData);
  86689. /**
  86690. * Gets the physics joint
  86691. */
  86692. /**
  86693. * Sets the physics joint
  86694. */
  86695. physicsJoint: any;
  86696. /**
  86697. * Sets the physics plugin
  86698. */
  86699. physicsPlugin: IPhysicsEnginePlugin;
  86700. /**
  86701. * Execute a function that is physics-plugin specific.
  86702. * @param {Function} func the function that will be executed.
  86703. * It accepts two parameters: the physics world and the physics joint
  86704. */
  86705. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86706. /**
  86707. * Distance-Joint type
  86708. */
  86709. static DistanceJoint: number;
  86710. /**
  86711. * Hinge-Joint type
  86712. */
  86713. static HingeJoint: number;
  86714. /**
  86715. * Ball-and-Socket joint type
  86716. */
  86717. static BallAndSocketJoint: number;
  86718. /**
  86719. * Wheel-Joint type
  86720. */
  86721. static WheelJoint: number;
  86722. /**
  86723. * Slider-Joint type
  86724. */
  86725. static SliderJoint: number;
  86726. /**
  86727. * Prismatic-Joint type
  86728. */
  86729. static PrismaticJoint: number;
  86730. /**
  86731. * Universal-Joint type
  86732. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86733. */
  86734. static UniversalJoint: number;
  86735. /**
  86736. * Hinge-Joint 2 type
  86737. */
  86738. static Hinge2Joint: number;
  86739. /**
  86740. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86741. */
  86742. static PointToPointJoint: number;
  86743. /**
  86744. * Spring-Joint type
  86745. */
  86746. static SpringJoint: number;
  86747. /**
  86748. * Lock-Joint type
  86749. */
  86750. static LockJoint: number;
  86751. }
  86752. /**
  86753. * A class representing a physics distance joint
  86754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86755. */
  86756. export class DistanceJoint extends PhysicsJoint {
  86757. /**
  86758. *
  86759. * @param jointData The data for the Distance-Joint
  86760. */
  86761. constructor(jointData: DistanceJointData);
  86762. /**
  86763. * Update the predefined distance.
  86764. * @param maxDistance The maximum preferred distance
  86765. * @param minDistance The minimum preferred distance
  86766. */
  86767. updateDistance(maxDistance: number, minDistance?: number): void;
  86768. }
  86769. /**
  86770. * Represents a Motor-Enabled Joint
  86771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86772. */
  86773. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86774. /**
  86775. * Initializes the Motor-Enabled Joint
  86776. * @param type The type of the joint
  86777. * @param jointData The physica joint data for the joint
  86778. */
  86779. constructor(type: number, jointData: PhysicsJointData);
  86780. /**
  86781. * Set the motor values.
  86782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86783. * @param force the force to apply
  86784. * @param maxForce max force for this motor.
  86785. */
  86786. setMotor(force?: number, maxForce?: number): void;
  86787. /**
  86788. * Set the motor's limits.
  86789. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86790. * @param upperLimit The upper limit of the motor
  86791. * @param lowerLimit The lower limit of the motor
  86792. */
  86793. setLimit(upperLimit: number, lowerLimit?: number): void;
  86794. }
  86795. /**
  86796. * This class represents a single physics Hinge-Joint
  86797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86798. */
  86799. export class HingeJoint extends MotorEnabledJoint {
  86800. /**
  86801. * Initializes the Hinge-Joint
  86802. * @param jointData The joint data for the Hinge-Joint
  86803. */
  86804. constructor(jointData: PhysicsJointData);
  86805. /**
  86806. * Set the motor values.
  86807. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86808. * @param {number} force the force to apply
  86809. * @param {number} maxForce max force for this motor.
  86810. */
  86811. setMotor(force?: number, maxForce?: number): void;
  86812. /**
  86813. * Set the motor's limits.
  86814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86815. * @param upperLimit The upper limit of the motor
  86816. * @param lowerLimit The lower limit of the motor
  86817. */
  86818. setLimit(upperLimit: number, lowerLimit?: number): void;
  86819. }
  86820. /**
  86821. * This class represents a dual hinge physics joint (same as wheel joint)
  86822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86823. */
  86824. export class Hinge2Joint extends MotorEnabledJoint {
  86825. /**
  86826. * Initializes the Hinge2-Joint
  86827. * @param jointData The joint data for the Hinge2-Joint
  86828. */
  86829. constructor(jointData: PhysicsJointData);
  86830. /**
  86831. * Set the motor values.
  86832. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86833. * @param {number} targetSpeed the speed the motor is to reach
  86834. * @param {number} maxForce max force for this motor.
  86835. * @param {motorIndex} the motor's index, 0 or 1.
  86836. */
  86837. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86838. /**
  86839. * Set the motor limits.
  86840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86841. * @param {number} upperLimit the upper limit
  86842. * @param {number} lowerLimit lower limit
  86843. * @param {motorIndex} the motor's index, 0 or 1.
  86844. */
  86845. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86846. }
  86847. /**
  86848. * Interface for a motor enabled joint
  86849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86850. */
  86851. export interface IMotorEnabledJoint {
  86852. /**
  86853. * Physics joint
  86854. */
  86855. physicsJoint: any;
  86856. /**
  86857. * Sets the motor of the motor-enabled joint
  86858. * @param force The force of the motor
  86859. * @param maxForce The maximum force of the motor
  86860. * @param motorIndex The index of the motor
  86861. */
  86862. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86863. /**
  86864. * Sets the limit of the motor
  86865. * @param upperLimit The upper limit of the motor
  86866. * @param lowerLimit The lower limit of the motor
  86867. * @param motorIndex The index of the motor
  86868. */
  86869. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86870. }
  86871. /**
  86872. * Joint data for a Distance-Joint
  86873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86874. */
  86875. export interface DistanceJointData extends PhysicsJointData {
  86876. /**
  86877. * Max distance the 2 joint objects can be apart
  86878. */
  86879. maxDistance: number;
  86880. }
  86881. /**
  86882. * Joint data from a spring joint
  86883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86884. */
  86885. export interface SpringJointData extends PhysicsJointData {
  86886. /**
  86887. * Length of the spring
  86888. */
  86889. length: number;
  86890. /**
  86891. * Stiffness of the spring
  86892. */
  86893. stiffness: number;
  86894. /**
  86895. * Damping of the spring
  86896. */
  86897. damping: number;
  86898. /** this callback will be called when applying the force to the impostors. */
  86899. forceApplicationCallback: () => void;
  86900. }
  86901. }
  86902. declare module BABYLON {
  86903. /**
  86904. * Holds the data for the raycast result
  86905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86906. */
  86907. export class PhysicsRaycastResult {
  86908. private _hasHit;
  86909. private _hitDistance;
  86910. private _hitNormalWorld;
  86911. private _hitPointWorld;
  86912. private _rayFromWorld;
  86913. private _rayToWorld;
  86914. /**
  86915. * Gets if there was a hit
  86916. */
  86917. readonly hasHit: boolean;
  86918. /**
  86919. * Gets the distance from the hit
  86920. */
  86921. readonly hitDistance: number;
  86922. /**
  86923. * Gets the hit normal/direction in the world
  86924. */
  86925. readonly hitNormalWorld: Vector3;
  86926. /**
  86927. * Gets the hit point in the world
  86928. */
  86929. readonly hitPointWorld: Vector3;
  86930. /**
  86931. * Gets the ray "start point" of the ray in the world
  86932. */
  86933. readonly rayFromWorld: Vector3;
  86934. /**
  86935. * Gets the ray "end point" of the ray in the world
  86936. */
  86937. readonly rayToWorld: Vector3;
  86938. /**
  86939. * Sets the hit data (normal & point in world space)
  86940. * @param hitNormalWorld defines the normal in world space
  86941. * @param hitPointWorld defines the point in world space
  86942. */
  86943. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86944. /**
  86945. * Sets the distance from the start point to the hit point
  86946. * @param distance
  86947. */
  86948. setHitDistance(distance: number): void;
  86949. /**
  86950. * Calculates the distance manually
  86951. */
  86952. calculateHitDistance(): void;
  86953. /**
  86954. * Resets all the values to default
  86955. * @param from The from point on world space
  86956. * @param to The to point on world space
  86957. */
  86958. reset(from?: Vector3, to?: Vector3): void;
  86959. }
  86960. /**
  86961. * Interface for the size containing width and height
  86962. */
  86963. interface IXYZ {
  86964. /**
  86965. * X
  86966. */
  86967. x: number;
  86968. /**
  86969. * Y
  86970. */
  86971. y: number;
  86972. /**
  86973. * Z
  86974. */
  86975. z: number;
  86976. }
  86977. }
  86978. declare module BABYLON {
  86979. /**
  86980. * Interface used to describe a physics joint
  86981. */
  86982. export interface PhysicsImpostorJoint {
  86983. /** Defines the main impostor to which the joint is linked */
  86984. mainImpostor: PhysicsImpostor;
  86985. /** Defines the impostor that is connected to the main impostor using this joint */
  86986. connectedImpostor: PhysicsImpostor;
  86987. /** Defines the joint itself */
  86988. joint: PhysicsJoint;
  86989. }
  86990. /** @hidden */
  86991. export interface IPhysicsEnginePlugin {
  86992. world: any;
  86993. name: string;
  86994. setGravity(gravity: Vector3): void;
  86995. setTimeStep(timeStep: number): void;
  86996. getTimeStep(): number;
  86997. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86998. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86999. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87000. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87001. removePhysicsBody(impostor: PhysicsImpostor): void;
  87002. generateJoint(joint: PhysicsImpostorJoint): void;
  87003. removeJoint(joint: PhysicsImpostorJoint): void;
  87004. isSupported(): boolean;
  87005. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87006. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87007. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87008. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87009. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87010. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87011. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87012. getBodyMass(impostor: PhysicsImpostor): number;
  87013. getBodyFriction(impostor: PhysicsImpostor): number;
  87014. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87015. getBodyRestitution(impostor: PhysicsImpostor): number;
  87016. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87017. getBodyPressure?(impostor: PhysicsImpostor): number;
  87018. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87019. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87020. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87021. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87022. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87023. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87024. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87025. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87026. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87027. sleepBody(impostor: PhysicsImpostor): void;
  87028. wakeUpBody(impostor: PhysicsImpostor): void;
  87029. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87030. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87031. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87032. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87033. getRadius(impostor: PhysicsImpostor): number;
  87034. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87035. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87036. dispose(): void;
  87037. }
  87038. /**
  87039. * Interface used to define a physics engine
  87040. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87041. */
  87042. export interface IPhysicsEngine {
  87043. /**
  87044. * Gets the gravity vector used by the simulation
  87045. */
  87046. gravity: Vector3;
  87047. /**
  87048. * Sets the gravity vector used by the simulation
  87049. * @param gravity defines the gravity vector to use
  87050. */
  87051. setGravity(gravity: Vector3): void;
  87052. /**
  87053. * Set the time step of the physics engine.
  87054. * Default is 1/60.
  87055. * To slow it down, enter 1/600 for example.
  87056. * To speed it up, 1/30
  87057. * @param newTimeStep the new timestep to apply to this world.
  87058. */
  87059. setTimeStep(newTimeStep: number): void;
  87060. /**
  87061. * Get the time step of the physics engine.
  87062. * @returns the current time step
  87063. */
  87064. getTimeStep(): number;
  87065. /**
  87066. * Release all resources
  87067. */
  87068. dispose(): void;
  87069. /**
  87070. * Gets the name of the current physics plugin
  87071. * @returns the name of the plugin
  87072. */
  87073. getPhysicsPluginName(): string;
  87074. /**
  87075. * Adding a new impostor for the impostor tracking.
  87076. * This will be done by the impostor itself.
  87077. * @param impostor the impostor to add
  87078. */
  87079. addImpostor(impostor: PhysicsImpostor): void;
  87080. /**
  87081. * Remove an impostor from the engine.
  87082. * This impostor and its mesh will not longer be updated by the physics engine.
  87083. * @param impostor the impostor to remove
  87084. */
  87085. removeImpostor(impostor: PhysicsImpostor): void;
  87086. /**
  87087. * Add a joint to the physics engine
  87088. * @param mainImpostor defines the main impostor to which the joint is added.
  87089. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87090. * @param joint defines the joint that will connect both impostors.
  87091. */
  87092. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87093. /**
  87094. * Removes a joint from the simulation
  87095. * @param mainImpostor defines the impostor used with the joint
  87096. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87097. * @param joint defines the joint to remove
  87098. */
  87099. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87100. /**
  87101. * Gets the current plugin used to run the simulation
  87102. * @returns current plugin
  87103. */
  87104. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87105. /**
  87106. * Gets the list of physic impostors
  87107. * @returns an array of PhysicsImpostor
  87108. */
  87109. getImpostors(): Array<PhysicsImpostor>;
  87110. /**
  87111. * Gets the impostor for a physics enabled object
  87112. * @param object defines the object impersonated by the impostor
  87113. * @returns the PhysicsImpostor or null if not found
  87114. */
  87115. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87116. /**
  87117. * Gets the impostor for a physics body object
  87118. * @param body defines physics body used by the impostor
  87119. * @returns the PhysicsImpostor or null if not found
  87120. */
  87121. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87122. /**
  87123. * Does a raycast in the physics world
  87124. * @param from when should the ray start?
  87125. * @param to when should the ray end?
  87126. * @returns PhysicsRaycastResult
  87127. */
  87128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87129. /**
  87130. * Called by the scene. No need to call it.
  87131. * @param delta defines the timespam between frames
  87132. */
  87133. _step(delta: number): void;
  87134. }
  87135. }
  87136. declare module BABYLON {
  87137. /**
  87138. * The interface for the physics imposter parameters
  87139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87140. */
  87141. export interface PhysicsImpostorParameters {
  87142. /**
  87143. * The mass of the physics imposter
  87144. */
  87145. mass: number;
  87146. /**
  87147. * The friction of the physics imposter
  87148. */
  87149. friction?: number;
  87150. /**
  87151. * The coefficient of restitution of the physics imposter
  87152. */
  87153. restitution?: number;
  87154. /**
  87155. * The native options of the physics imposter
  87156. */
  87157. nativeOptions?: any;
  87158. /**
  87159. * Specifies if the parent should be ignored
  87160. */
  87161. ignoreParent?: boolean;
  87162. /**
  87163. * Specifies if bi-directional transformations should be disabled
  87164. */
  87165. disableBidirectionalTransformation?: boolean;
  87166. /**
  87167. * The pressure inside the physics imposter, soft object only
  87168. */
  87169. pressure?: number;
  87170. /**
  87171. * The stiffness the physics imposter, soft object only
  87172. */
  87173. stiffness?: number;
  87174. /**
  87175. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87176. */
  87177. velocityIterations?: number;
  87178. /**
  87179. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87180. */
  87181. positionIterations?: number;
  87182. /**
  87183. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87184. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87185. * Add to fix multiple points
  87186. */
  87187. fixedPoints?: number;
  87188. /**
  87189. * The collision margin around a soft object
  87190. */
  87191. margin?: number;
  87192. /**
  87193. * The collision margin around a soft object
  87194. */
  87195. damping?: number;
  87196. /**
  87197. * The path for a rope based on an extrusion
  87198. */
  87199. path?: any;
  87200. /**
  87201. * The shape of an extrusion used for a rope based on an extrusion
  87202. */
  87203. shape?: any;
  87204. }
  87205. /**
  87206. * Interface for a physics-enabled object
  87207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87208. */
  87209. export interface IPhysicsEnabledObject {
  87210. /**
  87211. * The position of the physics-enabled object
  87212. */
  87213. position: Vector3;
  87214. /**
  87215. * The rotation of the physics-enabled object
  87216. */
  87217. rotationQuaternion: Nullable<Quaternion>;
  87218. /**
  87219. * The scale of the physics-enabled object
  87220. */
  87221. scaling: Vector3;
  87222. /**
  87223. * The rotation of the physics-enabled object
  87224. */
  87225. rotation?: Vector3;
  87226. /**
  87227. * The parent of the physics-enabled object
  87228. */
  87229. parent?: any;
  87230. /**
  87231. * The bounding info of the physics-enabled object
  87232. * @returns The bounding info of the physics-enabled object
  87233. */
  87234. getBoundingInfo(): BoundingInfo;
  87235. /**
  87236. * Computes the world matrix
  87237. * @param force Specifies if the world matrix should be computed by force
  87238. * @returns A world matrix
  87239. */
  87240. computeWorldMatrix(force: boolean): Matrix;
  87241. /**
  87242. * Gets the world matrix
  87243. * @returns A world matrix
  87244. */
  87245. getWorldMatrix?(): Matrix;
  87246. /**
  87247. * Gets the child meshes
  87248. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87249. * @returns An array of abstract meshes
  87250. */
  87251. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87252. /**
  87253. * Gets the vertex data
  87254. * @param kind The type of vertex data
  87255. * @returns A nullable array of numbers, or a float32 array
  87256. */
  87257. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87258. /**
  87259. * Gets the indices from the mesh
  87260. * @returns A nullable array of index arrays
  87261. */
  87262. getIndices?(): Nullable<IndicesArray>;
  87263. /**
  87264. * Gets the scene from the mesh
  87265. * @returns the indices array or null
  87266. */
  87267. getScene?(): Scene;
  87268. /**
  87269. * Gets the absolute position from the mesh
  87270. * @returns the absolute position
  87271. */
  87272. getAbsolutePosition(): Vector3;
  87273. /**
  87274. * Gets the absolute pivot point from the mesh
  87275. * @returns the absolute pivot point
  87276. */
  87277. getAbsolutePivotPoint(): Vector3;
  87278. /**
  87279. * Rotates the mesh
  87280. * @param axis The axis of rotation
  87281. * @param amount The amount of rotation
  87282. * @param space The space of the rotation
  87283. * @returns The rotation transform node
  87284. */
  87285. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87286. /**
  87287. * Translates the mesh
  87288. * @param axis The axis of translation
  87289. * @param distance The distance of translation
  87290. * @param space The space of the translation
  87291. * @returns The transform node
  87292. */
  87293. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87294. /**
  87295. * Sets the absolute position of the mesh
  87296. * @param absolutePosition The absolute position of the mesh
  87297. * @returns The transform node
  87298. */
  87299. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87300. /**
  87301. * Gets the class name of the mesh
  87302. * @returns The class name
  87303. */
  87304. getClassName(): string;
  87305. }
  87306. /**
  87307. * Represents a physics imposter
  87308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87309. */
  87310. export class PhysicsImpostor {
  87311. /**
  87312. * The physics-enabled object used as the physics imposter
  87313. */
  87314. object: IPhysicsEnabledObject;
  87315. /**
  87316. * The type of the physics imposter
  87317. */
  87318. type: number;
  87319. private _options;
  87320. private _scene?;
  87321. /**
  87322. * The default object size of the imposter
  87323. */
  87324. static DEFAULT_OBJECT_SIZE: Vector3;
  87325. /**
  87326. * The identity quaternion of the imposter
  87327. */
  87328. static IDENTITY_QUATERNION: Quaternion;
  87329. /** @hidden */
  87330. _pluginData: any;
  87331. private _physicsEngine;
  87332. private _physicsBody;
  87333. private _bodyUpdateRequired;
  87334. private _onBeforePhysicsStepCallbacks;
  87335. private _onAfterPhysicsStepCallbacks;
  87336. /** @hidden */
  87337. _onPhysicsCollideCallbacks: Array<{
  87338. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87339. otherImpostors: Array<PhysicsImpostor>;
  87340. }>;
  87341. private _deltaPosition;
  87342. private _deltaRotation;
  87343. private _deltaRotationConjugated;
  87344. /** @hidden */
  87345. _isFromLine: boolean;
  87346. private _parent;
  87347. private _isDisposed;
  87348. private static _tmpVecs;
  87349. private static _tmpQuat;
  87350. /**
  87351. * Specifies if the physics imposter is disposed
  87352. */
  87353. readonly isDisposed: boolean;
  87354. /**
  87355. * Gets the mass of the physics imposter
  87356. */
  87357. mass: number;
  87358. /**
  87359. * Gets the coefficient of friction
  87360. */
  87361. /**
  87362. * Sets the coefficient of friction
  87363. */
  87364. friction: number;
  87365. /**
  87366. * Gets the coefficient of restitution
  87367. */
  87368. /**
  87369. * Sets the coefficient of restitution
  87370. */
  87371. restitution: number;
  87372. /**
  87373. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87374. */
  87375. /**
  87376. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87377. */
  87378. pressure: number;
  87379. /**
  87380. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87381. */
  87382. /**
  87383. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87384. */
  87385. stiffness: number;
  87386. /**
  87387. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87388. */
  87389. /**
  87390. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87391. */
  87392. velocityIterations: number;
  87393. /**
  87394. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87395. */
  87396. /**
  87397. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87398. */
  87399. positionIterations: number;
  87400. /**
  87401. * The unique id of the physics imposter
  87402. * set by the physics engine when adding this impostor to the array
  87403. */
  87404. uniqueId: number;
  87405. /**
  87406. * @hidden
  87407. */
  87408. soft: boolean;
  87409. /**
  87410. * @hidden
  87411. */
  87412. segments: number;
  87413. private _joints;
  87414. /**
  87415. * Initializes the physics imposter
  87416. * @param object The physics-enabled object used as the physics imposter
  87417. * @param type The type of the physics imposter
  87418. * @param _options The options for the physics imposter
  87419. * @param _scene The Babylon scene
  87420. */
  87421. constructor(
  87422. /**
  87423. * The physics-enabled object used as the physics imposter
  87424. */
  87425. object: IPhysicsEnabledObject,
  87426. /**
  87427. * The type of the physics imposter
  87428. */
  87429. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87430. /**
  87431. * This function will completly initialize this impostor.
  87432. * It will create a new body - but only if this mesh has no parent.
  87433. * If it has, this impostor will not be used other than to define the impostor
  87434. * of the child mesh.
  87435. * @hidden
  87436. */
  87437. _init(): void;
  87438. private _getPhysicsParent;
  87439. /**
  87440. * Should a new body be generated.
  87441. * @returns boolean specifying if body initialization is required
  87442. */
  87443. isBodyInitRequired(): boolean;
  87444. /**
  87445. * Sets the updated scaling
  87446. * @param updated Specifies if the scaling is updated
  87447. */
  87448. setScalingUpdated(): void;
  87449. /**
  87450. * Force a regeneration of this or the parent's impostor's body.
  87451. * Use under cautious - This will remove all joints already implemented.
  87452. */
  87453. forceUpdate(): void;
  87454. /**
  87455. * Gets the body that holds this impostor. Either its own, or its parent.
  87456. */
  87457. /**
  87458. * Set the physics body. Used mainly by the physics engine/plugin
  87459. */
  87460. physicsBody: any;
  87461. /**
  87462. * Get the parent of the physics imposter
  87463. * @returns Physics imposter or null
  87464. */
  87465. /**
  87466. * Sets the parent of the physics imposter
  87467. */
  87468. parent: Nullable<PhysicsImpostor>;
  87469. /**
  87470. * Resets the update flags
  87471. */
  87472. resetUpdateFlags(): void;
  87473. /**
  87474. * Gets the object extend size
  87475. * @returns the object extend size
  87476. */
  87477. getObjectExtendSize(): Vector3;
  87478. /**
  87479. * Gets the object center
  87480. * @returns The object center
  87481. */
  87482. getObjectCenter(): Vector3;
  87483. /**
  87484. * Get a specific parametes from the options parameter
  87485. * @param paramName The object parameter name
  87486. * @returns The object parameter
  87487. */
  87488. getParam(paramName: string): any;
  87489. /**
  87490. * Sets a specific parameter in the options given to the physics plugin
  87491. * @param paramName The parameter name
  87492. * @param value The value of the parameter
  87493. */
  87494. setParam(paramName: string, value: number): void;
  87495. /**
  87496. * Specifically change the body's mass option. Won't recreate the physics body object
  87497. * @param mass The mass of the physics imposter
  87498. */
  87499. setMass(mass: number): void;
  87500. /**
  87501. * Gets the linear velocity
  87502. * @returns linear velocity or null
  87503. */
  87504. getLinearVelocity(): Nullable<Vector3>;
  87505. /**
  87506. * Sets the linear velocity
  87507. * @param velocity linear velocity or null
  87508. */
  87509. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87510. /**
  87511. * Gets the angular velocity
  87512. * @returns angular velocity or null
  87513. */
  87514. getAngularVelocity(): Nullable<Vector3>;
  87515. /**
  87516. * Sets the angular velocity
  87517. * @param velocity The velocity or null
  87518. */
  87519. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87520. /**
  87521. * Execute a function with the physics plugin native code
  87522. * Provide a function the will have two variables - the world object and the physics body object
  87523. * @param func The function to execute with the physics plugin native code
  87524. */
  87525. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87526. /**
  87527. * Register a function that will be executed before the physics world is stepping forward
  87528. * @param func The function to execute before the physics world is stepped forward
  87529. */
  87530. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87531. /**
  87532. * Unregister a function that will be executed before the physics world is stepping forward
  87533. * @param func The function to execute before the physics world is stepped forward
  87534. */
  87535. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87536. /**
  87537. * Register a function that will be executed after the physics step
  87538. * @param func The function to execute after physics step
  87539. */
  87540. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87541. /**
  87542. * Unregisters a function that will be executed after the physics step
  87543. * @param func The function to execute after physics step
  87544. */
  87545. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87546. /**
  87547. * register a function that will be executed when this impostor collides against a different body
  87548. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87549. * @param func Callback that is executed on collision
  87550. */
  87551. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87552. /**
  87553. * Unregisters the physics imposter on contact
  87554. * @param collideAgainst The physics object to collide against
  87555. * @param func Callback to execute on collision
  87556. */
  87557. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87558. private _tmpQuat;
  87559. private _tmpQuat2;
  87560. /**
  87561. * Get the parent rotation
  87562. * @returns The parent rotation
  87563. */
  87564. getParentsRotation(): Quaternion;
  87565. /**
  87566. * this function is executed by the physics engine.
  87567. */
  87568. beforeStep: () => void;
  87569. /**
  87570. * this function is executed by the physics engine
  87571. */
  87572. afterStep: () => void;
  87573. /**
  87574. * Legacy collision detection event support
  87575. */
  87576. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87577. /**
  87578. * event and body object due to cannon's event-based architecture.
  87579. */
  87580. onCollide: (e: {
  87581. body: any;
  87582. }) => void;
  87583. /**
  87584. * Apply a force
  87585. * @param force The force to apply
  87586. * @param contactPoint The contact point for the force
  87587. * @returns The physics imposter
  87588. */
  87589. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87590. /**
  87591. * Apply an impulse
  87592. * @param force The impulse force
  87593. * @param contactPoint The contact point for the impulse force
  87594. * @returns The physics imposter
  87595. */
  87596. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87597. /**
  87598. * A help function to create a joint
  87599. * @param otherImpostor A physics imposter used to create a joint
  87600. * @param jointType The type of joint
  87601. * @param jointData The data for the joint
  87602. * @returns The physics imposter
  87603. */
  87604. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87605. /**
  87606. * Add a joint to this impostor with a different impostor
  87607. * @param otherImpostor A physics imposter used to add a joint
  87608. * @param joint The joint to add
  87609. * @returns The physics imposter
  87610. */
  87611. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87612. /**
  87613. * Add an anchor to a cloth impostor
  87614. * @param otherImpostor rigid impostor to anchor to
  87615. * @param width ratio across width from 0 to 1
  87616. * @param height ratio up height from 0 to 1
  87617. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87618. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87619. * @returns impostor the soft imposter
  87620. */
  87621. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87622. /**
  87623. * Add a hook to a rope impostor
  87624. * @param otherImpostor rigid impostor to anchor to
  87625. * @param length ratio across rope from 0 to 1
  87626. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87627. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87628. * @returns impostor the rope imposter
  87629. */
  87630. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87631. /**
  87632. * Will keep this body still, in a sleep mode.
  87633. * @returns the physics imposter
  87634. */
  87635. sleep(): PhysicsImpostor;
  87636. /**
  87637. * Wake the body up.
  87638. * @returns The physics imposter
  87639. */
  87640. wakeUp(): PhysicsImpostor;
  87641. /**
  87642. * Clones the physics imposter
  87643. * @param newObject The physics imposter clones to this physics-enabled object
  87644. * @returns A nullable physics imposter
  87645. */
  87646. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87647. /**
  87648. * Disposes the physics imposter
  87649. */
  87650. dispose(): void;
  87651. /**
  87652. * Sets the delta position
  87653. * @param position The delta position amount
  87654. */
  87655. setDeltaPosition(position: Vector3): void;
  87656. /**
  87657. * Sets the delta rotation
  87658. * @param rotation The delta rotation amount
  87659. */
  87660. setDeltaRotation(rotation: Quaternion): void;
  87661. /**
  87662. * Gets the box size of the physics imposter and stores the result in the input parameter
  87663. * @param result Stores the box size
  87664. * @returns The physics imposter
  87665. */
  87666. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87667. /**
  87668. * Gets the radius of the physics imposter
  87669. * @returns Radius of the physics imposter
  87670. */
  87671. getRadius(): number;
  87672. /**
  87673. * Sync a bone with this impostor
  87674. * @param bone The bone to sync to the impostor.
  87675. * @param boneMesh The mesh that the bone is influencing.
  87676. * @param jointPivot The pivot of the joint / bone in local space.
  87677. * @param distToJoint Optional distance from the impostor to the joint.
  87678. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87679. */
  87680. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87681. /**
  87682. * Sync impostor to a bone
  87683. * @param bone The bone that the impostor will be synced to.
  87684. * @param boneMesh The mesh that the bone is influencing.
  87685. * @param jointPivot The pivot of the joint / bone in local space.
  87686. * @param distToJoint Optional distance from the impostor to the joint.
  87687. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87688. * @param boneAxis Optional vector3 axis the bone is aligned with
  87689. */
  87690. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87691. /**
  87692. * No-Imposter type
  87693. */
  87694. static NoImpostor: number;
  87695. /**
  87696. * Sphere-Imposter type
  87697. */
  87698. static SphereImpostor: number;
  87699. /**
  87700. * Box-Imposter type
  87701. */
  87702. static BoxImpostor: number;
  87703. /**
  87704. * Plane-Imposter type
  87705. */
  87706. static PlaneImpostor: number;
  87707. /**
  87708. * Mesh-imposter type
  87709. */
  87710. static MeshImpostor: number;
  87711. /**
  87712. * Capsule-Impostor type (Ammo.js plugin only)
  87713. */
  87714. static CapsuleImpostor: number;
  87715. /**
  87716. * Cylinder-Imposter type
  87717. */
  87718. static CylinderImpostor: number;
  87719. /**
  87720. * Particle-Imposter type
  87721. */
  87722. static ParticleImpostor: number;
  87723. /**
  87724. * Heightmap-Imposter type
  87725. */
  87726. static HeightmapImpostor: number;
  87727. /**
  87728. * ConvexHull-Impostor type (Ammo.js plugin only)
  87729. */
  87730. static ConvexHullImpostor: number;
  87731. /**
  87732. * Rope-Imposter type
  87733. */
  87734. static RopeImpostor: number;
  87735. /**
  87736. * Cloth-Imposter type
  87737. */
  87738. static ClothImpostor: number;
  87739. /**
  87740. * Softbody-Imposter type
  87741. */
  87742. static SoftbodyImpostor: number;
  87743. }
  87744. }
  87745. declare module BABYLON {
  87746. /**
  87747. * @hidden
  87748. **/
  87749. export class _CreationDataStorage {
  87750. closePath?: boolean;
  87751. closeArray?: boolean;
  87752. idx: number[];
  87753. dashSize: number;
  87754. gapSize: number;
  87755. path3D: Path3D;
  87756. pathArray: Vector3[][];
  87757. arc: number;
  87758. radius: number;
  87759. cap: number;
  87760. tessellation: number;
  87761. }
  87762. /**
  87763. * @hidden
  87764. **/
  87765. class _InstanceDataStorage {
  87766. visibleInstances: any;
  87767. batchCache: _InstancesBatch;
  87768. instancesBufferSize: number;
  87769. instancesBuffer: Nullable<Buffer>;
  87770. instancesData: Float32Array;
  87771. overridenInstanceCount: number;
  87772. isFrozen: boolean;
  87773. previousBatch: Nullable<_InstancesBatch>;
  87774. hardwareInstancedRendering: boolean;
  87775. sideOrientation: number;
  87776. }
  87777. /**
  87778. * @hidden
  87779. **/
  87780. export class _InstancesBatch {
  87781. mustReturn: boolean;
  87782. visibleInstances: Nullable<InstancedMesh[]>[];
  87783. renderSelf: boolean[];
  87784. hardwareInstancedRendering: boolean[];
  87785. }
  87786. /**
  87787. * Class used to represent renderable models
  87788. */
  87789. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87790. /**
  87791. * Mesh side orientation : usually the external or front surface
  87792. */
  87793. static readonly FRONTSIDE: number;
  87794. /**
  87795. * Mesh side orientation : usually the internal or back surface
  87796. */
  87797. static readonly BACKSIDE: number;
  87798. /**
  87799. * Mesh side orientation : both internal and external or front and back surfaces
  87800. */
  87801. static readonly DOUBLESIDE: number;
  87802. /**
  87803. * Mesh side orientation : by default, `FRONTSIDE`
  87804. */
  87805. static readonly DEFAULTSIDE: number;
  87806. /**
  87807. * Mesh cap setting : no cap
  87808. */
  87809. static readonly NO_CAP: number;
  87810. /**
  87811. * Mesh cap setting : one cap at the beginning of the mesh
  87812. */
  87813. static readonly CAP_START: number;
  87814. /**
  87815. * Mesh cap setting : one cap at the end of the mesh
  87816. */
  87817. static readonly CAP_END: number;
  87818. /**
  87819. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87820. */
  87821. static readonly CAP_ALL: number;
  87822. /**
  87823. * Mesh pattern setting : no flip or rotate
  87824. */
  87825. static readonly NO_FLIP: number;
  87826. /**
  87827. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87828. */
  87829. static readonly FLIP_TILE: number;
  87830. /**
  87831. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87832. */
  87833. static readonly ROTATE_TILE: number;
  87834. /**
  87835. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87836. */
  87837. static readonly FLIP_ROW: number;
  87838. /**
  87839. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87840. */
  87841. static readonly ROTATE_ROW: number;
  87842. /**
  87843. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87844. */
  87845. static readonly FLIP_N_ROTATE_TILE: number;
  87846. /**
  87847. * Mesh pattern setting : rotate pattern and rotate
  87848. */
  87849. static readonly FLIP_N_ROTATE_ROW: number;
  87850. /**
  87851. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87852. */
  87853. static readonly CENTER: number;
  87854. /**
  87855. * Mesh tile positioning : part tiles on left
  87856. */
  87857. static readonly LEFT: number;
  87858. /**
  87859. * Mesh tile positioning : part tiles on right
  87860. */
  87861. static readonly RIGHT: number;
  87862. /**
  87863. * Mesh tile positioning : part tiles on top
  87864. */
  87865. static readonly TOP: number;
  87866. /**
  87867. * Mesh tile positioning : part tiles on bottom
  87868. */
  87869. static readonly BOTTOM: number;
  87870. /**
  87871. * Gets the default side orientation.
  87872. * @param orientation the orientation to value to attempt to get
  87873. * @returns the default orientation
  87874. * @hidden
  87875. */
  87876. static _GetDefaultSideOrientation(orientation?: number): number;
  87877. private _internalMeshDataInfo;
  87878. /**
  87879. * An event triggered before rendering the mesh
  87880. */
  87881. readonly onBeforeRenderObservable: Observable<Mesh>;
  87882. /**
  87883. * An event triggered before binding the mesh
  87884. */
  87885. readonly onBeforeBindObservable: Observable<Mesh>;
  87886. /**
  87887. * An event triggered after rendering the mesh
  87888. */
  87889. readonly onAfterRenderObservable: Observable<Mesh>;
  87890. /**
  87891. * An event triggered before drawing the mesh
  87892. */
  87893. readonly onBeforeDrawObservable: Observable<Mesh>;
  87894. private _onBeforeDrawObserver;
  87895. /**
  87896. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87897. */
  87898. onBeforeDraw: () => void;
  87899. readonly hasInstances: boolean;
  87900. /**
  87901. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87902. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87903. */
  87904. delayLoadState: number;
  87905. /**
  87906. * Gets the list of instances created from this mesh
  87907. * it is not supposed to be modified manually.
  87908. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87909. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87910. */
  87911. instances: InstancedMesh[];
  87912. /**
  87913. * Gets the file containing delay loading data for this mesh
  87914. */
  87915. delayLoadingFile: string;
  87916. /** @hidden */
  87917. _binaryInfo: any;
  87918. /**
  87919. * User defined function used to change how LOD level selection is done
  87920. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87921. */
  87922. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87923. /**
  87924. * Gets or sets the morph target manager
  87925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87926. */
  87927. morphTargetManager: Nullable<MorphTargetManager>;
  87928. /** @hidden */
  87929. _creationDataStorage: Nullable<_CreationDataStorage>;
  87930. /** @hidden */
  87931. _geometry: Nullable<Geometry>;
  87932. /** @hidden */
  87933. _delayInfo: Array<string>;
  87934. /** @hidden */
  87935. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87936. /** @hidden */
  87937. _instanceDataStorage: _InstanceDataStorage;
  87938. private _effectiveMaterial;
  87939. /** @hidden */
  87940. _shouldGenerateFlatShading: boolean;
  87941. /** @hidden */
  87942. _originalBuilderSideOrientation: number;
  87943. /**
  87944. * Use this property to change the original side orientation defined at construction time
  87945. */
  87946. overrideMaterialSideOrientation: Nullable<number>;
  87947. /**
  87948. * Gets the source mesh (the one used to clone this one from)
  87949. */
  87950. readonly source: Nullable<Mesh>;
  87951. /**
  87952. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87953. */
  87954. isUnIndexed: boolean;
  87955. /**
  87956. * @constructor
  87957. * @param name The value used by scene.getMeshByName() to do a lookup.
  87958. * @param scene The scene to add this mesh to.
  87959. * @param parent The parent of this mesh, if it has one
  87960. * @param source An optional Mesh from which geometry is shared, cloned.
  87961. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87962. * When false, achieved by calling a clone(), also passing False.
  87963. * This will make creation of children, recursive.
  87964. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87965. */
  87966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87967. /**
  87968. * Gets the class name
  87969. * @returns the string "Mesh".
  87970. */
  87971. getClassName(): string;
  87972. /** @hidden */
  87973. readonly _isMesh: boolean;
  87974. /**
  87975. * Returns a description of this mesh
  87976. * @param fullDetails define if full details about this mesh must be used
  87977. * @returns a descriptive string representing this mesh
  87978. */
  87979. toString(fullDetails?: boolean): string;
  87980. /** @hidden */
  87981. _unBindEffect(): void;
  87982. /**
  87983. * Gets a boolean indicating if this mesh has LOD
  87984. */
  87985. readonly hasLODLevels: boolean;
  87986. /**
  87987. * Gets the list of MeshLODLevel associated with the current mesh
  87988. * @returns an array of MeshLODLevel
  87989. */
  87990. getLODLevels(): MeshLODLevel[];
  87991. private _sortLODLevels;
  87992. /**
  87993. * Add a mesh as LOD level triggered at the given distance.
  87994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87995. * @param distance The distance from the center of the object to show this level
  87996. * @param mesh The mesh to be added as LOD level (can be null)
  87997. * @return This mesh (for chaining)
  87998. */
  87999. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88000. /**
  88001. * Returns the LOD level mesh at the passed distance or null if not found.
  88002. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88003. * @param distance The distance from the center of the object to show this level
  88004. * @returns a Mesh or `null`
  88005. */
  88006. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88007. /**
  88008. * Remove a mesh from the LOD array
  88009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88010. * @param mesh defines the mesh to be removed
  88011. * @return This mesh (for chaining)
  88012. */
  88013. removeLODLevel(mesh: Mesh): Mesh;
  88014. /**
  88015. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88017. * @param camera defines the camera to use to compute distance
  88018. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88019. * @return This mesh (for chaining)
  88020. */
  88021. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88022. /**
  88023. * Gets the mesh internal Geometry object
  88024. */
  88025. readonly geometry: Nullable<Geometry>;
  88026. /**
  88027. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88028. * @returns the total number of vertices
  88029. */
  88030. getTotalVertices(): number;
  88031. /**
  88032. * Returns the content of an associated vertex buffer
  88033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88034. * - VertexBuffer.PositionKind
  88035. * - VertexBuffer.UVKind
  88036. * - VertexBuffer.UV2Kind
  88037. * - VertexBuffer.UV3Kind
  88038. * - VertexBuffer.UV4Kind
  88039. * - VertexBuffer.UV5Kind
  88040. * - VertexBuffer.UV6Kind
  88041. * - VertexBuffer.ColorKind
  88042. * - VertexBuffer.MatricesIndicesKind
  88043. * - VertexBuffer.MatricesIndicesExtraKind
  88044. * - VertexBuffer.MatricesWeightsKind
  88045. * - VertexBuffer.MatricesWeightsExtraKind
  88046. * @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
  88047. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88048. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88049. */
  88050. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88051. /**
  88052. * Returns the mesh VertexBuffer object from the requested `kind`
  88053. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88054. * - VertexBuffer.PositionKind
  88055. * - VertexBuffer.NormalKind
  88056. * - VertexBuffer.UVKind
  88057. * - VertexBuffer.UV2Kind
  88058. * - VertexBuffer.UV3Kind
  88059. * - VertexBuffer.UV4Kind
  88060. * - VertexBuffer.UV5Kind
  88061. * - VertexBuffer.UV6Kind
  88062. * - VertexBuffer.ColorKind
  88063. * - VertexBuffer.MatricesIndicesKind
  88064. * - VertexBuffer.MatricesIndicesExtraKind
  88065. * - VertexBuffer.MatricesWeightsKind
  88066. * - VertexBuffer.MatricesWeightsExtraKind
  88067. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88068. */
  88069. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88070. /**
  88071. * Tests if a specific vertex buffer is associated with this mesh
  88072. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88073. * - VertexBuffer.PositionKind
  88074. * - VertexBuffer.NormalKind
  88075. * - VertexBuffer.UVKind
  88076. * - VertexBuffer.UV2Kind
  88077. * - VertexBuffer.UV3Kind
  88078. * - VertexBuffer.UV4Kind
  88079. * - VertexBuffer.UV5Kind
  88080. * - VertexBuffer.UV6Kind
  88081. * - VertexBuffer.ColorKind
  88082. * - VertexBuffer.MatricesIndicesKind
  88083. * - VertexBuffer.MatricesIndicesExtraKind
  88084. * - VertexBuffer.MatricesWeightsKind
  88085. * - VertexBuffer.MatricesWeightsExtraKind
  88086. * @returns a boolean
  88087. */
  88088. isVerticesDataPresent(kind: string): boolean;
  88089. /**
  88090. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88091. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88092. * - VertexBuffer.PositionKind
  88093. * - VertexBuffer.UVKind
  88094. * - VertexBuffer.UV2Kind
  88095. * - VertexBuffer.UV3Kind
  88096. * - VertexBuffer.UV4Kind
  88097. * - VertexBuffer.UV5Kind
  88098. * - VertexBuffer.UV6Kind
  88099. * - VertexBuffer.ColorKind
  88100. * - VertexBuffer.MatricesIndicesKind
  88101. * - VertexBuffer.MatricesIndicesExtraKind
  88102. * - VertexBuffer.MatricesWeightsKind
  88103. * - VertexBuffer.MatricesWeightsExtraKind
  88104. * @returns a boolean
  88105. */
  88106. isVertexBufferUpdatable(kind: string): boolean;
  88107. /**
  88108. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88109. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88110. * - VertexBuffer.PositionKind
  88111. * - VertexBuffer.NormalKind
  88112. * - VertexBuffer.UVKind
  88113. * - VertexBuffer.UV2Kind
  88114. * - VertexBuffer.UV3Kind
  88115. * - VertexBuffer.UV4Kind
  88116. * - VertexBuffer.UV5Kind
  88117. * - VertexBuffer.UV6Kind
  88118. * - VertexBuffer.ColorKind
  88119. * - VertexBuffer.MatricesIndicesKind
  88120. * - VertexBuffer.MatricesIndicesExtraKind
  88121. * - VertexBuffer.MatricesWeightsKind
  88122. * - VertexBuffer.MatricesWeightsExtraKind
  88123. * @returns an array of strings
  88124. */
  88125. getVerticesDataKinds(): string[];
  88126. /**
  88127. * Returns a positive integer : the total number of indices in this mesh geometry.
  88128. * @returns the numner of indices or zero if the mesh has no geometry.
  88129. */
  88130. getTotalIndices(): number;
  88131. /**
  88132. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88133. * @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.
  88134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88135. * @returns the indices array or an empty array if the mesh has no geometry
  88136. */
  88137. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88138. readonly isBlocked: boolean;
  88139. /**
  88140. * Determine if the current mesh is ready to be rendered
  88141. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88142. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88143. * @returns true if all associated assets are ready (material, textures, shaders)
  88144. */
  88145. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88146. /**
  88147. * 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.
  88148. */
  88149. readonly areNormalsFrozen: boolean;
  88150. /**
  88151. * 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.
  88152. * @returns the current mesh
  88153. */
  88154. freezeNormals(): Mesh;
  88155. /**
  88156. * 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
  88157. * @returns the current mesh
  88158. */
  88159. unfreezeNormals(): Mesh;
  88160. /**
  88161. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88162. */
  88163. overridenInstanceCount: number;
  88164. /** @hidden */
  88165. _preActivate(): Mesh;
  88166. /** @hidden */
  88167. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88168. /** @hidden */
  88169. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88170. /**
  88171. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88172. * This means the mesh underlying bounding box and sphere are recomputed.
  88173. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88174. * @returns the current mesh
  88175. */
  88176. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88177. /** @hidden */
  88178. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88179. /**
  88180. * This function will subdivide the mesh into multiple submeshes
  88181. * @param count defines the expected number of submeshes
  88182. */
  88183. subdivide(count: number): void;
  88184. /**
  88185. * Copy a FloatArray into a specific associated vertex buffer
  88186. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88187. * - VertexBuffer.PositionKind
  88188. * - VertexBuffer.UVKind
  88189. * - VertexBuffer.UV2Kind
  88190. * - VertexBuffer.UV3Kind
  88191. * - VertexBuffer.UV4Kind
  88192. * - VertexBuffer.UV5Kind
  88193. * - VertexBuffer.UV6Kind
  88194. * - VertexBuffer.ColorKind
  88195. * - VertexBuffer.MatricesIndicesKind
  88196. * - VertexBuffer.MatricesIndicesExtraKind
  88197. * - VertexBuffer.MatricesWeightsKind
  88198. * - VertexBuffer.MatricesWeightsExtraKind
  88199. * @param data defines the data source
  88200. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88201. * @param stride defines the data stride size (can be null)
  88202. * @returns the current mesh
  88203. */
  88204. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  88205. /**
  88206. * Flags an associated vertex buffer as updatable
  88207. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88208. * - VertexBuffer.PositionKind
  88209. * - VertexBuffer.UVKind
  88210. * - VertexBuffer.UV2Kind
  88211. * - VertexBuffer.UV3Kind
  88212. * - VertexBuffer.UV4Kind
  88213. * - VertexBuffer.UV5Kind
  88214. * - VertexBuffer.UV6Kind
  88215. * - VertexBuffer.ColorKind
  88216. * - VertexBuffer.MatricesIndicesKind
  88217. * - VertexBuffer.MatricesIndicesExtraKind
  88218. * - VertexBuffer.MatricesWeightsKind
  88219. * - VertexBuffer.MatricesWeightsExtraKind
  88220. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88221. */
  88222. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88223. /**
  88224. * Sets the mesh global Vertex Buffer
  88225. * @param buffer defines the buffer to use
  88226. * @returns the current mesh
  88227. */
  88228. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88229. /**
  88230. * Update a specific associated vertex buffer
  88231. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88232. * - VertexBuffer.PositionKind
  88233. * - VertexBuffer.UVKind
  88234. * - VertexBuffer.UV2Kind
  88235. * - VertexBuffer.UV3Kind
  88236. * - VertexBuffer.UV4Kind
  88237. * - VertexBuffer.UV5Kind
  88238. * - VertexBuffer.UV6Kind
  88239. * - VertexBuffer.ColorKind
  88240. * - VertexBuffer.MatricesIndicesKind
  88241. * - VertexBuffer.MatricesIndicesExtraKind
  88242. * - VertexBuffer.MatricesWeightsKind
  88243. * - VertexBuffer.MatricesWeightsExtraKind
  88244. * @param data defines the data source
  88245. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88246. * @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)
  88247. * @returns the current mesh
  88248. */
  88249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88250. /**
  88251. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88252. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88253. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88254. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88255. * @returns the current mesh
  88256. */
  88257. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88258. /**
  88259. * Creates a un-shared specific occurence of the geometry for the mesh.
  88260. * @returns the current mesh
  88261. */
  88262. makeGeometryUnique(): Mesh;
  88263. /**
  88264. * Set the index buffer of this mesh
  88265. * @param indices defines the source data
  88266. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88267. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88268. * @returns the current mesh
  88269. */
  88270. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  88271. /**
  88272. * Update the current index buffer
  88273. * @param indices defines the source data
  88274. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88275. * @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)
  88276. * @returns the current mesh
  88277. */
  88278. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  88279. /**
  88280. * Invert the geometry to move from a right handed system to a left handed one.
  88281. * @returns the current mesh
  88282. */
  88283. toLeftHanded(): Mesh;
  88284. /** @hidden */
  88285. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88286. /** @hidden */
  88287. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88288. /**
  88289. * Registers for this mesh a javascript function called just before the rendering process
  88290. * @param func defines the function to call before rendering this mesh
  88291. * @returns the current mesh
  88292. */
  88293. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88294. /**
  88295. * Disposes a previously registered javascript function called before the rendering
  88296. * @param func defines the function to remove
  88297. * @returns the current mesh
  88298. */
  88299. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88300. /**
  88301. * Registers for this mesh a javascript function called just after the rendering is complete
  88302. * @param func defines the function to call after rendering this mesh
  88303. * @returns the current mesh
  88304. */
  88305. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88306. /**
  88307. * Disposes a previously registered javascript function called after the rendering.
  88308. * @param func defines the function to remove
  88309. * @returns the current mesh
  88310. */
  88311. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88312. /** @hidden */
  88313. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88314. /** @hidden */
  88315. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88316. /** @hidden */
  88317. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88318. /** @hidden */
  88319. _rebuild(): void;
  88320. /** @hidden */
  88321. _freeze(): void;
  88322. /** @hidden */
  88323. _unFreeze(): void;
  88324. /**
  88325. * 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
  88326. * @param subMesh defines the subMesh to render
  88327. * @param enableAlphaMode defines if alpha mode can be changed
  88328. * @returns the current mesh
  88329. */
  88330. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88331. private _onBeforeDraw;
  88332. /**
  88333. * Renormalize the mesh and patch it up if there are no weights
  88334. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88335. * However in the case of zero weights then we set just a single influence to 1.
  88336. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88337. */
  88338. cleanMatrixWeights(): void;
  88339. private normalizeSkinFourWeights;
  88340. private normalizeSkinWeightsAndExtra;
  88341. /**
  88342. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88343. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88344. * the user know there was an issue with importing the mesh
  88345. * @returns a validation object with skinned, valid and report string
  88346. */
  88347. validateSkinning(): {
  88348. skinned: boolean;
  88349. valid: boolean;
  88350. report: string;
  88351. };
  88352. /** @hidden */
  88353. _checkDelayState(): Mesh;
  88354. private _queueLoad;
  88355. /**
  88356. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88357. * A mesh is in the frustum if its bounding box intersects the frustum
  88358. * @param frustumPlanes defines the frustum to test
  88359. * @returns true if the mesh is in the frustum planes
  88360. */
  88361. isInFrustum(frustumPlanes: Plane[]): boolean;
  88362. /**
  88363. * Sets the mesh material by the material or multiMaterial `id` property
  88364. * @param id is a string identifying the material or the multiMaterial
  88365. * @returns the current mesh
  88366. */
  88367. setMaterialByID(id: string): Mesh;
  88368. /**
  88369. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88370. * @returns an array of IAnimatable
  88371. */
  88372. getAnimatables(): IAnimatable[];
  88373. /**
  88374. * Modifies the mesh geometry according to the passed transformation matrix.
  88375. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88376. * The mesh normals are modified using the same transformation.
  88377. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88378. * @param transform defines the transform matrix to use
  88379. * @see http://doc.babylonjs.com/resources/baking_transformations
  88380. * @returns the current mesh
  88381. */
  88382. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88383. /**
  88384. * Modifies the mesh geometry according to its own current World Matrix.
  88385. * The mesh World Matrix is then reset.
  88386. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88387. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88388. * @see http://doc.babylonjs.com/resources/baking_transformations
  88389. * @returns the current mesh
  88390. */
  88391. bakeCurrentTransformIntoVertices(): Mesh;
  88392. /** @hidden */
  88393. readonly _positions: Nullable<Vector3[]>;
  88394. /** @hidden */
  88395. _resetPointsArrayCache(): Mesh;
  88396. /** @hidden */
  88397. _generatePointsArray(): boolean;
  88398. /**
  88399. * Returns a new Mesh object generated from the current mesh properties.
  88400. * This method must not get confused with createInstance()
  88401. * @param name is a string, the name given to the new mesh
  88402. * @param newParent can be any Node object (default `null`)
  88403. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88404. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88405. * @returns a new mesh
  88406. */
  88407. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  88408. /**
  88409. * Releases resources associated with this mesh.
  88410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88412. */
  88413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88414. /**
  88415. * Modifies the mesh geometry according to a displacement map.
  88416. * 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.
  88417. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88418. * @param url is a string, the URL from the image file is to be downloaded.
  88419. * @param minHeight is the lower limit of the displacement.
  88420. * @param maxHeight is the upper limit of the displacement.
  88421. * @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.
  88422. * @param uvOffset is an optional vector2 used to offset UV.
  88423. * @param uvScale is an optional vector2 used to scale UV.
  88424. * @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.
  88425. * @returns the Mesh.
  88426. */
  88427. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88428. /**
  88429. * Modifies the mesh geometry according to a displacementMap buffer.
  88430. * 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.
  88431. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88432. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88433. * @param heightMapWidth is the width of the buffer image.
  88434. * @param heightMapHeight is the height of the buffer image.
  88435. * @param minHeight is the lower limit of the displacement.
  88436. * @param maxHeight is the upper limit of the displacement.
  88437. * @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.
  88438. * @param uvOffset is an optional vector2 used to offset UV.
  88439. * @param uvScale is an optional vector2 used to scale UV.
  88440. * @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.
  88441. * @returns the Mesh.
  88442. */
  88443. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88444. /**
  88445. * Modify the mesh to get a flat shading rendering.
  88446. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88447. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88448. * @returns current mesh
  88449. */
  88450. convertToFlatShadedMesh(): Mesh;
  88451. /**
  88452. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88453. * In other words, more vertices, no more indices and a single bigger VBO.
  88454. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88455. * @returns current mesh
  88456. */
  88457. convertToUnIndexedMesh(): Mesh;
  88458. /**
  88459. * Inverses facet orientations.
  88460. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88461. * @param flipNormals will also inverts the normals
  88462. * @returns current mesh
  88463. */
  88464. flipFaces(flipNormals?: boolean): Mesh;
  88465. /**
  88466. * Increase the number of facets and hence vertices in a mesh
  88467. * Vertex normals are interpolated from existing vertex normals
  88468. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88469. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88470. */
  88471. increaseVertices(numberPerEdge: number): void;
  88472. /**
  88473. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88474. * This will undo any application of covertToFlatShadedMesh
  88475. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88476. */
  88477. forceSharedVertices(): void;
  88478. /** @hidden */
  88479. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88480. /** @hidden */
  88481. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88482. /**
  88483. * Creates a new InstancedMesh object from the mesh model.
  88484. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88485. * @param name defines the name of the new instance
  88486. * @returns a new InstancedMesh
  88487. */
  88488. createInstance(name: string): InstancedMesh;
  88489. /**
  88490. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88491. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88492. * @returns the current mesh
  88493. */
  88494. synchronizeInstances(): Mesh;
  88495. /**
  88496. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88497. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88498. * This should be used together with the simplification to avoid disappearing triangles.
  88499. * @param successCallback an optional success callback to be called after the optimization finished.
  88500. * @returns the current mesh
  88501. */
  88502. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88503. /**
  88504. * Serialize current mesh
  88505. * @param serializationObject defines the object which will receive the serialization data
  88506. */
  88507. serialize(serializationObject: any): void;
  88508. /** @hidden */
  88509. _syncGeometryWithMorphTargetManager(): void;
  88510. /** @hidden */
  88511. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88512. /**
  88513. * Returns a new Mesh object parsed from the source provided.
  88514. * @param parsedMesh is the source
  88515. * @param scene defines the hosting scene
  88516. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88517. * @returns a new Mesh
  88518. */
  88519. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88520. /**
  88521. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88522. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88523. * @param name defines the name of the mesh to create
  88524. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88525. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88526. * @param closePath creates a seam between the first and the last points of each path of the path array
  88527. * @param offset is taken in account only if the `pathArray` is containing a single path
  88528. * @param scene defines the hosting scene
  88529. * @param updatable defines if the mesh must be flagged as updatable
  88530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88531. * @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)
  88532. * @returns a new Mesh
  88533. */
  88534. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88535. /**
  88536. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88537. * @param name defines the name of the mesh to create
  88538. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88539. * @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
  88540. * @param scene defines the hosting scene
  88541. * @param updatable defines if the mesh must be flagged as updatable
  88542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88543. * @returns a new Mesh
  88544. */
  88545. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88546. /**
  88547. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88548. * @param name defines the name of the mesh to create
  88549. * @param size sets the size (float) of each box side (default 1)
  88550. * @param scene defines the hosting scene
  88551. * @param updatable defines if the mesh must be flagged as updatable
  88552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88553. * @returns a new Mesh
  88554. */
  88555. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88556. /**
  88557. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88558. * @param name defines the name of the mesh to create
  88559. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88560. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88561. * @param scene defines the hosting scene
  88562. * @param updatable defines if the mesh must be flagged as updatable
  88563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88564. * @returns a new Mesh
  88565. */
  88566. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88567. /**
  88568. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88569. * @param name defines the name of the mesh to create
  88570. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88571. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88572. * @param scene defines the hosting scene
  88573. * @returns a new Mesh
  88574. */
  88575. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88576. /**
  88577. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88578. * @param name defines the name of the mesh to create
  88579. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88580. * @param diameterTop set the top cap diameter (floats, default 1)
  88581. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88582. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88583. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88584. * @param scene defines the hosting scene
  88585. * @param updatable defines if the mesh must be flagged as updatable
  88586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88587. * @returns a new Mesh
  88588. */
  88589. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88590. /**
  88591. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88592. * @param name defines the name of the mesh to create
  88593. * @param diameter sets the diameter size (float) of the torus (default 1)
  88594. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88595. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88596. * @param scene defines the hosting scene
  88597. * @param updatable defines if the mesh must be flagged as updatable
  88598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88599. * @returns a new Mesh
  88600. */
  88601. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88602. /**
  88603. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88604. * @param name defines the name of the mesh to create
  88605. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88606. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88607. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88608. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88609. * @param p the number of windings on X axis (positive integers, default 2)
  88610. * @param q the number of windings on Y axis (positive integers, default 3)
  88611. * @param scene defines the hosting scene
  88612. * @param updatable defines if the mesh must be flagged as updatable
  88613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88614. * @returns a new Mesh
  88615. */
  88616. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88617. /**
  88618. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88619. * @param name defines the name of the mesh to create
  88620. * @param points is an array successive Vector3
  88621. * @param scene defines the hosting scene
  88622. * @param updatable defines if the mesh must be flagged as updatable
  88623. * @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).
  88624. * @returns a new Mesh
  88625. */
  88626. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88627. /**
  88628. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88629. * @param name defines the name of the mesh to create
  88630. * @param points is an array successive Vector3
  88631. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88632. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88633. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88634. * @param scene defines the hosting scene
  88635. * @param updatable defines if the mesh must be flagged as updatable
  88636. * @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)
  88637. * @returns a new Mesh
  88638. */
  88639. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88640. /**
  88641. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88642. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88643. * 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.
  88644. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88645. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88646. * Remember you can only change the shape positions, not their number when updating a polygon.
  88647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88648. * @param name defines the name of the mesh to create
  88649. * @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
  88650. * @param scene defines the hosting scene
  88651. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88652. * @param updatable defines if the mesh must be flagged as updatable
  88653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88654. * @param earcutInjection can be used to inject your own earcut reference
  88655. * @returns a new Mesh
  88656. */
  88657. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88658. /**
  88659. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88660. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88661. * @param name defines the name of the mesh to create
  88662. * @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
  88663. * @param depth defines the height of extrusion
  88664. * @param scene defines the hosting scene
  88665. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88666. * @param updatable defines if the mesh must be flagged as updatable
  88667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88668. * @param earcutInjection can be used to inject your own earcut reference
  88669. * @returns a new Mesh
  88670. */
  88671. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88672. /**
  88673. * Creates an extruded shape mesh.
  88674. * 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
  88675. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88676. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88677. * @param name defines the name of the mesh to create
  88678. * @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
  88679. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88680. * @param scale is the value to scale the shape
  88681. * @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
  88682. * @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
  88683. * @param scene defines the hosting scene
  88684. * @param updatable defines if the mesh must be flagged as updatable
  88685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88686. * @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)
  88687. * @returns a new Mesh
  88688. */
  88689. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88690. /**
  88691. * Creates an custom extruded shape mesh.
  88692. * The custom extrusion is a parametric shape.
  88693. * It has no predefined shape. Its final shape will depend on the input parameters.
  88694. * Please consider using the same method from the MeshBuilder class instead
  88695. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88696. * @param name defines the name of the mesh to create
  88697. * @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
  88698. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88699. * @param scaleFunction is a custom Javascript function called on each path point
  88700. * @param rotationFunction is a custom Javascript function called on each path point
  88701. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88702. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88703. * @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
  88704. * @param scene defines the hosting scene
  88705. * @param updatable defines if the mesh must be flagged as updatable
  88706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88707. * @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)
  88708. * @returns a new Mesh
  88709. */
  88710. 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;
  88711. /**
  88712. * Creates lathe mesh.
  88713. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88714. * Please consider using the same method from the MeshBuilder class instead
  88715. * @param name defines the name of the mesh to create
  88716. * @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
  88717. * @param radius is the radius value of the lathe
  88718. * @param tessellation is the side number of the lathe.
  88719. * @param scene defines the hosting scene
  88720. * @param updatable defines if the mesh must be flagged as updatable
  88721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88722. * @returns a new Mesh
  88723. */
  88724. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88725. /**
  88726. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88727. * @param name defines the name of the mesh to create
  88728. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88729. * @param scene defines the hosting scene
  88730. * @param updatable defines if the mesh must be flagged as updatable
  88731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88732. * @returns a new Mesh
  88733. */
  88734. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88735. /**
  88736. * Creates a ground mesh.
  88737. * Please consider using the same method from the MeshBuilder class instead
  88738. * @param name defines the name of the mesh to create
  88739. * @param width set the width of the ground
  88740. * @param height set the height of the ground
  88741. * @param subdivisions sets the number of subdivisions per side
  88742. * @param scene defines the hosting scene
  88743. * @param updatable defines if the mesh must be flagged as updatable
  88744. * @returns a new Mesh
  88745. */
  88746. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88747. /**
  88748. * Creates a tiled ground mesh.
  88749. * Please consider using the same method from the MeshBuilder class instead
  88750. * @param name defines the name of the mesh to create
  88751. * @param xmin set the ground minimum X coordinate
  88752. * @param zmin set the ground minimum Y coordinate
  88753. * @param xmax set the ground maximum X coordinate
  88754. * @param zmax set the ground maximum Z coordinate
  88755. * @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
  88756. * @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
  88757. * @param scene defines the hosting scene
  88758. * @param updatable defines if the mesh must be flagged as updatable
  88759. * @returns a new Mesh
  88760. */
  88761. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88762. w: number;
  88763. h: number;
  88764. }, precision: {
  88765. w: number;
  88766. h: number;
  88767. }, scene: Scene, updatable?: boolean): Mesh;
  88768. /**
  88769. * Creates a ground mesh from a height map.
  88770. * Please consider using the same method from the MeshBuilder class instead
  88771. * @see http://doc.babylonjs.com/babylon101/height_map
  88772. * @param name defines the name of the mesh to create
  88773. * @param url sets the URL of the height map image resource
  88774. * @param width set the ground width size
  88775. * @param height set the ground height size
  88776. * @param subdivisions sets the number of subdivision per side
  88777. * @param minHeight is the minimum altitude on the ground
  88778. * @param maxHeight is the maximum altitude on the ground
  88779. * @param scene defines the hosting scene
  88780. * @param updatable defines if the mesh must be flagged as updatable
  88781. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88782. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88783. * @returns a new Mesh
  88784. */
  88785. 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;
  88786. /**
  88787. * Creates a tube mesh.
  88788. * The tube is a parametric shape.
  88789. * It has no predefined shape. Its final shape will depend on the input parameters.
  88790. * Please consider using the same method from the MeshBuilder class instead
  88791. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88792. * @param name defines the name of the mesh to create
  88793. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88794. * @param radius sets the tube radius size
  88795. * @param tessellation is the number of sides on the tubular surface
  88796. * @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
  88797. * @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
  88798. * @param scene defines the hosting scene
  88799. * @param updatable defines if the mesh must be flagged as updatable
  88800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88801. * @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)
  88802. * @returns a new Mesh
  88803. */
  88804. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88805. (i: number, distance: number): number;
  88806. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88807. /**
  88808. * Creates a polyhedron mesh.
  88809. * Please consider using the same method from the MeshBuilder class instead.
  88810. * * 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
  88811. * * The parameter `size` (positive float, default 1) sets the polygon size
  88812. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88813. * * 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`
  88814. * * 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
  88815. * * 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)`)
  88816. * * 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
  88817. * * 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
  88818. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88819. * * If you create a double-sided mesh, you can choose what parts of 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
  88820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88821. * @param name defines the name of the mesh to create
  88822. * @param options defines the options used to create the mesh
  88823. * @param scene defines the hosting scene
  88824. * @returns a new Mesh
  88825. */
  88826. static CreatePolyhedron(name: string, options: {
  88827. type?: number;
  88828. size?: number;
  88829. sizeX?: number;
  88830. sizeY?: number;
  88831. sizeZ?: number;
  88832. custom?: any;
  88833. faceUV?: Vector4[];
  88834. faceColors?: Color4[];
  88835. updatable?: boolean;
  88836. sideOrientation?: number;
  88837. }, scene: Scene): Mesh;
  88838. /**
  88839. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88840. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88841. * * 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`)
  88842. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88843. * * 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
  88844. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88845. * * If you create a double-sided mesh, you can choose what parts of 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
  88846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88847. * @param name defines the name of the mesh
  88848. * @param options defines the options used to create the mesh
  88849. * @param scene defines the hosting scene
  88850. * @returns a new Mesh
  88851. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88852. */
  88853. static CreateIcoSphere(name: string, options: {
  88854. radius?: number;
  88855. flat?: boolean;
  88856. subdivisions?: number;
  88857. sideOrientation?: number;
  88858. updatable?: boolean;
  88859. }, scene: Scene): Mesh;
  88860. /**
  88861. * Creates a decal mesh.
  88862. * Please consider using the same method from the MeshBuilder class instead.
  88863. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88864. * @param name defines the name of the mesh
  88865. * @param sourceMesh defines the mesh receiving the decal
  88866. * @param position sets the position of the decal in world coordinates
  88867. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88868. * @param size sets the decal scaling
  88869. * @param angle sets the angle to rotate the decal
  88870. * @returns a new Mesh
  88871. */
  88872. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88873. /**
  88874. * Prepare internal position array for software CPU skinning
  88875. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88876. */
  88877. setPositionsForCPUSkinning(): Float32Array;
  88878. /**
  88879. * Prepare internal normal array for software CPU skinning
  88880. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88881. */
  88882. setNormalsForCPUSkinning(): Float32Array;
  88883. /**
  88884. * Updates the vertex buffer by applying transformation from the bones
  88885. * @param skeleton defines the skeleton to apply to current mesh
  88886. * @returns the current mesh
  88887. */
  88888. applySkeleton(skeleton: Skeleton): Mesh;
  88889. /**
  88890. * 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
  88891. * @param meshes defines the list of meshes to scan
  88892. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88893. */
  88894. static MinMax(meshes: AbstractMesh[]): {
  88895. min: Vector3;
  88896. max: Vector3;
  88897. };
  88898. /**
  88899. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88900. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88901. * @returns a vector3
  88902. */
  88903. static Center(meshesOrMinMaxVector: {
  88904. min: Vector3;
  88905. max: Vector3;
  88906. } | AbstractMesh[]): Vector3;
  88907. /**
  88908. * Merge the array of meshes into a single mesh for performance reasons.
  88909. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88910. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88911. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88912. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88913. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88914. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88915. * @returns a new mesh
  88916. */
  88917. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88918. /** @hidden */
  88919. addInstance(instance: InstancedMesh): void;
  88920. /** @hidden */
  88921. removeInstance(instance: InstancedMesh): void;
  88922. }
  88923. }
  88924. declare module BABYLON {
  88925. /**
  88926. * This is the base class of all the camera used in the application.
  88927. * @see http://doc.babylonjs.com/features/cameras
  88928. */
  88929. export class Camera extends Node {
  88930. /** @hidden */
  88931. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88932. /**
  88933. * This is the default projection mode used by the cameras.
  88934. * It helps recreating a feeling of perspective and better appreciate depth.
  88935. * This is the best way to simulate real life cameras.
  88936. */
  88937. static readonly PERSPECTIVE_CAMERA: number;
  88938. /**
  88939. * This helps creating camera with an orthographic mode.
  88940. * 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.
  88941. */
  88942. static readonly ORTHOGRAPHIC_CAMERA: number;
  88943. /**
  88944. * This is the default FOV mode for perspective cameras.
  88945. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88946. */
  88947. static readonly FOVMODE_VERTICAL_FIXED: number;
  88948. /**
  88949. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88950. */
  88951. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88952. /**
  88953. * This specifies ther is no need for a camera rig.
  88954. * Basically only one eye is rendered corresponding to the camera.
  88955. */
  88956. static readonly RIG_MODE_NONE: number;
  88957. /**
  88958. * Simulates a camera Rig with one blue eye and one red eye.
  88959. * This can be use with 3d blue and red glasses.
  88960. */
  88961. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88962. /**
  88963. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88964. */
  88965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88966. /**
  88967. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88968. */
  88969. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88970. /**
  88971. * Defines that both eyes of the camera will be rendered over under each other.
  88972. */
  88973. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88974. /**
  88975. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88976. */
  88977. static readonly RIG_MODE_VR: number;
  88978. /**
  88979. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88980. */
  88981. static readonly RIG_MODE_WEBVR: number;
  88982. /**
  88983. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88984. */
  88985. static readonly RIG_MODE_CUSTOM: number;
  88986. /**
  88987. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88988. */
  88989. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88990. /**
  88991. * Define the input manager associated with the camera.
  88992. */
  88993. inputs: CameraInputsManager<Camera>;
  88994. /** @hidden */
  88995. _position: Vector3;
  88996. /**
  88997. * Define the current local position of the camera in the scene
  88998. */
  88999. position: Vector3;
  89000. /**
  89001. * The vector the camera should consider as up.
  89002. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89003. */
  89004. upVector: Vector3;
  89005. /**
  89006. * Define the current limit on the left side for an orthographic camera
  89007. * In scene unit
  89008. */
  89009. orthoLeft: Nullable<number>;
  89010. /**
  89011. * Define the current limit on the right side for an orthographic camera
  89012. * In scene unit
  89013. */
  89014. orthoRight: Nullable<number>;
  89015. /**
  89016. * Define the current limit on the bottom side for an orthographic camera
  89017. * In scene unit
  89018. */
  89019. orthoBottom: Nullable<number>;
  89020. /**
  89021. * Define the current limit on the top side for an orthographic camera
  89022. * In scene unit
  89023. */
  89024. orthoTop: Nullable<number>;
  89025. /**
  89026. * Field Of View is set in Radians. (default is 0.8)
  89027. */
  89028. fov: number;
  89029. /**
  89030. * Define the minimum distance the camera can see from.
  89031. * This is important to note that the depth buffer are not infinite and the closer it starts
  89032. * the more your scene might encounter depth fighting issue.
  89033. */
  89034. minZ: number;
  89035. /**
  89036. * Define the maximum distance the camera can see to.
  89037. * This is important to note that the depth buffer are not infinite and the further it end
  89038. * the more your scene might encounter depth fighting issue.
  89039. */
  89040. maxZ: number;
  89041. /**
  89042. * Define the default inertia of the camera.
  89043. * This helps giving a smooth feeling to the camera movement.
  89044. */
  89045. inertia: number;
  89046. /**
  89047. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89048. */
  89049. mode: number;
  89050. /**
  89051. * Define wether the camera is intermediate.
  89052. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89053. */
  89054. isIntermediate: boolean;
  89055. /**
  89056. * Define the viewport of the camera.
  89057. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89058. */
  89059. viewport: Viewport;
  89060. /**
  89061. * Restricts the camera to viewing objects with the same layerMask.
  89062. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89063. */
  89064. layerMask: number;
  89065. /**
  89066. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89067. */
  89068. fovMode: number;
  89069. /**
  89070. * Rig mode of the camera.
  89071. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89072. * This is normally controlled byt the camera themselves as internal use.
  89073. */
  89074. cameraRigMode: number;
  89075. /**
  89076. * Defines the distance between both "eyes" in case of a RIG
  89077. */
  89078. interaxialDistance: number;
  89079. /**
  89080. * Defines if stereoscopic rendering is done side by side or over under.
  89081. */
  89082. isStereoscopicSideBySide: boolean;
  89083. /**
  89084. * 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
  89085. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89086. * else in the scene. (Eg. security camera)
  89087. *
  89088. * 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)
  89089. */
  89090. customRenderTargets: RenderTargetTexture[];
  89091. /**
  89092. * When set, the camera will render to this render target instead of the default canvas
  89093. *
  89094. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89095. */
  89096. outputRenderTarget: Nullable<RenderTargetTexture>;
  89097. /**
  89098. * Observable triggered when the camera view matrix has changed.
  89099. */
  89100. onViewMatrixChangedObservable: Observable<Camera>;
  89101. /**
  89102. * Observable triggered when the camera Projection matrix has changed.
  89103. */
  89104. onProjectionMatrixChangedObservable: Observable<Camera>;
  89105. /**
  89106. * Observable triggered when the inputs have been processed.
  89107. */
  89108. onAfterCheckInputsObservable: Observable<Camera>;
  89109. /**
  89110. * Observable triggered when reset has been called and applied to the camera.
  89111. */
  89112. onRestoreStateObservable: Observable<Camera>;
  89113. /** @hidden */
  89114. _cameraRigParams: any;
  89115. /** @hidden */
  89116. _rigCameras: Camera[];
  89117. /** @hidden */
  89118. _rigPostProcess: Nullable<PostProcess>;
  89119. protected _webvrViewMatrix: Matrix;
  89120. /** @hidden */
  89121. _skipRendering: boolean;
  89122. /** @hidden */
  89123. _projectionMatrix: Matrix;
  89124. /** @hidden */
  89125. _postProcesses: Nullable<PostProcess>[];
  89126. /** @hidden */
  89127. _activeMeshes: SmartArray<AbstractMesh>;
  89128. protected _globalPosition: Vector3;
  89129. /** @hidden */
  89130. _computedViewMatrix: Matrix;
  89131. private _doNotComputeProjectionMatrix;
  89132. private _transformMatrix;
  89133. private _frustumPlanes;
  89134. private _refreshFrustumPlanes;
  89135. private _storedFov;
  89136. private _stateStored;
  89137. /**
  89138. * Instantiates a new camera object.
  89139. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89140. * @see http://doc.babylonjs.com/features/cameras
  89141. * @param name Defines the name of the camera in the scene
  89142. * @param position Defines the position of the camera
  89143. * @param scene Defines the scene the camera belongs too
  89144. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89145. */
  89146. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89147. /**
  89148. * Store current camera state (fov, position, etc..)
  89149. * @returns the camera
  89150. */
  89151. storeState(): Camera;
  89152. /**
  89153. * Restores the camera state values if it has been stored. You must call storeState() first
  89154. */
  89155. protected _restoreStateValues(): boolean;
  89156. /**
  89157. * Restored camera state. You must call storeState() first.
  89158. * @returns true if restored and false otherwise
  89159. */
  89160. restoreState(): boolean;
  89161. /**
  89162. * Gets the class name of the camera.
  89163. * @returns the class name
  89164. */
  89165. getClassName(): string;
  89166. /** @hidden */
  89167. readonly _isCamera: boolean;
  89168. /**
  89169. * Gets a string representation of the camera useful for debug purpose.
  89170. * @param fullDetails Defines that a more verboe level of logging is required
  89171. * @returns the string representation
  89172. */
  89173. toString(fullDetails?: boolean): string;
  89174. /**
  89175. * Gets the current world space position of the camera.
  89176. */
  89177. readonly globalPosition: Vector3;
  89178. /**
  89179. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89180. * @returns the active meshe list
  89181. */
  89182. getActiveMeshes(): SmartArray<AbstractMesh>;
  89183. /**
  89184. * Check wether a mesh is part of the current active mesh list of the camera
  89185. * @param mesh Defines the mesh to check
  89186. * @returns true if active, false otherwise
  89187. */
  89188. isActiveMesh(mesh: Mesh): boolean;
  89189. /**
  89190. * Is this camera ready to be used/rendered
  89191. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89192. * @return true if the camera is ready
  89193. */
  89194. isReady(completeCheck?: boolean): boolean;
  89195. /** @hidden */
  89196. _initCache(): void;
  89197. /** @hidden */
  89198. _updateCache(ignoreParentClass?: boolean): void;
  89199. /** @hidden */
  89200. _isSynchronized(): boolean;
  89201. /** @hidden */
  89202. _isSynchronizedViewMatrix(): boolean;
  89203. /** @hidden */
  89204. _isSynchronizedProjectionMatrix(): boolean;
  89205. /**
  89206. * Attach the input controls to a specific dom element to get the input from.
  89207. * @param element Defines the element the controls should be listened from
  89208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89209. */
  89210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89211. /**
  89212. * Detach the current controls from the specified dom element.
  89213. * @param element Defines the element to stop listening the inputs from
  89214. */
  89215. detachControl(element: HTMLElement): void;
  89216. /**
  89217. * Update the camera state according to the different inputs gathered during the frame.
  89218. */
  89219. update(): void;
  89220. /** @hidden */
  89221. _checkInputs(): void;
  89222. /** @hidden */
  89223. readonly rigCameras: Camera[];
  89224. /**
  89225. * Gets the post process used by the rig cameras
  89226. */
  89227. readonly rigPostProcess: Nullable<PostProcess>;
  89228. /**
  89229. * Internal, gets the first post proces.
  89230. * @returns the first post process to be run on this camera.
  89231. */
  89232. _getFirstPostProcess(): Nullable<PostProcess>;
  89233. private _cascadePostProcessesToRigCams;
  89234. /**
  89235. * Attach a post process to the camera.
  89236. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89237. * @param postProcess The post process to attach to the camera
  89238. * @param insertAt The position of the post process in case several of them are in use in the scene
  89239. * @returns the position the post process has been inserted at
  89240. */
  89241. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89242. /**
  89243. * Detach a post process to the camera.
  89244. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89245. * @param postProcess The post process to detach from the camera
  89246. */
  89247. detachPostProcess(postProcess: PostProcess): void;
  89248. /**
  89249. * Gets the current world matrix of the camera
  89250. */
  89251. getWorldMatrix(): Matrix;
  89252. /** @hidden */
  89253. _getViewMatrix(): Matrix;
  89254. /**
  89255. * Gets the current view matrix of the camera.
  89256. * @param force forces the camera to recompute the matrix without looking at the cached state
  89257. * @returns the view matrix
  89258. */
  89259. getViewMatrix(force?: boolean): Matrix;
  89260. /**
  89261. * Freeze the projection matrix.
  89262. * It will prevent the cache check of the camera projection compute and can speed up perf
  89263. * if no parameter of the camera are meant to change
  89264. * @param projection Defines manually a projection if necessary
  89265. */
  89266. freezeProjectionMatrix(projection?: Matrix): void;
  89267. /**
  89268. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89269. */
  89270. unfreezeProjectionMatrix(): void;
  89271. /**
  89272. * Gets the current projection matrix of the camera.
  89273. * @param force forces the camera to recompute the matrix without looking at the cached state
  89274. * @returns the projection matrix
  89275. */
  89276. getProjectionMatrix(force?: boolean): Matrix;
  89277. /**
  89278. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89279. * @returns a Matrix
  89280. */
  89281. getTransformationMatrix(): Matrix;
  89282. private _updateFrustumPlanes;
  89283. /**
  89284. * Checks if a cullable object (mesh...) is in the camera frustum
  89285. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89286. * @param target The object to check
  89287. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89288. * @returns true if the object is in frustum otherwise false
  89289. */
  89290. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89291. /**
  89292. * Checks if a cullable object (mesh...) is in the camera frustum
  89293. * Unlike isInFrustum this cheks the full bounding box
  89294. * @param target The object to check
  89295. * @returns true if the object is in frustum otherwise false
  89296. */
  89297. isCompletelyInFrustum(target: ICullable): boolean;
  89298. /**
  89299. * Gets a ray in the forward direction from the camera.
  89300. * @param length Defines the length of the ray to create
  89301. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89302. * @param origin Defines the start point of the ray which defaults to the camera position
  89303. * @returns the forward ray
  89304. */
  89305. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89306. /**
  89307. * Releases resources associated with this node.
  89308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89310. */
  89311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89312. /** @hidden */
  89313. _isLeftCamera: boolean;
  89314. /**
  89315. * Gets the left camera of a rig setup in case of Rigged Camera
  89316. */
  89317. readonly isLeftCamera: boolean;
  89318. /** @hidden */
  89319. _isRightCamera: boolean;
  89320. /**
  89321. * Gets the right camera of a rig setup in case of Rigged Camera
  89322. */
  89323. readonly isRightCamera: boolean;
  89324. /**
  89325. * Gets the left camera of a rig setup in case of Rigged Camera
  89326. */
  89327. readonly leftCamera: Nullable<FreeCamera>;
  89328. /**
  89329. * Gets the right camera of a rig setup in case of Rigged Camera
  89330. */
  89331. readonly rightCamera: Nullable<FreeCamera>;
  89332. /**
  89333. * Gets the left camera target of a rig setup in case of Rigged Camera
  89334. * @returns the target position
  89335. */
  89336. getLeftTarget(): Nullable<Vector3>;
  89337. /**
  89338. * Gets the right camera target of a rig setup in case of Rigged Camera
  89339. * @returns the target position
  89340. */
  89341. getRightTarget(): Nullable<Vector3>;
  89342. /**
  89343. * @hidden
  89344. */
  89345. setCameraRigMode(mode: number, rigParams: any): void;
  89346. /** @hidden */
  89347. static _setStereoscopicRigMode(camera: Camera): void;
  89348. /** @hidden */
  89349. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89350. /** @hidden */
  89351. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89352. /** @hidden */
  89353. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89354. /** @hidden */
  89355. _getVRProjectionMatrix(): Matrix;
  89356. protected _updateCameraRotationMatrix(): void;
  89357. protected _updateWebVRCameraRotationMatrix(): void;
  89358. /**
  89359. * This function MUST be overwritten by the different WebVR cameras available.
  89360. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89361. * @hidden
  89362. */
  89363. _getWebVRProjectionMatrix(): Matrix;
  89364. /**
  89365. * This function MUST be overwritten by the different WebVR cameras available.
  89366. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89367. * @hidden
  89368. */
  89369. _getWebVRViewMatrix(): Matrix;
  89370. /** @hidden */
  89371. setCameraRigParameter(name: string, value: any): void;
  89372. /**
  89373. * needs to be overridden by children so sub has required properties to be copied
  89374. * @hidden
  89375. */
  89376. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89377. /**
  89378. * May need to be overridden by children
  89379. * @hidden
  89380. */
  89381. _updateRigCameras(): void;
  89382. /** @hidden */
  89383. _setupInputs(): void;
  89384. /**
  89385. * Serialiaze the camera setup to a json represention
  89386. * @returns the JSON representation
  89387. */
  89388. serialize(): any;
  89389. /**
  89390. * Clones the current camera.
  89391. * @param name The cloned camera name
  89392. * @returns the cloned camera
  89393. */
  89394. clone(name: string): Camera;
  89395. /**
  89396. * Gets the direction of the camera relative to a given local axis.
  89397. * @param localAxis Defines the reference axis to provide a relative direction.
  89398. * @return the direction
  89399. */
  89400. getDirection(localAxis: Vector3): Vector3;
  89401. /**
  89402. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89403. * @param localAxis Defines the reference axis to provide a relative direction.
  89404. * @param result Defines the vector to store the result in
  89405. */
  89406. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89407. /**
  89408. * Gets a camera constructor for a given camera type
  89409. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89410. * @param name The name of the camera the result will be able to instantiate
  89411. * @param scene The scene the result will construct the camera in
  89412. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89413. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89414. * @returns a factory method to construc the camera
  89415. */
  89416. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89417. /**
  89418. * Compute the world matrix of the camera.
  89419. * @returns the camera workd matrix
  89420. */
  89421. computeWorldMatrix(): Matrix;
  89422. /**
  89423. * Parse a JSON and creates the camera from the parsed information
  89424. * @param parsedCamera The JSON to parse
  89425. * @param scene The scene to instantiate the camera in
  89426. * @returns the newly constructed camera
  89427. */
  89428. static Parse(parsedCamera: any, scene: Scene): Camera;
  89429. }
  89430. }
  89431. declare module BABYLON {
  89432. /**
  89433. * Class containing static functions to help procedurally build meshes
  89434. */
  89435. export class DiscBuilder {
  89436. /**
  89437. * Creates a plane polygonal mesh. By default, this is a disc
  89438. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89439. * * 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
  89440. * * 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
  89441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89444. * @param name defines the name of the mesh
  89445. * @param options defines the options used to create the mesh
  89446. * @param scene defines the hosting scene
  89447. * @returns the plane polygonal mesh
  89448. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89449. */
  89450. static CreateDisc(name: string, options: {
  89451. radius?: number;
  89452. tessellation?: number;
  89453. arc?: number;
  89454. updatable?: boolean;
  89455. sideOrientation?: number;
  89456. frontUVs?: Vector4;
  89457. backUVs?: Vector4;
  89458. }, scene?: Nullable<Scene>): Mesh;
  89459. }
  89460. }
  89461. declare module BABYLON {
  89462. /**
  89463. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89464. *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.
  89465. * The SPS is also a particle system. It provides some methods to manage the particles.
  89466. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89467. *
  89468. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89469. */
  89470. export class SolidParticleSystem implements IDisposable {
  89471. /**
  89472. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89473. * Example : var p = SPS.particles[i];
  89474. */
  89475. particles: SolidParticle[];
  89476. /**
  89477. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89478. */
  89479. nbParticles: number;
  89480. /**
  89481. * If the particles must ever face the camera (default false). Useful for planar particles.
  89482. */
  89483. billboard: boolean;
  89484. /**
  89485. * Recompute normals when adding a shape
  89486. */
  89487. recomputeNormals: boolean;
  89488. /**
  89489. * This a counter ofr your own usage. It's not set by any SPS functions.
  89490. */
  89491. counter: number;
  89492. /**
  89493. * The SPS name. This name is also given to the underlying mesh.
  89494. */
  89495. name: string;
  89496. /**
  89497. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89498. */
  89499. mesh: Mesh;
  89500. /**
  89501. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89502. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89503. */
  89504. vars: any;
  89505. /**
  89506. * This array is populated when the SPS is set as 'pickable'.
  89507. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89508. * Each element of this array is an object `{idx: int, faceId: int}`.
  89509. * `idx` is the picked particle index in the `SPS.particles` array
  89510. * `faceId` is the picked face index counted within this particle.
  89511. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89512. */
  89513. pickedParticles: {
  89514. idx: number;
  89515. faceId: number;
  89516. }[];
  89517. /**
  89518. * This array is populated when `enableDepthSort` is set to true.
  89519. * Each element of this array is an instance of the class DepthSortedParticle.
  89520. */
  89521. depthSortedParticles: DepthSortedParticle[];
  89522. /**
  89523. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89524. * @hidden
  89525. */
  89526. _bSphereOnly: boolean;
  89527. /**
  89528. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89529. * @hidden
  89530. */
  89531. _bSphereRadiusFactor: number;
  89532. private _scene;
  89533. private _positions;
  89534. private _indices;
  89535. private _normals;
  89536. private _colors;
  89537. private _uvs;
  89538. private _indices32;
  89539. private _positions32;
  89540. private _normals32;
  89541. private _fixedNormal32;
  89542. private _colors32;
  89543. private _uvs32;
  89544. private _index;
  89545. private _updatable;
  89546. private _pickable;
  89547. private _isVisibilityBoxLocked;
  89548. private _alwaysVisible;
  89549. private _depthSort;
  89550. private _shapeCounter;
  89551. private _copy;
  89552. private _color;
  89553. private _computeParticleColor;
  89554. private _computeParticleTexture;
  89555. private _computeParticleRotation;
  89556. private _computeParticleVertex;
  89557. private _computeBoundingBox;
  89558. private _depthSortParticles;
  89559. private _camera;
  89560. private _mustUnrotateFixedNormals;
  89561. private _particlesIntersect;
  89562. private _needs32Bits;
  89563. /**
  89564. * Creates a SPS (Solid Particle System) object.
  89565. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89566. * @param scene (Scene) is the scene in which the SPS is added.
  89567. * @param options defines the options of the sps e.g.
  89568. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89569. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89570. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89571. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89572. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89573. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89574. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89575. */
  89576. constructor(name: string, scene: Scene, options?: {
  89577. updatable?: boolean;
  89578. isPickable?: boolean;
  89579. enableDepthSort?: boolean;
  89580. particleIntersection?: boolean;
  89581. boundingSphereOnly?: boolean;
  89582. bSphereRadiusFactor?: number;
  89583. });
  89584. /**
  89585. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89586. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89587. * @returns the created mesh
  89588. */
  89589. buildMesh(): Mesh;
  89590. /**
  89591. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89592. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89593. * Thus the particles generated from `digest()` have their property `position` set yet.
  89594. * @param mesh ( Mesh ) is the mesh to be digested
  89595. * @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
  89596. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89597. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89598. * @returns the current SPS
  89599. */
  89600. digest(mesh: Mesh, options?: {
  89601. facetNb?: number;
  89602. number?: number;
  89603. delta?: number;
  89604. }): SolidParticleSystem;
  89605. private _unrotateFixedNormals;
  89606. private _resetCopy;
  89607. private _meshBuilder;
  89608. private _posToShape;
  89609. private _uvsToShapeUV;
  89610. private _addParticle;
  89611. /**
  89612. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89613. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89614. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89615. * @param nb (positive integer) the number of particles to be created from this model
  89616. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89617. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89618. * @returns the number of shapes in the system
  89619. */
  89620. addShape(mesh: Mesh, nb: number, options?: {
  89621. positionFunction?: any;
  89622. vertexFunction?: any;
  89623. }): number;
  89624. private _rebuildParticle;
  89625. /**
  89626. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89627. * @returns the SPS.
  89628. */
  89629. rebuildMesh(): SolidParticleSystem;
  89630. /**
  89631. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89632. * This method calls `updateParticle()` for each particle of the SPS.
  89633. * For an animated SPS, it is usually called within the render loop.
  89634. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89635. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89636. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89637. * @returns the SPS.
  89638. */
  89639. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89640. /**
  89641. * Disposes the SPS.
  89642. */
  89643. dispose(): void;
  89644. /**
  89645. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89646. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89647. * @returns the SPS.
  89648. */
  89649. refreshVisibleSize(): SolidParticleSystem;
  89650. /**
  89651. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89652. * @param size the size (float) of the visibility box
  89653. * note : this doesn't lock the SPS mesh bounding box.
  89654. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89655. */
  89656. setVisibilityBox(size: number): void;
  89657. /**
  89658. * Gets whether the SPS as always visible or not
  89659. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89660. */
  89661. /**
  89662. * Sets the SPS as always visible or not
  89663. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89664. */
  89665. isAlwaysVisible: boolean;
  89666. /**
  89667. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89668. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89669. */
  89670. /**
  89671. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89672. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89673. */
  89674. isVisibilityBoxLocked: boolean;
  89675. /**
  89676. * Tells to `setParticles()` to compute the particle rotations or not.
  89677. * Default value : true. The SPS is faster when it's set to false.
  89678. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89679. */
  89680. /**
  89681. * Gets if `setParticles()` computes the particle rotations or not.
  89682. * Default value : true. The SPS is faster when it's set to false.
  89683. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89684. */
  89685. computeParticleRotation: boolean;
  89686. /**
  89687. * Tells to `setParticles()` to compute the particle colors or not.
  89688. * Default value : true. The SPS is faster when it's set to false.
  89689. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89690. */
  89691. /**
  89692. * Gets if `setParticles()` computes the particle colors or not.
  89693. * Default value : true. The SPS is faster when it's set to false.
  89694. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89695. */
  89696. computeParticleColor: boolean;
  89697. /**
  89698. * Gets if `setParticles()` computes the particle textures or not.
  89699. * Default value : true. The SPS is faster when it's set to false.
  89700. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89701. */
  89702. computeParticleTexture: boolean;
  89703. /**
  89704. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89705. * Default value : false. The SPS is faster when it's set to false.
  89706. * Note : the particle custom vertex positions aren't stored values.
  89707. */
  89708. /**
  89709. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89710. * Default value : false. The SPS is faster when it's set to false.
  89711. * Note : the particle custom vertex positions aren't stored values.
  89712. */
  89713. computeParticleVertex: boolean;
  89714. /**
  89715. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89716. */
  89717. /**
  89718. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89719. */
  89720. computeBoundingBox: boolean;
  89721. /**
  89722. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89723. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89724. * Default : `true`
  89725. */
  89726. /**
  89727. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89728. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89729. * Default : `true`
  89730. */
  89731. depthSortParticles: boolean;
  89732. /**
  89733. * This function does nothing. It may be overwritten to set all the particle first values.
  89734. * The SPS doesn't call this function, you may have to call it by your own.
  89735. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89736. */
  89737. initParticles(): void;
  89738. /**
  89739. * This function does nothing. It may be overwritten to recycle a particle.
  89740. * The SPS doesn't call this function, you may have to call it by your own.
  89741. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89742. * @param particle The particle to recycle
  89743. * @returns the recycled particle
  89744. */
  89745. recycleParticle(particle: SolidParticle): SolidParticle;
  89746. /**
  89747. * Updates a particle : this function should be overwritten by the user.
  89748. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89749. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89750. * @example : just set a particle position or velocity and recycle conditions
  89751. * @param particle The particle to update
  89752. * @returns the updated particle
  89753. */
  89754. updateParticle(particle: SolidParticle): SolidParticle;
  89755. /**
  89756. * Updates a vertex of a particle : it can be overwritten by the user.
  89757. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89758. * @param particle the current particle
  89759. * @param vertex the current index of the current particle
  89760. * @param pt the index of the current vertex in the particle shape
  89761. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89762. * @example : just set a vertex particle position
  89763. * @returns the updated vertex
  89764. */
  89765. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89766. /**
  89767. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89768. * This does nothing and may be overwritten by the user.
  89769. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89770. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89771. * @param update the boolean update value actually passed to setParticles()
  89772. */
  89773. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89774. /**
  89775. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89776. * This will be passed three parameters.
  89777. * This does nothing and may be overwritten by the user.
  89778. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89779. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89780. * @param update the boolean update value actually passed to setParticles()
  89781. */
  89782. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89783. }
  89784. }
  89785. declare module BABYLON {
  89786. /**
  89787. * Represents one particle of a solid particle system.
  89788. */
  89789. export class SolidParticle {
  89790. /**
  89791. * particle global index
  89792. */
  89793. idx: number;
  89794. /**
  89795. * The color of the particle
  89796. */
  89797. color: Nullable<Color4>;
  89798. /**
  89799. * The world space position of the particle.
  89800. */
  89801. position: Vector3;
  89802. /**
  89803. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89804. */
  89805. rotation: Vector3;
  89806. /**
  89807. * The world space rotation quaternion of the particle.
  89808. */
  89809. rotationQuaternion: Nullable<Quaternion>;
  89810. /**
  89811. * The scaling of the particle.
  89812. */
  89813. scaling: Vector3;
  89814. /**
  89815. * The uvs of the particle.
  89816. */
  89817. uvs: Vector4;
  89818. /**
  89819. * The current speed of the particle.
  89820. */
  89821. velocity: Vector3;
  89822. /**
  89823. * The pivot point in the particle local space.
  89824. */
  89825. pivot: Vector3;
  89826. /**
  89827. * Must the particle be translated from its pivot point in its local space ?
  89828. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89829. * Default : false
  89830. */
  89831. translateFromPivot: boolean;
  89832. /**
  89833. * Is the particle active or not ?
  89834. */
  89835. alive: boolean;
  89836. /**
  89837. * Is the particle visible or not ?
  89838. */
  89839. isVisible: boolean;
  89840. /**
  89841. * Index of this particle in the global "positions" array (Internal use)
  89842. * @hidden
  89843. */
  89844. _pos: number;
  89845. /**
  89846. * @hidden Index of this particle in the global "indices" array (Internal use)
  89847. */
  89848. _ind: number;
  89849. /**
  89850. * @hidden ModelShape of this particle (Internal use)
  89851. */
  89852. _model: ModelShape;
  89853. /**
  89854. * ModelShape id of this particle
  89855. */
  89856. shapeId: number;
  89857. /**
  89858. * Index of the particle in its shape id (Internal use)
  89859. */
  89860. idxInShape: number;
  89861. /**
  89862. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89863. */
  89864. _modelBoundingInfo: BoundingInfo;
  89865. /**
  89866. * @hidden Particle BoundingInfo object (Internal use)
  89867. */
  89868. _boundingInfo: BoundingInfo;
  89869. /**
  89870. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89871. */
  89872. _sps: SolidParticleSystem;
  89873. /**
  89874. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89875. */
  89876. _stillInvisible: boolean;
  89877. /**
  89878. * @hidden Last computed particle rotation matrix
  89879. */
  89880. _rotationMatrix: number[];
  89881. /**
  89882. * Parent particle Id, if any.
  89883. * Default null.
  89884. */
  89885. parentId: Nullable<number>;
  89886. /**
  89887. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89888. * The possible values are :
  89889. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89890. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89891. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89892. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89893. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89894. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89895. * */
  89896. cullingStrategy: number;
  89897. /**
  89898. * @hidden Internal global position in the SPS.
  89899. */
  89900. _globalPosition: Vector3;
  89901. /**
  89902. * Creates a Solid Particle object.
  89903. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89904. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89905. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89906. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89907. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89908. * @param shapeId (integer) is the model shape identifier in the SPS.
  89909. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89910. * @param sps defines the sps it is associated to
  89911. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89912. */
  89913. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89914. /**
  89915. * Legacy support, changed scale to scaling
  89916. */
  89917. /**
  89918. * Legacy support, changed scale to scaling
  89919. */
  89920. scale: Vector3;
  89921. /**
  89922. * Legacy support, changed quaternion to rotationQuaternion
  89923. */
  89924. /**
  89925. * Legacy support, changed quaternion to rotationQuaternion
  89926. */
  89927. quaternion: Nullable<Quaternion>;
  89928. /**
  89929. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89930. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89931. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89932. * @returns true if it intersects
  89933. */
  89934. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89935. /**
  89936. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89937. * A particle is in the frustum if its bounding box intersects the frustum
  89938. * @param frustumPlanes defines the frustum to test
  89939. * @returns true if the particle is in the frustum planes
  89940. */
  89941. isInFrustum(frustumPlanes: Plane[]): boolean;
  89942. /**
  89943. * get the rotation matrix of the particle
  89944. * @hidden
  89945. */
  89946. getRotationMatrix(m: Matrix): void;
  89947. }
  89948. /**
  89949. * Represents the shape of the model used by one particle of a solid particle system.
  89950. * SPS internal tool, don't use it manually.
  89951. */
  89952. export class ModelShape {
  89953. /**
  89954. * The shape id
  89955. * @hidden
  89956. */
  89957. shapeID: number;
  89958. /**
  89959. * flat array of model positions (internal use)
  89960. * @hidden
  89961. */
  89962. _shape: Vector3[];
  89963. /**
  89964. * flat array of model UVs (internal use)
  89965. * @hidden
  89966. */
  89967. _shapeUV: number[];
  89968. /**
  89969. * length of the shape in the model indices array (internal use)
  89970. * @hidden
  89971. */
  89972. _indicesLength: number;
  89973. /**
  89974. * Custom position function (internal use)
  89975. * @hidden
  89976. */
  89977. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89978. /**
  89979. * Custom vertex function (internal use)
  89980. * @hidden
  89981. */
  89982. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89983. /**
  89984. * 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.
  89985. * SPS internal tool, don't use it manually.
  89986. * @hidden
  89987. */
  89988. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  89989. }
  89990. /**
  89991. * Represents a Depth Sorted Particle in the solid particle system.
  89992. */
  89993. export class DepthSortedParticle {
  89994. /**
  89995. * Index of the particle in the "indices" array
  89996. */
  89997. ind: number;
  89998. /**
  89999. * Length of the particle shape in the "indices" array
  90000. */
  90001. indicesLength: number;
  90002. /**
  90003. * Squared distance from the particle to the camera
  90004. */
  90005. sqDistance: number;
  90006. }
  90007. }
  90008. declare module BABYLON {
  90009. /**
  90010. * @hidden
  90011. */
  90012. export class _MeshCollisionData {
  90013. _checkCollisions: boolean;
  90014. _collisionMask: number;
  90015. _collisionGroup: number;
  90016. _collider: Nullable<Collider>;
  90017. _oldPositionForCollisions: Vector3;
  90018. _diffPositionForCollisions: Vector3;
  90019. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90020. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90021. }
  90022. }
  90023. declare module BABYLON {
  90024. /** @hidden */
  90025. class _FacetDataStorage {
  90026. facetPositions: Vector3[];
  90027. facetNormals: Vector3[];
  90028. facetPartitioning: number[][];
  90029. facetNb: number;
  90030. partitioningSubdivisions: number;
  90031. partitioningBBoxRatio: number;
  90032. facetDataEnabled: boolean;
  90033. facetParameters: any;
  90034. bbSize: Vector3;
  90035. subDiv: {
  90036. max: number;
  90037. X: number;
  90038. Y: number;
  90039. Z: number;
  90040. };
  90041. facetDepthSort: boolean;
  90042. facetDepthSortEnabled: boolean;
  90043. depthSortedIndices: IndicesArray;
  90044. depthSortedFacets: {
  90045. ind: number;
  90046. sqDistance: number;
  90047. }[];
  90048. facetDepthSortFunction: (f1: {
  90049. ind: number;
  90050. sqDistance: number;
  90051. }, f2: {
  90052. ind: number;
  90053. sqDistance: number;
  90054. }) => number;
  90055. facetDepthSortFrom: Vector3;
  90056. facetDepthSortOrigin: Vector3;
  90057. invertedMatrix: Matrix;
  90058. }
  90059. /**
  90060. * @hidden
  90061. **/
  90062. class _InternalAbstractMeshDataInfo {
  90063. _hasVertexAlpha: boolean;
  90064. _useVertexColors: boolean;
  90065. _numBoneInfluencers: number;
  90066. _applyFog: boolean;
  90067. _receiveShadows: boolean;
  90068. _facetData: _FacetDataStorage;
  90069. _visibility: number;
  90070. _skeleton: Nullable<Skeleton>;
  90071. _layerMask: number;
  90072. _computeBonesUsingShaders: boolean;
  90073. _isActive: boolean;
  90074. _onlyForInstances: boolean;
  90075. _isActiveIntermediate: boolean;
  90076. _onlyForInstancesIntermediate: boolean;
  90077. }
  90078. /**
  90079. * Class used to store all common mesh properties
  90080. */
  90081. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90082. /** No occlusion */
  90083. static OCCLUSION_TYPE_NONE: number;
  90084. /** Occlusion set to optimisitic */
  90085. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90086. /** Occlusion set to strict */
  90087. static OCCLUSION_TYPE_STRICT: number;
  90088. /** Use an accurante occlusion algorithm */
  90089. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90090. /** Use a conservative occlusion algorithm */
  90091. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90092. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90093. * Test order :
  90094. * Is the bounding sphere outside the frustum ?
  90095. * If not, are the bounding box vertices outside the frustum ?
  90096. * It not, then the cullable object is in the frustum.
  90097. */
  90098. static readonly CULLINGSTRATEGY_STANDARD: number;
  90099. /** Culling strategy : Bounding Sphere Only.
  90100. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90101. * It's also less accurate than the standard because some not visible objects can still be selected.
  90102. * Test : is the bounding sphere outside the frustum ?
  90103. * If not, then the cullable object is in the frustum.
  90104. */
  90105. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90106. /** Culling strategy : Optimistic Inclusion.
  90107. * This in an inclusion test first, then the standard exclusion test.
  90108. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90109. * 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.
  90110. * Anyway, it's as accurate as the standard strategy.
  90111. * Test :
  90112. * Is the cullable object bounding sphere center in the frustum ?
  90113. * If not, apply the default culling strategy.
  90114. */
  90115. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90116. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90117. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90118. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90119. * 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.
  90120. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90121. * Test :
  90122. * Is the cullable object bounding sphere center in the frustum ?
  90123. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90124. */
  90125. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90126. /**
  90127. * No billboard
  90128. */
  90129. static readonly BILLBOARDMODE_NONE: number;
  90130. /** Billboard on X axis */
  90131. static readonly BILLBOARDMODE_X: number;
  90132. /** Billboard on Y axis */
  90133. static readonly BILLBOARDMODE_Y: number;
  90134. /** Billboard on Z axis */
  90135. static readonly BILLBOARDMODE_Z: number;
  90136. /** Billboard on all axes */
  90137. static readonly BILLBOARDMODE_ALL: number;
  90138. /** Billboard on using position instead of orientation */
  90139. static readonly BILLBOARDMODE_USE_POSITION: number;
  90140. /** @hidden */
  90141. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90142. /**
  90143. * The culling strategy to use to check whether the mesh must be rendered or not.
  90144. * This value can be changed at any time and will be used on the next render mesh selection.
  90145. * The possible values are :
  90146. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90147. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90148. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90149. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90150. * Please read each static variable documentation to get details about the culling process.
  90151. * */
  90152. cullingStrategy: number;
  90153. /**
  90154. * Gets the number of facets in the mesh
  90155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90156. */
  90157. readonly facetNb: number;
  90158. /**
  90159. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90161. */
  90162. partitioningSubdivisions: number;
  90163. /**
  90164. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90165. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90167. */
  90168. partitioningBBoxRatio: number;
  90169. /**
  90170. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90171. * Works only for updatable meshes.
  90172. * Doesn't work with multi-materials
  90173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90174. */
  90175. mustDepthSortFacets: boolean;
  90176. /**
  90177. * The location (Vector3) where the facet depth sort must be computed from.
  90178. * By default, the active camera position.
  90179. * Used only when facet depth sort is enabled
  90180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90181. */
  90182. facetDepthSortFrom: Vector3;
  90183. /**
  90184. * gets a boolean indicating if facetData is enabled
  90185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90186. */
  90187. readonly isFacetDataEnabled: boolean;
  90188. /** @hidden */
  90189. _updateNonUniformScalingState(value: boolean): boolean;
  90190. /**
  90191. * An event triggered when this mesh collides with another one
  90192. */
  90193. onCollideObservable: Observable<AbstractMesh>;
  90194. /** Set a function to call when this mesh collides with another one */
  90195. onCollide: () => void;
  90196. /**
  90197. * An event triggered when the collision's position changes
  90198. */
  90199. onCollisionPositionChangeObservable: Observable<Vector3>;
  90200. /** Set a function to call when the collision's position changes */
  90201. onCollisionPositionChange: () => void;
  90202. /**
  90203. * An event triggered when material is changed
  90204. */
  90205. onMaterialChangedObservable: Observable<AbstractMesh>;
  90206. /**
  90207. * Gets or sets the orientation for POV movement & rotation
  90208. */
  90209. definedFacingForward: boolean;
  90210. /** @hidden */
  90211. _occlusionQuery: Nullable<WebGLQuery>;
  90212. /** @hidden */
  90213. _renderingGroup: Nullable<RenderingGroup>;
  90214. /**
  90215. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90216. */
  90217. /**
  90218. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90219. */
  90220. visibility: number;
  90221. /** Gets or sets the alpha index used to sort transparent meshes
  90222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90223. */
  90224. alphaIndex: number;
  90225. /**
  90226. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90227. */
  90228. isVisible: boolean;
  90229. /**
  90230. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90231. */
  90232. isPickable: boolean;
  90233. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90234. showSubMeshesBoundingBox: boolean;
  90235. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90237. */
  90238. isBlocker: boolean;
  90239. /**
  90240. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90241. */
  90242. enablePointerMoveEvents: boolean;
  90243. /**
  90244. * Specifies the rendering group id for this mesh (0 by default)
  90245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90246. */
  90247. renderingGroupId: number;
  90248. private _material;
  90249. /** Gets or sets current material */
  90250. material: Nullable<Material>;
  90251. /**
  90252. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90253. * @see http://doc.babylonjs.com/babylon101/shadows
  90254. */
  90255. receiveShadows: boolean;
  90256. /** Defines color to use when rendering outline */
  90257. outlineColor: Color3;
  90258. /** Define width to use when rendering outline */
  90259. outlineWidth: number;
  90260. /** Defines color to use when rendering overlay */
  90261. overlayColor: Color3;
  90262. /** Defines alpha to use when rendering overlay */
  90263. overlayAlpha: number;
  90264. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90265. hasVertexAlpha: boolean;
  90266. /** 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) */
  90267. useVertexColors: boolean;
  90268. /**
  90269. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90270. */
  90271. computeBonesUsingShaders: boolean;
  90272. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90273. numBoneInfluencers: number;
  90274. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90275. applyFog: boolean;
  90276. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90277. useOctreeForRenderingSelection: boolean;
  90278. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90279. useOctreeForPicking: boolean;
  90280. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90281. useOctreeForCollisions: boolean;
  90282. /**
  90283. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90284. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90285. */
  90286. layerMask: number;
  90287. /**
  90288. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90289. */
  90290. alwaysSelectAsActiveMesh: boolean;
  90291. /**
  90292. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90293. */
  90294. doNotSyncBoundingInfo: boolean;
  90295. /**
  90296. * Gets or sets the current action manager
  90297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90298. */
  90299. actionManager: Nullable<AbstractActionManager>;
  90300. private _meshCollisionData;
  90301. /**
  90302. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90304. */
  90305. ellipsoid: Vector3;
  90306. /**
  90307. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90309. */
  90310. ellipsoidOffset: Vector3;
  90311. /**
  90312. * Gets or sets a collision mask used to mask collisions (default is -1).
  90313. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90314. */
  90315. collisionMask: number;
  90316. /**
  90317. * Gets or sets the current collision group mask (-1 by default).
  90318. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90319. */
  90320. collisionGroup: number;
  90321. /**
  90322. * Defines edge width used when edgesRenderer is enabled
  90323. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90324. */
  90325. edgesWidth: number;
  90326. /**
  90327. * Defines edge color used when edgesRenderer is enabled
  90328. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90329. */
  90330. edgesColor: Color4;
  90331. /** @hidden */
  90332. _edgesRenderer: Nullable<IEdgesRenderer>;
  90333. /** @hidden */
  90334. _masterMesh: Nullable<AbstractMesh>;
  90335. /** @hidden */
  90336. _boundingInfo: Nullable<BoundingInfo>;
  90337. /** @hidden */
  90338. _renderId: number;
  90339. /**
  90340. * Gets or sets the list of subMeshes
  90341. * @see http://doc.babylonjs.com/how_to/multi_materials
  90342. */
  90343. subMeshes: SubMesh[];
  90344. /** @hidden */
  90345. _intersectionsInProgress: AbstractMesh[];
  90346. /** @hidden */
  90347. _unIndexed: boolean;
  90348. /** @hidden */
  90349. _lightSources: Light[];
  90350. /** Gets the list of lights affecting that mesh */
  90351. readonly lightSources: Light[];
  90352. /** @hidden */
  90353. readonly _positions: Nullable<Vector3[]>;
  90354. /** @hidden */
  90355. _waitingData: {
  90356. lods: Nullable<any>;
  90357. actions: Nullable<any>;
  90358. freezeWorldMatrix: Nullable<boolean>;
  90359. };
  90360. /** @hidden */
  90361. _bonesTransformMatrices: Nullable<Float32Array>;
  90362. /** @hidden */
  90363. _transformMatrixTexture: Nullable<RawTexture>;
  90364. /**
  90365. * Gets or sets a skeleton to apply skining transformations
  90366. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90367. */
  90368. skeleton: Nullable<Skeleton>;
  90369. /**
  90370. * An event triggered when the mesh is rebuilt.
  90371. */
  90372. onRebuildObservable: Observable<AbstractMesh>;
  90373. /**
  90374. * Creates a new AbstractMesh
  90375. * @param name defines the name of the mesh
  90376. * @param scene defines the hosting scene
  90377. */
  90378. constructor(name: string, scene?: Nullable<Scene>);
  90379. /**
  90380. * Returns the string "AbstractMesh"
  90381. * @returns "AbstractMesh"
  90382. */
  90383. getClassName(): string;
  90384. /**
  90385. * Gets a string representation of the current mesh
  90386. * @param fullDetails defines a boolean indicating if full details must be included
  90387. * @returns a string representation of the current mesh
  90388. */
  90389. toString(fullDetails?: boolean): string;
  90390. /**
  90391. * @hidden
  90392. */
  90393. protected _getEffectiveParent(): Nullable<Node>;
  90394. /** @hidden */
  90395. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90396. /** @hidden */
  90397. _rebuild(): void;
  90398. /** @hidden */
  90399. _resyncLightSources(): void;
  90400. /** @hidden */
  90401. _resyncLighSource(light: Light): void;
  90402. /** @hidden */
  90403. _unBindEffect(): void;
  90404. /** @hidden */
  90405. _removeLightSource(light: Light): void;
  90406. private _markSubMeshesAsDirty;
  90407. /** @hidden */
  90408. _markSubMeshesAsLightDirty(): void;
  90409. /** @hidden */
  90410. _markSubMeshesAsAttributesDirty(): void;
  90411. /** @hidden */
  90412. _markSubMeshesAsMiscDirty(): void;
  90413. /**
  90414. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90415. */
  90416. scaling: Vector3;
  90417. /**
  90418. * Returns true if the mesh is blocked. Implemented by child classes
  90419. */
  90420. readonly isBlocked: boolean;
  90421. /**
  90422. * Returns the mesh itself by default. Implemented by child classes
  90423. * @param camera defines the camera to use to pick the right LOD level
  90424. * @returns the currentAbstractMesh
  90425. */
  90426. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90427. /**
  90428. * Returns 0 by default. Implemented by child classes
  90429. * @returns an integer
  90430. */
  90431. getTotalVertices(): number;
  90432. /**
  90433. * Returns a positive integer : the total number of indices in this mesh geometry.
  90434. * @returns the numner of indices or zero if the mesh has no geometry.
  90435. */
  90436. getTotalIndices(): number;
  90437. /**
  90438. * Returns null by default. Implemented by child classes
  90439. * @returns null
  90440. */
  90441. getIndices(): Nullable<IndicesArray>;
  90442. /**
  90443. * Returns the array of the requested vertex data kind. Implemented by child classes
  90444. * @param kind defines the vertex data kind to use
  90445. * @returns null
  90446. */
  90447. getVerticesData(kind: string): Nullable<FloatArray>;
  90448. /**
  90449. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90450. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90451. * Note that a new underlying VertexBuffer object is created each call.
  90452. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90453. * @param kind defines vertex data kind:
  90454. * * VertexBuffer.PositionKind
  90455. * * VertexBuffer.UVKind
  90456. * * VertexBuffer.UV2Kind
  90457. * * VertexBuffer.UV3Kind
  90458. * * VertexBuffer.UV4Kind
  90459. * * VertexBuffer.UV5Kind
  90460. * * VertexBuffer.UV6Kind
  90461. * * VertexBuffer.ColorKind
  90462. * * VertexBuffer.MatricesIndicesKind
  90463. * * VertexBuffer.MatricesIndicesExtraKind
  90464. * * VertexBuffer.MatricesWeightsKind
  90465. * * VertexBuffer.MatricesWeightsExtraKind
  90466. * @param data defines the data source
  90467. * @param updatable defines if the data must be flagged as updatable (or static)
  90468. * @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
  90469. * @returns the current mesh
  90470. */
  90471. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90472. /**
  90473. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90474. * If the mesh has no geometry, it is simply returned as it is.
  90475. * @param kind defines vertex data kind:
  90476. * * VertexBuffer.PositionKind
  90477. * * VertexBuffer.UVKind
  90478. * * VertexBuffer.UV2Kind
  90479. * * VertexBuffer.UV3Kind
  90480. * * VertexBuffer.UV4Kind
  90481. * * VertexBuffer.UV5Kind
  90482. * * VertexBuffer.UV6Kind
  90483. * * VertexBuffer.ColorKind
  90484. * * VertexBuffer.MatricesIndicesKind
  90485. * * VertexBuffer.MatricesIndicesExtraKind
  90486. * * VertexBuffer.MatricesWeightsKind
  90487. * * VertexBuffer.MatricesWeightsExtraKind
  90488. * @param data defines the data source
  90489. * @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
  90490. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90491. * @returns the current mesh
  90492. */
  90493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90494. /**
  90495. * Sets the mesh indices,
  90496. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90497. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90498. * @param totalVertices Defines the total number of vertices
  90499. * @returns the current mesh
  90500. */
  90501. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90502. /**
  90503. * Gets a boolean indicating if specific vertex data is present
  90504. * @param kind defines the vertex data kind to use
  90505. * @returns true is data kind is present
  90506. */
  90507. isVerticesDataPresent(kind: string): boolean;
  90508. /**
  90509. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90510. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90511. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90512. * @returns a BoundingInfo
  90513. */
  90514. getBoundingInfo(): BoundingInfo;
  90515. /**
  90516. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90517. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90518. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90519. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90520. * @returns the current mesh
  90521. */
  90522. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90523. /**
  90524. * Overwrite the current bounding info
  90525. * @param boundingInfo defines the new bounding info
  90526. * @returns the current mesh
  90527. */
  90528. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90529. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90530. readonly useBones: boolean;
  90531. /** @hidden */
  90532. _preActivate(): void;
  90533. /** @hidden */
  90534. _preActivateForIntermediateRendering(renderId: number): void;
  90535. /** @hidden */
  90536. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90537. /** @hidden */
  90538. _postActivate(): void;
  90539. /** @hidden */
  90540. _freeze(): void;
  90541. /** @hidden */
  90542. _unFreeze(): void;
  90543. /**
  90544. * Gets the current world matrix
  90545. * @returns a Matrix
  90546. */
  90547. getWorldMatrix(): Matrix;
  90548. /** @hidden */
  90549. _getWorldMatrixDeterminant(): number;
  90550. /**
  90551. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90552. */
  90553. readonly isAnInstance: boolean;
  90554. /**
  90555. * Gets a boolean indicating if this mesh has instances
  90556. */
  90557. readonly hasInstances: boolean;
  90558. /**
  90559. * Perform relative position change from the point of view of behind the front of the mesh.
  90560. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90561. * Supports definition of mesh facing forward or backward
  90562. * @param amountRight defines the distance on the right axis
  90563. * @param amountUp defines the distance on the up axis
  90564. * @param amountForward defines the distance on the forward axis
  90565. * @returns the current mesh
  90566. */
  90567. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90568. /**
  90569. * Calculate relative position change from the point of view of behind the front of the mesh.
  90570. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90571. * Supports definition of mesh facing forward or backward
  90572. * @param amountRight defines the distance on the right axis
  90573. * @param amountUp defines the distance on the up axis
  90574. * @param amountForward defines the distance on the forward axis
  90575. * @returns the new displacement vector
  90576. */
  90577. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90578. /**
  90579. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90580. * Supports definition of mesh facing forward or backward
  90581. * @param flipBack defines the flip
  90582. * @param twirlClockwise defines the twirl
  90583. * @param tiltRight defines the tilt
  90584. * @returns the current mesh
  90585. */
  90586. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90587. /**
  90588. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90589. * Supports definition of mesh facing forward or backward.
  90590. * @param flipBack defines the flip
  90591. * @param twirlClockwise defines the twirl
  90592. * @param tiltRight defines the tilt
  90593. * @returns the new rotation vector
  90594. */
  90595. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90596. /**
  90597. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90598. * This means the mesh underlying bounding box and sphere are recomputed.
  90599. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90600. * @returns the current mesh
  90601. */
  90602. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90603. /** @hidden */
  90604. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90605. /** @hidden */
  90606. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90607. /** @hidden */
  90608. _updateBoundingInfo(): AbstractMesh;
  90609. /** @hidden */
  90610. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90611. /** @hidden */
  90612. protected _afterComputeWorldMatrix(): void;
  90613. /** @hidden */
  90614. readonly _effectiveMesh: AbstractMesh;
  90615. /**
  90616. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90617. * A mesh is in the frustum if its bounding box intersects the frustum
  90618. * @param frustumPlanes defines the frustum to test
  90619. * @returns true if the mesh is in the frustum planes
  90620. */
  90621. isInFrustum(frustumPlanes: Plane[]): boolean;
  90622. /**
  90623. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90624. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90625. * @param frustumPlanes defines the frustum to test
  90626. * @returns true if the mesh is completely in the frustum planes
  90627. */
  90628. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90629. /**
  90630. * True if the mesh intersects another mesh or a SolidParticle object
  90631. * @param mesh defines a target mesh or SolidParticle to test
  90632. * @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)
  90633. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90634. * @returns true if there is an intersection
  90635. */
  90636. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90637. /**
  90638. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90639. * @param point defines the point to test
  90640. * @returns true if there is an intersection
  90641. */
  90642. intersectsPoint(point: Vector3): boolean;
  90643. /**
  90644. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90646. */
  90647. checkCollisions: boolean;
  90648. /**
  90649. * Gets Collider object used to compute collisions (not physics)
  90650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90651. */
  90652. readonly collider: Nullable<Collider>;
  90653. /**
  90654. * Move the mesh using collision engine
  90655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90656. * @param displacement defines the requested displacement vector
  90657. * @returns the current mesh
  90658. */
  90659. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90660. private _onCollisionPositionChange;
  90661. /** @hidden */
  90662. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90663. /** @hidden */
  90664. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90665. /** @hidden */
  90666. _checkCollision(collider: Collider): AbstractMesh;
  90667. /** @hidden */
  90668. _generatePointsArray(): boolean;
  90669. /**
  90670. * Checks if the passed Ray intersects with the mesh
  90671. * @param ray defines the ray to use
  90672. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90673. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90674. * @returns the picking info
  90675. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90676. */
  90677. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90678. /**
  90679. * Clones the current mesh
  90680. * @param name defines the mesh name
  90681. * @param newParent defines the new mesh parent
  90682. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90683. * @returns the new mesh
  90684. */
  90685. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90686. /**
  90687. * Disposes all the submeshes of the current meshnp
  90688. * @returns the current mesh
  90689. */
  90690. releaseSubMeshes(): AbstractMesh;
  90691. /**
  90692. * Releases resources associated with this abstract mesh.
  90693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90695. */
  90696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90697. /**
  90698. * Adds the passed mesh as a child to the current mesh
  90699. * @param mesh defines the child mesh
  90700. * @returns the current mesh
  90701. */
  90702. addChild(mesh: AbstractMesh): AbstractMesh;
  90703. /**
  90704. * Removes the passed mesh from the current mesh children list
  90705. * @param mesh defines the child mesh
  90706. * @returns the current mesh
  90707. */
  90708. removeChild(mesh: AbstractMesh): AbstractMesh;
  90709. /** @hidden */
  90710. private _initFacetData;
  90711. /**
  90712. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90713. * This method can be called within the render loop.
  90714. * 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
  90715. * @returns the current mesh
  90716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90717. */
  90718. updateFacetData(): AbstractMesh;
  90719. /**
  90720. * Returns the facetLocalNormals array.
  90721. * The normals are expressed in the mesh local spac
  90722. * @returns an array of Vector3
  90723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90724. */
  90725. getFacetLocalNormals(): Vector3[];
  90726. /**
  90727. * Returns the facetLocalPositions array.
  90728. * The facet positions are expressed in the mesh local space
  90729. * @returns an array of Vector3
  90730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90731. */
  90732. getFacetLocalPositions(): Vector3[];
  90733. /**
  90734. * Returns the facetLocalPartioning array
  90735. * @returns an array of array of numbers
  90736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90737. */
  90738. getFacetLocalPartitioning(): number[][];
  90739. /**
  90740. * Returns the i-th facet position in the world system.
  90741. * This method allocates a new Vector3 per call
  90742. * @param i defines the facet index
  90743. * @returns a new Vector3
  90744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90745. */
  90746. getFacetPosition(i: number): Vector3;
  90747. /**
  90748. * Sets the reference Vector3 with the i-th facet position in the world system
  90749. * @param i defines the facet index
  90750. * @param ref defines the target vector
  90751. * @returns the current mesh
  90752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90753. */
  90754. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90755. /**
  90756. * Returns the i-th facet normal in the world system.
  90757. * This method allocates a new Vector3 per call
  90758. * @param i defines the facet index
  90759. * @returns a new Vector3
  90760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90761. */
  90762. getFacetNormal(i: number): Vector3;
  90763. /**
  90764. * Sets the reference Vector3 with the i-th facet normal in the world system
  90765. * @param i defines the facet index
  90766. * @param ref defines the target vector
  90767. * @returns the current mesh
  90768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90769. */
  90770. getFacetNormalToRef(i: number, ref: Vector3): this;
  90771. /**
  90772. * 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)
  90773. * @param x defines x coordinate
  90774. * @param y defines y coordinate
  90775. * @param z defines z coordinate
  90776. * @returns the array of facet indexes
  90777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90778. */
  90779. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90780. /**
  90781. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90782. * @param projected sets as the (x,y,z) world projection on the facet
  90783. * @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
  90784. * @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
  90785. * @param x defines x coordinate
  90786. * @param y defines y coordinate
  90787. * @param z defines z coordinate
  90788. * @returns the face index if found (or null instead)
  90789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90790. */
  90791. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90792. /**
  90793. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90794. * @param projected sets as the (x,y,z) local projection on the facet
  90795. * @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
  90796. * @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
  90797. * @param x defines x coordinate
  90798. * @param y defines y coordinate
  90799. * @param z defines z coordinate
  90800. * @returns the face index if found (or null instead)
  90801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90802. */
  90803. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90804. /**
  90805. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90806. * @returns the parameters
  90807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90808. */
  90809. getFacetDataParameters(): any;
  90810. /**
  90811. * Disables the feature FacetData and frees the related memory
  90812. * @returns the current mesh
  90813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90814. */
  90815. disableFacetData(): AbstractMesh;
  90816. /**
  90817. * Updates the AbstractMesh indices array
  90818. * @param indices defines the data source
  90819. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90820. * @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)
  90821. * @returns the current mesh
  90822. */
  90823. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90824. /**
  90825. * Creates new normals data for the mesh
  90826. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90827. * @returns the current mesh
  90828. */
  90829. createNormals(updatable: boolean): AbstractMesh;
  90830. /**
  90831. * Align the mesh with a normal
  90832. * @param normal defines the normal to use
  90833. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90834. * @returns the current mesh
  90835. */
  90836. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90837. /** @hidden */
  90838. _checkOcclusionQuery(): boolean;
  90839. /**
  90840. * Disables the mesh edge rendering mode
  90841. * @returns the currentAbstractMesh
  90842. */
  90843. disableEdgesRendering(): AbstractMesh;
  90844. /**
  90845. * Enables the edge rendering mode on the mesh.
  90846. * This mode makes the mesh edges visible
  90847. * @param epsilon defines the maximal distance between two angles to detect a face
  90848. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90849. * @returns the currentAbstractMesh
  90850. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90851. */
  90852. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90853. }
  90854. }
  90855. declare module BABYLON {
  90856. /**
  90857. * Interface used to define ActionEvent
  90858. */
  90859. export interface IActionEvent {
  90860. /** The mesh or sprite that triggered the action */
  90861. source: any;
  90862. /** The X mouse cursor position at the time of the event */
  90863. pointerX: number;
  90864. /** The Y mouse cursor position at the time of the event */
  90865. pointerY: number;
  90866. /** The mesh that is currently pointed at (can be null) */
  90867. meshUnderPointer: Nullable<AbstractMesh>;
  90868. /** the original (browser) event that triggered the ActionEvent */
  90869. sourceEvent?: any;
  90870. /** additional data for the event */
  90871. additionalData?: any;
  90872. }
  90873. /**
  90874. * ActionEvent is the event being sent when an action is triggered.
  90875. */
  90876. export class ActionEvent implements IActionEvent {
  90877. /** The mesh or sprite that triggered the action */
  90878. source: any;
  90879. /** The X mouse cursor position at the time of the event */
  90880. pointerX: number;
  90881. /** The Y mouse cursor position at the time of the event */
  90882. pointerY: number;
  90883. /** The mesh that is currently pointed at (can be null) */
  90884. meshUnderPointer: Nullable<AbstractMesh>;
  90885. /** the original (browser) event that triggered the ActionEvent */
  90886. sourceEvent?: any;
  90887. /** additional data for the event */
  90888. additionalData?: any;
  90889. /**
  90890. * Creates a new ActionEvent
  90891. * @param source The mesh or sprite that triggered the action
  90892. * @param pointerX The X mouse cursor position at the time of the event
  90893. * @param pointerY The Y mouse cursor position at the time of the event
  90894. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90895. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90896. * @param additionalData additional data for the event
  90897. */
  90898. constructor(
  90899. /** The mesh or sprite that triggered the action */
  90900. source: any,
  90901. /** The X mouse cursor position at the time of the event */
  90902. pointerX: number,
  90903. /** The Y mouse cursor position at the time of the event */
  90904. pointerY: number,
  90905. /** The mesh that is currently pointed at (can be null) */
  90906. meshUnderPointer: Nullable<AbstractMesh>,
  90907. /** the original (browser) event that triggered the ActionEvent */
  90908. sourceEvent?: any,
  90909. /** additional data for the event */
  90910. additionalData?: any);
  90911. /**
  90912. * Helper function to auto-create an ActionEvent from a source mesh.
  90913. * @param source The source mesh that triggered the event
  90914. * @param evt The original (browser) event
  90915. * @param additionalData additional data for the event
  90916. * @returns the new ActionEvent
  90917. */
  90918. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90919. /**
  90920. * Helper function to auto-create an ActionEvent from a source sprite
  90921. * @param source The source sprite that triggered the event
  90922. * @param scene Scene associated with the sprite
  90923. * @param evt The original (browser) event
  90924. * @param additionalData additional data for the event
  90925. * @returns the new ActionEvent
  90926. */
  90927. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90928. /**
  90929. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90930. * @param scene the scene where the event occurred
  90931. * @param evt The original (browser) event
  90932. * @returns the new ActionEvent
  90933. */
  90934. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90935. /**
  90936. * Helper function to auto-create an ActionEvent from a primitive
  90937. * @param prim defines the target primitive
  90938. * @param pointerPos defines the pointer position
  90939. * @param evt The original (browser) event
  90940. * @param additionalData additional data for the event
  90941. * @returns the new ActionEvent
  90942. */
  90943. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90944. }
  90945. }
  90946. declare module BABYLON {
  90947. /**
  90948. * Abstract class used to decouple action Manager from scene and meshes.
  90949. * Do not instantiate.
  90950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90951. */
  90952. export abstract class AbstractActionManager implements IDisposable {
  90953. /** Gets the list of active triggers */
  90954. static Triggers: {
  90955. [key: string]: number;
  90956. };
  90957. /** Gets the cursor to use when hovering items */
  90958. hoverCursor: string;
  90959. /** Gets the list of actions */
  90960. actions: IAction[];
  90961. /**
  90962. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90963. */
  90964. isRecursive: boolean;
  90965. /**
  90966. * Releases all associated resources
  90967. */
  90968. abstract dispose(): void;
  90969. /**
  90970. * Does this action manager has pointer triggers
  90971. */
  90972. abstract readonly hasPointerTriggers: boolean;
  90973. /**
  90974. * Does this action manager has pick triggers
  90975. */
  90976. abstract readonly hasPickTriggers: boolean;
  90977. /**
  90978. * Process a specific trigger
  90979. * @param trigger defines the trigger to process
  90980. * @param evt defines the event details to be processed
  90981. */
  90982. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90983. /**
  90984. * Does this action manager handles actions of any of the given triggers
  90985. * @param triggers defines the triggers to be tested
  90986. * @return a boolean indicating whether one (or more) of the triggers is handled
  90987. */
  90988. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90989. /**
  90990. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90991. * speed.
  90992. * @param triggerA defines the trigger to be tested
  90993. * @param triggerB defines the trigger to be tested
  90994. * @return a boolean indicating whether one (or more) of the triggers is handled
  90995. */
  90996. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90997. /**
  90998. * Does this action manager handles actions of a given trigger
  90999. * @param trigger defines the trigger to be tested
  91000. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91001. * @return whether the trigger is handled
  91002. */
  91003. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91004. /**
  91005. * Serialize this manager to a JSON object
  91006. * @param name defines the property name to store this manager
  91007. * @returns a JSON representation of this manager
  91008. */
  91009. abstract serialize(name: string): any;
  91010. /**
  91011. * Registers an action to this action manager
  91012. * @param action defines the action to be registered
  91013. * @return the action amended (prepared) after registration
  91014. */
  91015. abstract registerAction(action: IAction): Nullable<IAction>;
  91016. /**
  91017. * Unregisters an action to this action manager
  91018. * @param action defines the action to be unregistered
  91019. * @return a boolean indicating whether the action has been unregistered
  91020. */
  91021. abstract unregisterAction(action: IAction): Boolean;
  91022. /**
  91023. * Does exist one action manager with at least one trigger
  91024. **/
  91025. static readonly HasTriggers: boolean;
  91026. /**
  91027. * Does exist one action manager with at least one pick trigger
  91028. **/
  91029. static readonly HasPickTriggers: boolean;
  91030. /**
  91031. * Does exist one action manager that handles actions of a given trigger
  91032. * @param trigger defines the trigger to be tested
  91033. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91034. **/
  91035. static HasSpecificTrigger(trigger: number): boolean;
  91036. }
  91037. }
  91038. declare module BABYLON {
  91039. /**
  91040. * Defines how a node can be built from a string name.
  91041. */
  91042. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91043. /**
  91044. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91045. */
  91046. export class Node implements IBehaviorAware<Node> {
  91047. /** @hidden */
  91048. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91049. private static _NodeConstructors;
  91050. /**
  91051. * Add a new node constructor
  91052. * @param type defines the type name of the node to construct
  91053. * @param constructorFunc defines the constructor function
  91054. */
  91055. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91056. /**
  91057. * Returns a node constructor based on type name
  91058. * @param type defines the type name
  91059. * @param name defines the new node name
  91060. * @param scene defines the hosting scene
  91061. * @param options defines optional options to transmit to constructors
  91062. * @returns the new constructor or null
  91063. */
  91064. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91065. /**
  91066. * Gets or sets the name of the node
  91067. */
  91068. name: string;
  91069. /**
  91070. * Gets or sets the id of the node
  91071. */
  91072. id: string;
  91073. /**
  91074. * Gets or sets the unique id of the node
  91075. */
  91076. uniqueId: number;
  91077. /**
  91078. * Gets or sets a string used to store user defined state for the node
  91079. */
  91080. state: string;
  91081. /**
  91082. * Gets or sets an object used to store user defined information for the node
  91083. */
  91084. metadata: any;
  91085. /**
  91086. * For internal use only. Please do not use.
  91087. */
  91088. reservedDataStore: any;
  91089. /**
  91090. * List of inspectable custom properties (used by the Inspector)
  91091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91092. */
  91093. inspectableCustomProperties: IInspectable[];
  91094. /**
  91095. * Gets or sets a boolean used to define if the node must be serialized
  91096. */
  91097. doNotSerialize: boolean;
  91098. /** @hidden */
  91099. _isDisposed: boolean;
  91100. /**
  91101. * Gets a list of Animations associated with the node
  91102. */
  91103. animations: Animation[];
  91104. protected _ranges: {
  91105. [name: string]: Nullable<AnimationRange>;
  91106. };
  91107. /**
  91108. * Callback raised when the node is ready to be used
  91109. */
  91110. onReady: Nullable<(node: Node) => void>;
  91111. private _isEnabled;
  91112. private _isParentEnabled;
  91113. private _isReady;
  91114. /** @hidden */
  91115. _currentRenderId: number;
  91116. private _parentUpdateId;
  91117. /** @hidden */
  91118. _childUpdateId: number;
  91119. /** @hidden */
  91120. _waitingParentId: Nullable<string>;
  91121. /** @hidden */
  91122. _scene: Scene;
  91123. /** @hidden */
  91124. _cache: any;
  91125. private _parentNode;
  91126. private _children;
  91127. /** @hidden */
  91128. _worldMatrix: Matrix;
  91129. /** @hidden */
  91130. _worldMatrixDeterminant: number;
  91131. /** @hidden */
  91132. _worldMatrixDeterminantIsDirty: boolean;
  91133. /** @hidden */
  91134. private _sceneRootNodesIndex;
  91135. /**
  91136. * Gets a boolean indicating if the node has been disposed
  91137. * @returns true if the node was disposed
  91138. */
  91139. isDisposed(): boolean;
  91140. /**
  91141. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91142. * @see https://doc.babylonjs.com/how_to/parenting
  91143. */
  91144. parent: Nullable<Node>;
  91145. private addToSceneRootNodes;
  91146. private removeFromSceneRootNodes;
  91147. private _animationPropertiesOverride;
  91148. /**
  91149. * Gets or sets the animation properties override
  91150. */
  91151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91152. /**
  91153. * Gets a string idenfifying the name of the class
  91154. * @returns "Node" string
  91155. */
  91156. getClassName(): string;
  91157. /** @hidden */
  91158. readonly _isNode: boolean;
  91159. /**
  91160. * An event triggered when the mesh is disposed
  91161. */
  91162. onDisposeObservable: Observable<Node>;
  91163. private _onDisposeObserver;
  91164. /**
  91165. * Sets a callback that will be raised when the node will be disposed
  91166. */
  91167. onDispose: () => void;
  91168. /**
  91169. * Creates a new Node
  91170. * @param name the name and id to be given to this node
  91171. * @param scene the scene this node will be added to
  91172. * @param addToRootNodes the node will be added to scene.rootNodes
  91173. */
  91174. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91175. /**
  91176. * Gets the scene of the node
  91177. * @returns a scene
  91178. */
  91179. getScene(): Scene;
  91180. /**
  91181. * Gets the engine of the node
  91182. * @returns a Engine
  91183. */
  91184. getEngine(): Engine;
  91185. private _behaviors;
  91186. /**
  91187. * Attach a behavior to the node
  91188. * @see http://doc.babylonjs.com/features/behaviour
  91189. * @param behavior defines the behavior to attach
  91190. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91191. * @returns the current Node
  91192. */
  91193. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91194. /**
  91195. * Remove an attached behavior
  91196. * @see http://doc.babylonjs.com/features/behaviour
  91197. * @param behavior defines the behavior to attach
  91198. * @returns the current Node
  91199. */
  91200. removeBehavior(behavior: Behavior<Node>): Node;
  91201. /**
  91202. * Gets the list of attached behaviors
  91203. * @see http://doc.babylonjs.com/features/behaviour
  91204. */
  91205. readonly behaviors: Behavior<Node>[];
  91206. /**
  91207. * Gets an attached behavior by name
  91208. * @param name defines the name of the behavior to look for
  91209. * @see http://doc.babylonjs.com/features/behaviour
  91210. * @returns null if behavior was not found else the requested behavior
  91211. */
  91212. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91213. /**
  91214. * Returns the latest update of the World matrix
  91215. * @returns a Matrix
  91216. */
  91217. getWorldMatrix(): Matrix;
  91218. /** @hidden */
  91219. _getWorldMatrixDeterminant(): number;
  91220. /**
  91221. * Returns directly the latest state of the mesh World matrix.
  91222. * A Matrix is returned.
  91223. */
  91224. readonly worldMatrixFromCache: Matrix;
  91225. /** @hidden */
  91226. _initCache(): void;
  91227. /** @hidden */
  91228. updateCache(force?: boolean): void;
  91229. /** @hidden */
  91230. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91231. /** @hidden */
  91232. _updateCache(ignoreParentClass?: boolean): void;
  91233. /** @hidden */
  91234. _isSynchronized(): boolean;
  91235. /** @hidden */
  91236. _markSyncedWithParent(): void;
  91237. /** @hidden */
  91238. isSynchronizedWithParent(): boolean;
  91239. /** @hidden */
  91240. isSynchronized(): boolean;
  91241. /**
  91242. * Is this node ready to be used/rendered
  91243. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91244. * @return true if the node is ready
  91245. */
  91246. isReady(completeCheck?: boolean): boolean;
  91247. /**
  91248. * Is this node enabled?
  91249. * 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
  91250. * @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
  91251. * @return whether this node (and its parent) is enabled
  91252. */
  91253. isEnabled(checkAncestors?: boolean): boolean;
  91254. /** @hidden */
  91255. protected _syncParentEnabledState(): void;
  91256. /**
  91257. * Set the enabled state of this node
  91258. * @param value defines the new enabled state
  91259. */
  91260. setEnabled(value: boolean): void;
  91261. /**
  91262. * Is this node a descendant of the given node?
  91263. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91264. * @param ancestor defines the parent node to inspect
  91265. * @returns a boolean indicating if this node is a descendant of the given node
  91266. */
  91267. isDescendantOf(ancestor: Node): boolean;
  91268. /** @hidden */
  91269. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91270. /**
  91271. * Will return all nodes that have this node as ascendant
  91272. * @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
  91273. * @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
  91274. * @return all children nodes of all types
  91275. */
  91276. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91277. /**
  91278. * Get all child-meshes of this node
  91279. * @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)
  91280. * @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
  91281. * @returns an array of AbstractMesh
  91282. */
  91283. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91284. /**
  91285. * Get all direct children of this node
  91286. * @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
  91287. * @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)
  91288. * @returns an array of Node
  91289. */
  91290. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91291. /** @hidden */
  91292. _setReady(state: boolean): void;
  91293. /**
  91294. * Get an animation by name
  91295. * @param name defines the name of the animation to look for
  91296. * @returns null if not found else the requested animation
  91297. */
  91298. getAnimationByName(name: string): Nullable<Animation>;
  91299. /**
  91300. * Creates an animation range for this node
  91301. * @param name defines the name of the range
  91302. * @param from defines the starting key
  91303. * @param to defines the end key
  91304. */
  91305. createAnimationRange(name: string, from: number, to: number): void;
  91306. /**
  91307. * Delete a specific animation range
  91308. * @param name defines the name of the range to delete
  91309. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91310. */
  91311. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91312. /**
  91313. * Get an animation range by name
  91314. * @param name defines the name of the animation range to look for
  91315. * @returns null if not found else the requested animation range
  91316. */
  91317. getAnimationRange(name: string): Nullable<AnimationRange>;
  91318. /**
  91319. * Gets the list of all animation ranges defined on this node
  91320. * @returns an array
  91321. */
  91322. getAnimationRanges(): Nullable<AnimationRange>[];
  91323. /**
  91324. * Will start the animation sequence
  91325. * @param name defines the range frames for animation sequence
  91326. * @param loop defines if the animation should loop (false by default)
  91327. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91328. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91329. * @returns the object created for this animation. If range does not exist, it will return null
  91330. */
  91331. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91332. /**
  91333. * Serialize animation ranges into a JSON compatible object
  91334. * @returns serialization object
  91335. */
  91336. serializeAnimationRanges(): any;
  91337. /**
  91338. * Computes the world matrix of the node
  91339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91340. * @returns the world matrix
  91341. */
  91342. computeWorldMatrix(force?: boolean): Matrix;
  91343. /**
  91344. * Releases resources associated with this node.
  91345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91347. */
  91348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91349. /**
  91350. * Parse animation range data from a serialization object and store them into a given node
  91351. * @param node defines where to store the animation ranges
  91352. * @param parsedNode defines the serialization object to read data from
  91353. * @param scene defines the hosting scene
  91354. */
  91355. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91356. /**
  91357. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91358. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91359. * @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
  91360. * @returns the new bounding vectors
  91361. */
  91362. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91363. min: Vector3;
  91364. max: Vector3;
  91365. };
  91366. }
  91367. }
  91368. declare module BABYLON {
  91369. /**
  91370. * @hidden
  91371. */
  91372. export class _IAnimationState {
  91373. key: number;
  91374. repeatCount: number;
  91375. workValue?: any;
  91376. loopMode?: number;
  91377. offsetValue?: any;
  91378. highLimitValue?: any;
  91379. }
  91380. /**
  91381. * Class used to store any kind of animation
  91382. */
  91383. export class Animation {
  91384. /**Name of the animation */
  91385. name: string;
  91386. /**Property to animate */
  91387. targetProperty: string;
  91388. /**The frames per second of the animation */
  91389. framePerSecond: number;
  91390. /**The data type of the animation */
  91391. dataType: number;
  91392. /**The loop mode of the animation */
  91393. loopMode?: number | undefined;
  91394. /**Specifies if blending should be enabled */
  91395. enableBlending?: boolean | undefined;
  91396. /**
  91397. * Use matrix interpolation instead of using direct key value when animating matrices
  91398. */
  91399. static AllowMatricesInterpolation: boolean;
  91400. /**
  91401. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91402. */
  91403. static AllowMatrixDecomposeForInterpolation: boolean;
  91404. /**
  91405. * Stores the key frames of the animation
  91406. */
  91407. private _keys;
  91408. /**
  91409. * Stores the easing function of the animation
  91410. */
  91411. private _easingFunction;
  91412. /**
  91413. * @hidden Internal use only
  91414. */
  91415. _runtimeAnimations: RuntimeAnimation[];
  91416. /**
  91417. * The set of event that will be linked to this animation
  91418. */
  91419. private _events;
  91420. /**
  91421. * Stores an array of target property paths
  91422. */
  91423. targetPropertyPath: string[];
  91424. /**
  91425. * Stores the blending speed of the animation
  91426. */
  91427. blendingSpeed: number;
  91428. /**
  91429. * Stores the animation ranges for the animation
  91430. */
  91431. private _ranges;
  91432. /**
  91433. * @hidden Internal use
  91434. */
  91435. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91436. /**
  91437. * Sets up an animation
  91438. * @param property The property to animate
  91439. * @param animationType The animation type to apply
  91440. * @param framePerSecond The frames per second of the animation
  91441. * @param easingFunction The easing function used in the animation
  91442. * @returns The created animation
  91443. */
  91444. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91445. /**
  91446. * Create and start an animation on a node
  91447. * @param name defines the name of the global animation that will be run on all nodes
  91448. * @param node defines the root node where the animation will take place
  91449. * @param targetProperty defines property to animate
  91450. * @param framePerSecond defines the number of frame per second yo use
  91451. * @param totalFrame defines the number of frames in total
  91452. * @param from defines the initial value
  91453. * @param to defines the final value
  91454. * @param loopMode defines which loop mode you want to use (off by default)
  91455. * @param easingFunction defines the easing function to use (linear by default)
  91456. * @param onAnimationEnd defines the callback to call when animation end
  91457. * @returns the animatable created for this animation
  91458. */
  91459. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91460. /**
  91461. * Create and start an animation on a node and its descendants
  91462. * @param name defines the name of the global animation that will be run on all nodes
  91463. * @param node defines the root node where the animation will take place
  91464. * @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
  91465. * @param targetProperty defines property to animate
  91466. * @param framePerSecond defines the number of frame per second to use
  91467. * @param totalFrame defines the number of frames in total
  91468. * @param from defines the initial value
  91469. * @param to defines the final value
  91470. * @param loopMode defines which loop mode you want to use (off by default)
  91471. * @param easingFunction defines the easing function to use (linear by default)
  91472. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91473. * @returns the list of animatables created for all nodes
  91474. * @example https://www.babylonjs-playground.com/#MH0VLI
  91475. */
  91476. 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[]>;
  91477. /**
  91478. * Creates a new animation, merges it with the existing animations and starts it
  91479. * @param name Name of the animation
  91480. * @param node Node which contains the scene that begins the animations
  91481. * @param targetProperty Specifies which property to animate
  91482. * @param framePerSecond The frames per second of the animation
  91483. * @param totalFrame The total number of frames
  91484. * @param from The frame at the beginning of the animation
  91485. * @param to The frame at the end of the animation
  91486. * @param loopMode Specifies the loop mode of the animation
  91487. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91488. * @param onAnimationEnd Callback to run once the animation is complete
  91489. * @returns Nullable animation
  91490. */
  91491. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91492. /**
  91493. * Transition property of an host to the target Value
  91494. * @param property The property to transition
  91495. * @param targetValue The target Value of the property
  91496. * @param host The object where the property to animate belongs
  91497. * @param scene Scene used to run the animation
  91498. * @param frameRate Framerate (in frame/s) to use
  91499. * @param transition The transition type we want to use
  91500. * @param duration The duration of the animation, in milliseconds
  91501. * @param onAnimationEnd Callback trigger at the end of the animation
  91502. * @returns Nullable animation
  91503. */
  91504. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91505. /**
  91506. * Return the array of runtime animations currently using this animation
  91507. */
  91508. readonly runtimeAnimations: RuntimeAnimation[];
  91509. /**
  91510. * Specifies if any of the runtime animations are currently running
  91511. */
  91512. readonly hasRunningRuntimeAnimations: boolean;
  91513. /**
  91514. * Initializes the animation
  91515. * @param name Name of the animation
  91516. * @param targetProperty Property to animate
  91517. * @param framePerSecond The frames per second of the animation
  91518. * @param dataType The data type of the animation
  91519. * @param loopMode The loop mode of the animation
  91520. * @param enableBlending Specifies if blending should be enabled
  91521. */
  91522. constructor(
  91523. /**Name of the animation */
  91524. name: string,
  91525. /**Property to animate */
  91526. targetProperty: string,
  91527. /**The frames per second of the animation */
  91528. framePerSecond: number,
  91529. /**The data type of the animation */
  91530. dataType: number,
  91531. /**The loop mode of the animation */
  91532. loopMode?: number | undefined,
  91533. /**Specifies if blending should be enabled */
  91534. enableBlending?: boolean | undefined);
  91535. /**
  91536. * Converts the animation to a string
  91537. * @param fullDetails support for multiple levels of logging within scene loading
  91538. * @returns String form of the animation
  91539. */
  91540. toString(fullDetails?: boolean): string;
  91541. /**
  91542. * Add an event to this animation
  91543. * @param event Event to add
  91544. */
  91545. addEvent(event: AnimationEvent): void;
  91546. /**
  91547. * Remove all events found at the given frame
  91548. * @param frame The frame to remove events from
  91549. */
  91550. removeEvents(frame: number): void;
  91551. /**
  91552. * Retrieves all the events from the animation
  91553. * @returns Events from the animation
  91554. */
  91555. getEvents(): AnimationEvent[];
  91556. /**
  91557. * Creates an animation range
  91558. * @param name Name of the animation range
  91559. * @param from Starting frame of the animation range
  91560. * @param to Ending frame of the animation
  91561. */
  91562. createRange(name: string, from: number, to: number): void;
  91563. /**
  91564. * Deletes an animation range by name
  91565. * @param name Name of the animation range to delete
  91566. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91567. */
  91568. deleteRange(name: string, deleteFrames?: boolean): void;
  91569. /**
  91570. * Gets the animation range by name, or null if not defined
  91571. * @param name Name of the animation range
  91572. * @returns Nullable animation range
  91573. */
  91574. getRange(name: string): Nullable<AnimationRange>;
  91575. /**
  91576. * Gets the key frames from the animation
  91577. * @returns The key frames of the animation
  91578. */
  91579. getKeys(): Array<IAnimationKey>;
  91580. /**
  91581. * Gets the highest frame rate of the animation
  91582. * @returns Highest frame rate of the animation
  91583. */
  91584. getHighestFrame(): number;
  91585. /**
  91586. * Gets the easing function of the animation
  91587. * @returns Easing function of the animation
  91588. */
  91589. getEasingFunction(): IEasingFunction;
  91590. /**
  91591. * Sets the easing function of the animation
  91592. * @param easingFunction A custom mathematical formula for animation
  91593. */
  91594. setEasingFunction(easingFunction: EasingFunction): void;
  91595. /**
  91596. * Interpolates a scalar linearly
  91597. * @param startValue Start value of the animation curve
  91598. * @param endValue End value of the animation curve
  91599. * @param gradient Scalar amount to interpolate
  91600. * @returns Interpolated scalar value
  91601. */
  91602. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91603. /**
  91604. * Interpolates a scalar cubically
  91605. * @param startValue Start value of the animation curve
  91606. * @param outTangent End tangent of the animation
  91607. * @param endValue End value of the animation curve
  91608. * @param inTangent Start tangent of the animation curve
  91609. * @param gradient Scalar amount to interpolate
  91610. * @returns Interpolated scalar value
  91611. */
  91612. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91613. /**
  91614. * Interpolates a quaternion using a spherical linear interpolation
  91615. * @param startValue Start value of the animation curve
  91616. * @param endValue End value of the animation curve
  91617. * @param gradient Scalar amount to interpolate
  91618. * @returns Interpolated quaternion value
  91619. */
  91620. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91621. /**
  91622. * Interpolates a quaternion cubically
  91623. * @param startValue Start value of the animation curve
  91624. * @param outTangent End tangent of the animation curve
  91625. * @param endValue End value of the animation curve
  91626. * @param inTangent Start tangent of the animation curve
  91627. * @param gradient Scalar amount to interpolate
  91628. * @returns Interpolated quaternion value
  91629. */
  91630. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91631. /**
  91632. * Interpolates a Vector3 linearl
  91633. * @param startValue Start value of the animation curve
  91634. * @param endValue End value of the animation curve
  91635. * @param gradient Scalar amount to interpolate
  91636. * @returns Interpolated scalar value
  91637. */
  91638. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91639. /**
  91640. * Interpolates a Vector3 cubically
  91641. * @param startValue Start value of the animation curve
  91642. * @param outTangent End tangent of the animation
  91643. * @param endValue End value of the animation curve
  91644. * @param inTangent Start tangent of the animation curve
  91645. * @param gradient Scalar amount to interpolate
  91646. * @returns InterpolatedVector3 value
  91647. */
  91648. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91649. /**
  91650. * Interpolates a Vector2 linearly
  91651. * @param startValue Start value of the animation curve
  91652. * @param endValue End value of the animation curve
  91653. * @param gradient Scalar amount to interpolate
  91654. * @returns Interpolated Vector2 value
  91655. */
  91656. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91657. /**
  91658. * Interpolates a Vector2 cubically
  91659. * @param startValue Start value of the animation curve
  91660. * @param outTangent End tangent of the animation
  91661. * @param endValue End value of the animation curve
  91662. * @param inTangent Start tangent of the animation curve
  91663. * @param gradient Scalar amount to interpolate
  91664. * @returns Interpolated Vector2 value
  91665. */
  91666. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91667. /**
  91668. * Interpolates a size linearly
  91669. * @param startValue Start value of the animation curve
  91670. * @param endValue End value of the animation curve
  91671. * @param gradient Scalar amount to interpolate
  91672. * @returns Interpolated Size value
  91673. */
  91674. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91675. /**
  91676. * Interpolates a Color3 linearly
  91677. * @param startValue Start value of the animation curve
  91678. * @param endValue End value of the animation curve
  91679. * @param gradient Scalar amount to interpolate
  91680. * @returns Interpolated Color3 value
  91681. */
  91682. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91683. /**
  91684. * @hidden Internal use only
  91685. */
  91686. _getKeyValue(value: any): any;
  91687. /**
  91688. * @hidden Internal use only
  91689. */
  91690. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91691. /**
  91692. * Defines the function to use to interpolate matrices
  91693. * @param startValue defines the start matrix
  91694. * @param endValue defines the end matrix
  91695. * @param gradient defines the gradient between both matrices
  91696. * @param result defines an optional target matrix where to store the interpolation
  91697. * @returns the interpolated matrix
  91698. */
  91699. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91700. /**
  91701. * Makes a copy of the animation
  91702. * @returns Cloned animation
  91703. */
  91704. clone(): Animation;
  91705. /**
  91706. * Sets the key frames of the animation
  91707. * @param values The animation key frames to set
  91708. */
  91709. setKeys(values: Array<IAnimationKey>): void;
  91710. /**
  91711. * Serializes the animation to an object
  91712. * @returns Serialized object
  91713. */
  91714. serialize(): any;
  91715. /**
  91716. * Float animation type
  91717. */
  91718. private static _ANIMATIONTYPE_FLOAT;
  91719. /**
  91720. * Vector3 animation type
  91721. */
  91722. private static _ANIMATIONTYPE_VECTOR3;
  91723. /**
  91724. * Quaternion animation type
  91725. */
  91726. private static _ANIMATIONTYPE_QUATERNION;
  91727. /**
  91728. * Matrix animation type
  91729. */
  91730. private static _ANIMATIONTYPE_MATRIX;
  91731. /**
  91732. * Color3 animation type
  91733. */
  91734. private static _ANIMATIONTYPE_COLOR3;
  91735. /**
  91736. * Vector2 animation type
  91737. */
  91738. private static _ANIMATIONTYPE_VECTOR2;
  91739. /**
  91740. * Size animation type
  91741. */
  91742. private static _ANIMATIONTYPE_SIZE;
  91743. /**
  91744. * Relative Loop Mode
  91745. */
  91746. private static _ANIMATIONLOOPMODE_RELATIVE;
  91747. /**
  91748. * Cycle Loop Mode
  91749. */
  91750. private static _ANIMATIONLOOPMODE_CYCLE;
  91751. /**
  91752. * Constant Loop Mode
  91753. */
  91754. private static _ANIMATIONLOOPMODE_CONSTANT;
  91755. /**
  91756. * Get the float animation type
  91757. */
  91758. static readonly ANIMATIONTYPE_FLOAT: number;
  91759. /**
  91760. * Get the Vector3 animation type
  91761. */
  91762. static readonly ANIMATIONTYPE_VECTOR3: number;
  91763. /**
  91764. * Get the Vector2 animation type
  91765. */
  91766. static readonly ANIMATIONTYPE_VECTOR2: number;
  91767. /**
  91768. * Get the Size animation type
  91769. */
  91770. static readonly ANIMATIONTYPE_SIZE: number;
  91771. /**
  91772. * Get the Quaternion animation type
  91773. */
  91774. static readonly ANIMATIONTYPE_QUATERNION: number;
  91775. /**
  91776. * Get the Matrix animation type
  91777. */
  91778. static readonly ANIMATIONTYPE_MATRIX: number;
  91779. /**
  91780. * Get the Color3 animation type
  91781. */
  91782. static readonly ANIMATIONTYPE_COLOR3: number;
  91783. /**
  91784. * Get the Relative Loop Mode
  91785. */
  91786. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91787. /**
  91788. * Get the Cycle Loop Mode
  91789. */
  91790. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91791. /**
  91792. * Get the Constant Loop Mode
  91793. */
  91794. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91795. /** @hidden */
  91796. static _UniversalLerp(left: any, right: any, amount: number): any;
  91797. /**
  91798. * Parses an animation object and creates an animation
  91799. * @param parsedAnimation Parsed animation object
  91800. * @returns Animation object
  91801. */
  91802. static Parse(parsedAnimation: any): Animation;
  91803. /**
  91804. * Appends the serialized animations from the source animations
  91805. * @param source Source containing the animations
  91806. * @param destination Target to store the animations
  91807. */
  91808. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91809. }
  91810. }
  91811. declare module BABYLON {
  91812. /**
  91813. * Interface containing an array of animations
  91814. */
  91815. export interface IAnimatable {
  91816. /**
  91817. * Array of animations
  91818. */
  91819. animations: Nullable<Array<Animation>>;
  91820. }
  91821. }
  91822. declare module BABYLON {
  91823. /**
  91824. * This represents all the required information to add a fresnel effect on a material:
  91825. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91826. */
  91827. export class FresnelParameters {
  91828. private _isEnabled;
  91829. /**
  91830. * Define if the fresnel effect is enable or not.
  91831. */
  91832. isEnabled: boolean;
  91833. /**
  91834. * Define the color used on edges (grazing angle)
  91835. */
  91836. leftColor: Color3;
  91837. /**
  91838. * Define the color used on center
  91839. */
  91840. rightColor: Color3;
  91841. /**
  91842. * Define bias applied to computed fresnel term
  91843. */
  91844. bias: number;
  91845. /**
  91846. * Defined the power exponent applied to fresnel term
  91847. */
  91848. power: number;
  91849. /**
  91850. * Clones the current fresnel and its valuues
  91851. * @returns a clone fresnel configuration
  91852. */
  91853. clone(): FresnelParameters;
  91854. /**
  91855. * Serializes the current fresnel parameters to a JSON representation.
  91856. * @return the JSON serialization
  91857. */
  91858. serialize(): any;
  91859. /**
  91860. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91861. * @param parsedFresnelParameters Define the JSON representation
  91862. * @returns the parsed parameters
  91863. */
  91864. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91865. }
  91866. }
  91867. declare module BABYLON {
  91868. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91869. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91870. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91871. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91872. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91873. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91874. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91875. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91876. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91877. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91878. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91879. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91880. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91881. /**
  91882. * Decorator used to define property that can be serialized as reference to a camera
  91883. * @param sourceName defines the name of the property to decorate
  91884. */
  91885. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91886. /**
  91887. * Class used to help serialization objects
  91888. */
  91889. export class SerializationHelper {
  91890. /** @hidden */
  91891. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91892. /** @hidden */
  91893. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91894. /** @hidden */
  91895. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91896. /** @hidden */
  91897. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91898. /**
  91899. * Appends the serialized animations from the source animations
  91900. * @param source Source containing the animations
  91901. * @param destination Target to store the animations
  91902. */
  91903. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91904. /**
  91905. * Static function used to serialized a specific entity
  91906. * @param entity defines the entity to serialize
  91907. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91908. * @returns a JSON compatible object representing the serialization of the entity
  91909. */
  91910. static Serialize<T>(entity: T, serializationObject?: any): any;
  91911. /**
  91912. * Creates a new entity from a serialization data object
  91913. * @param creationFunction defines a function used to instanciated the new entity
  91914. * @param source defines the source serialization data
  91915. * @param scene defines the hosting scene
  91916. * @param rootUrl defines the root url for resources
  91917. * @returns a new entity
  91918. */
  91919. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91920. /**
  91921. * Clones an object
  91922. * @param creationFunction defines the function used to instanciate the new object
  91923. * @param source defines the source object
  91924. * @returns the cloned object
  91925. */
  91926. static Clone<T>(creationFunction: () => T, source: T): T;
  91927. /**
  91928. * Instanciates a new object based on a source one (some data will be shared between both object)
  91929. * @param creationFunction defines the function used to instanciate the new object
  91930. * @param source defines the source object
  91931. * @returns the new object
  91932. */
  91933. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91934. }
  91935. }
  91936. declare module BABYLON {
  91937. /**
  91938. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91939. */
  91940. export interface CubeMapInfo {
  91941. /**
  91942. * The pixel array for the front face.
  91943. * This is stored in format, left to right, up to down format.
  91944. */
  91945. front: Nullable<ArrayBufferView>;
  91946. /**
  91947. * The pixel array for the back face.
  91948. * This is stored in format, left to right, up to down format.
  91949. */
  91950. back: Nullable<ArrayBufferView>;
  91951. /**
  91952. * The pixel array for the left face.
  91953. * This is stored in format, left to right, up to down format.
  91954. */
  91955. left: Nullable<ArrayBufferView>;
  91956. /**
  91957. * The pixel array for the right face.
  91958. * This is stored in format, left to right, up to down format.
  91959. */
  91960. right: Nullable<ArrayBufferView>;
  91961. /**
  91962. * The pixel array for the up face.
  91963. * This is stored in format, left to right, up to down format.
  91964. */
  91965. up: Nullable<ArrayBufferView>;
  91966. /**
  91967. * The pixel array for the down face.
  91968. * This is stored in format, left to right, up to down format.
  91969. */
  91970. down: Nullable<ArrayBufferView>;
  91971. /**
  91972. * The size of the cubemap stored.
  91973. *
  91974. * Each faces will be size * size pixels.
  91975. */
  91976. size: number;
  91977. /**
  91978. * The format of the texture.
  91979. *
  91980. * RGBA, RGB.
  91981. */
  91982. format: number;
  91983. /**
  91984. * The type of the texture data.
  91985. *
  91986. * UNSIGNED_INT, FLOAT.
  91987. */
  91988. type: number;
  91989. /**
  91990. * Specifies whether the texture is in gamma space.
  91991. */
  91992. gammaSpace: boolean;
  91993. }
  91994. /**
  91995. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91996. */
  91997. export class PanoramaToCubeMapTools {
  91998. private static FACE_FRONT;
  91999. private static FACE_BACK;
  92000. private static FACE_RIGHT;
  92001. private static FACE_LEFT;
  92002. private static FACE_DOWN;
  92003. private static FACE_UP;
  92004. /**
  92005. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92006. *
  92007. * @param float32Array The source data.
  92008. * @param inputWidth The width of the input panorama.
  92009. * @param inputHeight The height of the input panorama.
  92010. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92011. * @return The cubemap data
  92012. */
  92013. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92014. private static CreateCubemapTexture;
  92015. private static CalcProjectionSpherical;
  92016. }
  92017. }
  92018. declare module BABYLON {
  92019. /**
  92020. * Helper class dealing with the extraction of spherical polynomial dataArray
  92021. * from a cube map.
  92022. */
  92023. export class CubeMapToSphericalPolynomialTools {
  92024. private static FileFaces;
  92025. /**
  92026. * Converts a texture to the according Spherical Polynomial data.
  92027. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92028. *
  92029. * @param texture The texture to extract the information from.
  92030. * @return The Spherical Polynomial data.
  92031. */
  92032. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92033. /**
  92034. * Converts a cubemap to the according Spherical Polynomial data.
  92035. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92036. *
  92037. * @param cubeInfo The Cube map to extract the information from.
  92038. * @return The Spherical Polynomial data.
  92039. */
  92040. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92041. }
  92042. }
  92043. declare module BABYLON {
  92044. /**
  92045. * Class used to manipulate GUIDs
  92046. */
  92047. export class GUID {
  92048. /**
  92049. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92050. * Be aware Math.random() could cause collisions, but:
  92051. * "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"
  92052. * @returns a pseudo random id
  92053. */
  92054. static RandomId(): string;
  92055. }
  92056. }
  92057. declare module BABYLON {
  92058. /**
  92059. * Base class of all the textures in babylon.
  92060. * It groups all the common properties the materials, post process, lights... might need
  92061. * in order to make a correct use of the texture.
  92062. */
  92063. export class BaseTexture implements IAnimatable {
  92064. /**
  92065. * Default anisotropic filtering level for the application.
  92066. * It is set to 4 as a good tradeoff between perf and quality.
  92067. */
  92068. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92069. /**
  92070. * Gets or sets the unique id of the texture
  92071. */
  92072. uniqueId: number;
  92073. /**
  92074. * Define the name of the texture.
  92075. */
  92076. name: string;
  92077. /**
  92078. * Gets or sets an object used to store user defined information.
  92079. */
  92080. metadata: any;
  92081. /**
  92082. * For internal use only. Please do not use.
  92083. */
  92084. reservedDataStore: any;
  92085. private _hasAlpha;
  92086. /**
  92087. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92088. */
  92089. hasAlpha: boolean;
  92090. /**
  92091. * Defines if the alpha value should be determined via the rgb values.
  92092. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92093. */
  92094. getAlphaFromRGB: boolean;
  92095. /**
  92096. * Intensity or strength of the texture.
  92097. * It is commonly used by materials to fine tune the intensity of the texture
  92098. */
  92099. level: number;
  92100. /**
  92101. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92102. * This is part of the texture as textures usually maps to one uv set.
  92103. */
  92104. coordinatesIndex: number;
  92105. private _coordinatesMode;
  92106. /**
  92107. * How a texture is mapped.
  92108. *
  92109. * | Value | Type | Description |
  92110. * | ----- | ----------------------------------- | ----------- |
  92111. * | 0 | EXPLICIT_MODE | |
  92112. * | 1 | SPHERICAL_MODE | |
  92113. * | 2 | PLANAR_MODE | |
  92114. * | 3 | CUBIC_MODE | |
  92115. * | 4 | PROJECTION_MODE | |
  92116. * | 5 | SKYBOX_MODE | |
  92117. * | 6 | INVCUBIC_MODE | |
  92118. * | 7 | EQUIRECTANGULAR_MODE | |
  92119. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92120. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92121. */
  92122. coordinatesMode: number;
  92123. /**
  92124. * | Value | Type | Description |
  92125. * | ----- | ------------------ | ----------- |
  92126. * | 0 | CLAMP_ADDRESSMODE | |
  92127. * | 1 | WRAP_ADDRESSMODE | |
  92128. * | 2 | MIRROR_ADDRESSMODE | |
  92129. */
  92130. wrapU: number;
  92131. /**
  92132. * | Value | Type | Description |
  92133. * | ----- | ------------------ | ----------- |
  92134. * | 0 | CLAMP_ADDRESSMODE | |
  92135. * | 1 | WRAP_ADDRESSMODE | |
  92136. * | 2 | MIRROR_ADDRESSMODE | |
  92137. */
  92138. wrapV: number;
  92139. /**
  92140. * | Value | Type | Description |
  92141. * | ----- | ------------------ | ----------- |
  92142. * | 0 | CLAMP_ADDRESSMODE | |
  92143. * | 1 | WRAP_ADDRESSMODE | |
  92144. * | 2 | MIRROR_ADDRESSMODE | |
  92145. */
  92146. wrapR: number;
  92147. /**
  92148. * With compliant hardware and browser (supporting anisotropic filtering)
  92149. * this defines the level of anisotropic filtering in the texture.
  92150. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92151. */
  92152. anisotropicFilteringLevel: number;
  92153. /**
  92154. * Define if the texture is a cube texture or if false a 2d texture.
  92155. */
  92156. isCube: boolean;
  92157. /**
  92158. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92159. */
  92160. is3D: boolean;
  92161. /**
  92162. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92163. * HDR texture are usually stored in linear space.
  92164. * This only impacts the PBR and Background materials
  92165. */
  92166. gammaSpace: boolean;
  92167. /**
  92168. * Gets whether or not the texture contains RGBD data.
  92169. */
  92170. readonly isRGBD: boolean;
  92171. /**
  92172. * Is Z inverted in the texture (useful in a cube texture).
  92173. */
  92174. invertZ: boolean;
  92175. /**
  92176. * Are mip maps generated for this texture or not.
  92177. */
  92178. readonly noMipmap: boolean;
  92179. /**
  92180. * @hidden
  92181. */
  92182. lodLevelInAlpha: boolean;
  92183. /**
  92184. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92185. */
  92186. lodGenerationOffset: number;
  92187. /**
  92188. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92189. */
  92190. lodGenerationScale: number;
  92191. /**
  92192. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92193. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92194. * average roughness values.
  92195. */
  92196. linearSpecularLOD: boolean;
  92197. /**
  92198. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92199. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92200. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92201. */
  92202. irradianceTexture: Nullable<BaseTexture>;
  92203. /**
  92204. * Define if the texture is a render target.
  92205. */
  92206. isRenderTarget: boolean;
  92207. /**
  92208. * Define the unique id of the texture in the scene.
  92209. */
  92210. readonly uid: string;
  92211. /**
  92212. * Return a string representation of the texture.
  92213. * @returns the texture as a string
  92214. */
  92215. toString(): string;
  92216. /**
  92217. * Get the class name of the texture.
  92218. * @returns "BaseTexture"
  92219. */
  92220. getClassName(): string;
  92221. /**
  92222. * Define the list of animation attached to the texture.
  92223. */
  92224. animations: Animation[];
  92225. /**
  92226. * An event triggered when the texture is disposed.
  92227. */
  92228. onDisposeObservable: Observable<BaseTexture>;
  92229. private _onDisposeObserver;
  92230. /**
  92231. * Callback triggered when the texture has been disposed.
  92232. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92233. */
  92234. onDispose: () => void;
  92235. /**
  92236. * Define the current state of the loading sequence when in delayed load mode.
  92237. */
  92238. delayLoadState: number;
  92239. private _scene;
  92240. /** @hidden */
  92241. _texture: Nullable<InternalTexture>;
  92242. private _uid;
  92243. /**
  92244. * Define if the texture is preventinga material to render or not.
  92245. * If not and the texture is not ready, the engine will use a default black texture instead.
  92246. */
  92247. readonly isBlocking: boolean;
  92248. /**
  92249. * Instantiates a new BaseTexture.
  92250. * Base class of all the textures in babylon.
  92251. * It groups all the common properties the materials, post process, lights... might need
  92252. * in order to make a correct use of the texture.
  92253. * @param scene Define the scene the texture blongs to
  92254. */
  92255. constructor(scene: Nullable<Scene>);
  92256. /**
  92257. * Get the scene the texture belongs to.
  92258. * @returns the scene or null if undefined
  92259. */
  92260. getScene(): Nullable<Scene>;
  92261. /**
  92262. * Get the texture transform matrix used to offset tile the texture for istance.
  92263. * @returns the transformation matrix
  92264. */
  92265. getTextureMatrix(): Matrix;
  92266. /**
  92267. * Get the texture reflection matrix used to rotate/transform the reflection.
  92268. * @returns the reflection matrix
  92269. */
  92270. getReflectionTextureMatrix(): Matrix;
  92271. /**
  92272. * Get the underlying lower level texture from Babylon.
  92273. * @returns the insternal texture
  92274. */
  92275. getInternalTexture(): Nullable<InternalTexture>;
  92276. /**
  92277. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92278. * @returns true if ready or not blocking
  92279. */
  92280. isReadyOrNotBlocking(): boolean;
  92281. /**
  92282. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92283. * @returns true if fully ready
  92284. */
  92285. isReady(): boolean;
  92286. private _cachedSize;
  92287. /**
  92288. * Get the size of the texture.
  92289. * @returns the texture size.
  92290. */
  92291. getSize(): ISize;
  92292. /**
  92293. * Get the base size of the texture.
  92294. * It can be different from the size if the texture has been resized for POT for instance
  92295. * @returns the base size
  92296. */
  92297. getBaseSize(): ISize;
  92298. /**
  92299. * Update the sampling mode of the texture.
  92300. * Default is Trilinear mode.
  92301. *
  92302. * | Value | Type | Description |
  92303. * | ----- | ------------------ | ----------- |
  92304. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92305. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92306. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92307. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92308. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92309. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92310. * | 7 | NEAREST_LINEAR | |
  92311. * | 8 | NEAREST_NEAREST | |
  92312. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92313. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92314. * | 11 | LINEAR_LINEAR | |
  92315. * | 12 | LINEAR_NEAREST | |
  92316. *
  92317. * > _mag_: magnification filter (close to the viewer)
  92318. * > _min_: minification filter (far from the viewer)
  92319. * > _mip_: filter used between mip map levels
  92320. *@param samplingMode Define the new sampling mode of the texture
  92321. */
  92322. updateSamplingMode(samplingMode: number): void;
  92323. /**
  92324. * Scales the texture if is `canRescale()`
  92325. * @param ratio the resize factor we want to use to rescale
  92326. */
  92327. scale(ratio: number): void;
  92328. /**
  92329. * Get if the texture can rescale.
  92330. */
  92331. readonly canRescale: boolean;
  92332. /** @hidden */
  92333. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92334. /** @hidden */
  92335. _rebuild(): void;
  92336. /**
  92337. * Triggers the load sequence in delayed load mode.
  92338. */
  92339. delayLoad(): void;
  92340. /**
  92341. * Clones the texture.
  92342. * @returns the cloned texture
  92343. */
  92344. clone(): Nullable<BaseTexture>;
  92345. /**
  92346. * Get the texture underlying type (INT, FLOAT...)
  92347. */
  92348. readonly textureType: number;
  92349. /**
  92350. * Get the texture underlying format (RGB, RGBA...)
  92351. */
  92352. readonly textureFormat: number;
  92353. /**
  92354. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92355. * This will returns an RGBA array buffer containing either in values (0-255) or
  92356. * float values (0-1) depending of the underlying buffer type.
  92357. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92358. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92359. * @param buffer defines a user defined buffer to fill with data (can be null)
  92360. * @returns The Array buffer containing the pixels data.
  92361. */
  92362. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92363. /**
  92364. * Release and destroy the underlying lower level texture aka internalTexture.
  92365. */
  92366. releaseInternalTexture(): void;
  92367. /**
  92368. * Get the polynomial representation of the texture data.
  92369. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92370. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92371. */
  92372. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92373. /** @hidden */
  92374. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92375. /** @hidden */
  92376. readonly _lodTextureMid: Nullable<BaseTexture>;
  92377. /** @hidden */
  92378. readonly _lodTextureLow: Nullable<BaseTexture>;
  92379. /**
  92380. * Dispose the texture and release its associated resources.
  92381. */
  92382. dispose(): void;
  92383. /**
  92384. * Serialize the texture into a JSON representation that can be parsed later on.
  92385. * @returns the JSON representation of the texture
  92386. */
  92387. serialize(): any;
  92388. /**
  92389. * Helper function to be called back once a list of texture contains only ready textures.
  92390. * @param textures Define the list of textures to wait for
  92391. * @param callback Define the callback triggered once the entire list will be ready
  92392. */
  92393. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92394. }
  92395. }
  92396. declare module BABYLON {
  92397. /**
  92398. * Class used to store data associated with WebGL texture data for the engine
  92399. * This class should not be used directly
  92400. */
  92401. export class InternalTexture {
  92402. /** @hidden */
  92403. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92404. /**
  92405. * The source of the texture data is unknown
  92406. */
  92407. static DATASOURCE_UNKNOWN: number;
  92408. /**
  92409. * Texture data comes from an URL
  92410. */
  92411. static DATASOURCE_URL: number;
  92412. /**
  92413. * Texture data is only used for temporary storage
  92414. */
  92415. static DATASOURCE_TEMP: number;
  92416. /**
  92417. * Texture data comes from raw data (ArrayBuffer)
  92418. */
  92419. static DATASOURCE_RAW: number;
  92420. /**
  92421. * Texture content is dynamic (video or dynamic texture)
  92422. */
  92423. static DATASOURCE_DYNAMIC: number;
  92424. /**
  92425. * Texture content is generated by rendering to it
  92426. */
  92427. static DATASOURCE_RENDERTARGET: number;
  92428. /**
  92429. * Texture content is part of a multi render target process
  92430. */
  92431. static DATASOURCE_MULTIRENDERTARGET: number;
  92432. /**
  92433. * Texture data comes from a cube data file
  92434. */
  92435. static DATASOURCE_CUBE: number;
  92436. /**
  92437. * Texture data comes from a raw cube data
  92438. */
  92439. static DATASOURCE_CUBERAW: number;
  92440. /**
  92441. * Texture data come from a prefiltered cube data file
  92442. */
  92443. static DATASOURCE_CUBEPREFILTERED: number;
  92444. /**
  92445. * Texture content is raw 3D data
  92446. */
  92447. static DATASOURCE_RAW3D: number;
  92448. /**
  92449. * Texture content is a depth texture
  92450. */
  92451. static DATASOURCE_DEPTHTEXTURE: number;
  92452. /**
  92453. * Texture data comes from a raw cube data encoded with RGBD
  92454. */
  92455. static DATASOURCE_CUBERAW_RGBD: number;
  92456. /**
  92457. * Defines if the texture is ready
  92458. */
  92459. isReady: boolean;
  92460. /**
  92461. * Defines if the texture is a cube texture
  92462. */
  92463. isCube: boolean;
  92464. /**
  92465. * Defines if the texture contains 3D data
  92466. */
  92467. is3D: boolean;
  92468. /**
  92469. * Defines if the texture contains multiview data
  92470. */
  92471. isMultiview: boolean;
  92472. /**
  92473. * Gets the URL used to load this texture
  92474. */
  92475. url: string;
  92476. /**
  92477. * Gets the sampling mode of the texture
  92478. */
  92479. samplingMode: number;
  92480. /**
  92481. * Gets a boolean indicating if the texture needs mipmaps generation
  92482. */
  92483. generateMipMaps: boolean;
  92484. /**
  92485. * Gets the number of samples used by the texture (WebGL2+ only)
  92486. */
  92487. samples: number;
  92488. /**
  92489. * Gets the type of the texture (int, float...)
  92490. */
  92491. type: number;
  92492. /**
  92493. * Gets the format of the texture (RGB, RGBA...)
  92494. */
  92495. format: number;
  92496. /**
  92497. * Observable called when the texture is loaded
  92498. */
  92499. onLoadedObservable: Observable<InternalTexture>;
  92500. /**
  92501. * Gets the width of the texture
  92502. */
  92503. width: number;
  92504. /**
  92505. * Gets the height of the texture
  92506. */
  92507. height: number;
  92508. /**
  92509. * Gets the depth of the texture
  92510. */
  92511. depth: number;
  92512. /**
  92513. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92514. */
  92515. baseWidth: number;
  92516. /**
  92517. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92518. */
  92519. baseHeight: number;
  92520. /**
  92521. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92522. */
  92523. baseDepth: number;
  92524. /**
  92525. * Gets a boolean indicating if the texture is inverted on Y axis
  92526. */
  92527. invertY: boolean;
  92528. /** @hidden */
  92529. _invertVScale: boolean;
  92530. /** @hidden */
  92531. _associatedChannel: number;
  92532. /** @hidden */
  92533. _dataSource: number;
  92534. /** @hidden */
  92535. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92536. /** @hidden */
  92537. _bufferView: Nullable<ArrayBufferView>;
  92538. /** @hidden */
  92539. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92540. /** @hidden */
  92541. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92542. /** @hidden */
  92543. _size: number;
  92544. /** @hidden */
  92545. _extension: string;
  92546. /** @hidden */
  92547. _files: Nullable<string[]>;
  92548. /** @hidden */
  92549. _workingCanvas: Nullable<HTMLCanvasElement>;
  92550. /** @hidden */
  92551. _workingContext: Nullable<CanvasRenderingContext2D>;
  92552. /** @hidden */
  92553. _framebuffer: Nullable<WebGLFramebuffer>;
  92554. /** @hidden */
  92555. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92556. /** @hidden */
  92557. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92558. /** @hidden */
  92559. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92560. /** @hidden */
  92561. _attachments: Nullable<number[]>;
  92562. /** @hidden */
  92563. _cachedCoordinatesMode: Nullable<number>;
  92564. /** @hidden */
  92565. _cachedWrapU: Nullable<number>;
  92566. /** @hidden */
  92567. _cachedWrapV: Nullable<number>;
  92568. /** @hidden */
  92569. _cachedWrapR: Nullable<number>;
  92570. /** @hidden */
  92571. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92572. /** @hidden */
  92573. _isDisabled: boolean;
  92574. /** @hidden */
  92575. _compression: Nullable<string>;
  92576. /** @hidden */
  92577. _generateStencilBuffer: boolean;
  92578. /** @hidden */
  92579. _generateDepthBuffer: boolean;
  92580. /** @hidden */
  92581. _comparisonFunction: number;
  92582. /** @hidden */
  92583. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92584. /** @hidden */
  92585. _lodGenerationScale: number;
  92586. /** @hidden */
  92587. _lodGenerationOffset: number;
  92588. /** @hidden */
  92589. _colorTextureArray: Nullable<WebGLTexture>;
  92590. /** @hidden */
  92591. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92592. /** @hidden */
  92593. _lodTextureHigh: Nullable<BaseTexture>;
  92594. /** @hidden */
  92595. _lodTextureMid: Nullable<BaseTexture>;
  92596. /** @hidden */
  92597. _lodTextureLow: Nullable<BaseTexture>;
  92598. /** @hidden */
  92599. _isRGBD: boolean;
  92600. /** @hidden */
  92601. _linearSpecularLOD: boolean;
  92602. /** @hidden */
  92603. _irradianceTexture: Nullable<BaseTexture>;
  92604. /** @hidden */
  92605. _webGLTexture: Nullable<WebGLTexture>;
  92606. /** @hidden */
  92607. _references: number;
  92608. private _engine;
  92609. /**
  92610. * Gets the Engine the texture belongs to.
  92611. * @returns The babylon engine
  92612. */
  92613. getEngine(): Engine;
  92614. /**
  92615. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92616. */
  92617. readonly dataSource: number;
  92618. /**
  92619. * Creates a new InternalTexture
  92620. * @param engine defines the engine to use
  92621. * @param dataSource defines the type of data that will be used
  92622. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92623. */
  92624. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92625. /**
  92626. * Increments the number of references (ie. the number of Texture that point to it)
  92627. */
  92628. incrementReferences(): void;
  92629. /**
  92630. * Change the size of the texture (not the size of the content)
  92631. * @param width defines the new width
  92632. * @param height defines the new height
  92633. * @param depth defines the new depth (1 by default)
  92634. */
  92635. updateSize(width: int, height: int, depth?: int): void;
  92636. /** @hidden */
  92637. _rebuild(): void;
  92638. /** @hidden */
  92639. _swapAndDie(target: InternalTexture): void;
  92640. /**
  92641. * Dispose the current allocated resources
  92642. */
  92643. dispose(): void;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92649. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92650. */
  92651. export class EffectFallbacks {
  92652. private _defines;
  92653. private _currentRank;
  92654. private _maxRank;
  92655. private _mesh;
  92656. /**
  92657. * Removes the fallback from the bound mesh.
  92658. */
  92659. unBindMesh(): void;
  92660. /**
  92661. * Adds a fallback on the specified property.
  92662. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92663. * @param define The name of the define in the shader
  92664. */
  92665. addFallback(rank: number, define: string): void;
  92666. /**
  92667. * Sets the mesh to use CPU skinning when needing to fallback.
  92668. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92669. * @param mesh The mesh to use the fallbacks.
  92670. */
  92671. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92672. /**
  92673. * Checks to see if more fallbacks are still availible.
  92674. */
  92675. readonly isMoreFallbacks: boolean;
  92676. /**
  92677. * Removes the defines that should be removed when falling back.
  92678. * @param currentDefines defines the current define statements for the shader.
  92679. * @param effect defines the current effect we try to compile
  92680. * @returns The resulting defines with defines of the current rank removed.
  92681. */
  92682. reduce(currentDefines: string, effect: Effect): string;
  92683. }
  92684. /**
  92685. * Options to be used when creating an effect.
  92686. */
  92687. export class EffectCreationOptions {
  92688. /**
  92689. * Atrributes that will be used in the shader.
  92690. */
  92691. attributes: string[];
  92692. /**
  92693. * Uniform varible names that will be set in the shader.
  92694. */
  92695. uniformsNames: string[];
  92696. /**
  92697. * Uniform buffer varible names that will be set in the shader.
  92698. */
  92699. uniformBuffersNames: string[];
  92700. /**
  92701. * Sampler texture variable names that will be set in the shader.
  92702. */
  92703. samplers: string[];
  92704. /**
  92705. * Define statements that will be set in the shader.
  92706. */
  92707. defines: any;
  92708. /**
  92709. * Possible fallbacks for this effect to improve performance when needed.
  92710. */
  92711. fallbacks: Nullable<EffectFallbacks>;
  92712. /**
  92713. * Callback that will be called when the shader is compiled.
  92714. */
  92715. onCompiled: Nullable<(effect: Effect) => void>;
  92716. /**
  92717. * Callback that will be called if an error occurs during shader compilation.
  92718. */
  92719. onError: Nullable<(effect: Effect, errors: string) => void>;
  92720. /**
  92721. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92722. */
  92723. indexParameters: any;
  92724. /**
  92725. * Max number of lights that can be used in the shader.
  92726. */
  92727. maxSimultaneousLights: number;
  92728. /**
  92729. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92730. */
  92731. transformFeedbackVaryings: Nullable<string[]>;
  92732. }
  92733. /**
  92734. * Effect containing vertex and fragment shader that can be executed on an object.
  92735. */
  92736. export class Effect implements IDisposable {
  92737. /**
  92738. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92739. */
  92740. static ShadersRepository: string;
  92741. /**
  92742. * Name of the effect.
  92743. */
  92744. name: any;
  92745. /**
  92746. * String container all the define statements that should be set on the shader.
  92747. */
  92748. defines: string;
  92749. /**
  92750. * Callback that will be called when the shader is compiled.
  92751. */
  92752. onCompiled: Nullable<(effect: Effect) => void>;
  92753. /**
  92754. * Callback that will be called if an error occurs during shader compilation.
  92755. */
  92756. onError: Nullable<(effect: Effect, errors: string) => void>;
  92757. /**
  92758. * Callback that will be called when effect is bound.
  92759. */
  92760. onBind: Nullable<(effect: Effect) => void>;
  92761. /**
  92762. * Unique ID of the effect.
  92763. */
  92764. uniqueId: number;
  92765. /**
  92766. * Observable that will be called when the shader is compiled.
  92767. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92768. */
  92769. onCompileObservable: Observable<Effect>;
  92770. /**
  92771. * Observable that will be called if an error occurs during shader compilation.
  92772. */
  92773. onErrorObservable: Observable<Effect>;
  92774. /** @hidden */
  92775. _onBindObservable: Nullable<Observable<Effect>>;
  92776. /**
  92777. * Observable that will be called when effect is bound.
  92778. */
  92779. readonly onBindObservable: Observable<Effect>;
  92780. /** @hidden */
  92781. _bonesComputationForcedToCPU: boolean;
  92782. private static _uniqueIdSeed;
  92783. private _engine;
  92784. private _uniformBuffersNames;
  92785. private _uniformsNames;
  92786. private _samplerList;
  92787. private _samplers;
  92788. private _isReady;
  92789. private _compilationError;
  92790. private _attributesNames;
  92791. private _attributes;
  92792. private _uniforms;
  92793. /**
  92794. * Key for the effect.
  92795. * @hidden
  92796. */
  92797. _key: string;
  92798. private _indexParameters;
  92799. private _fallbacks;
  92800. private _vertexSourceCode;
  92801. private _fragmentSourceCode;
  92802. private _vertexSourceCodeOverride;
  92803. private _fragmentSourceCodeOverride;
  92804. private _transformFeedbackVaryings;
  92805. /**
  92806. * Compiled shader to webGL program.
  92807. * @hidden
  92808. */
  92809. _pipelineContext: Nullable<IPipelineContext>;
  92810. private _valueCache;
  92811. private static _baseCache;
  92812. /**
  92813. * Instantiates an effect.
  92814. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92815. * @param baseName Name of the effect.
  92816. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92817. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92818. * @param samplers List of sampler variables that will be passed to the shader.
  92819. * @param engine Engine to be used to render the effect
  92820. * @param defines Define statements to be added to the shader.
  92821. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92822. * @param onCompiled Callback that will be called when the shader is compiled.
  92823. * @param onError Callback that will be called if an error occurs during shader compilation.
  92824. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92825. */
  92826. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  92827. private _useFinalCode;
  92828. /**
  92829. * Unique key for this effect
  92830. */
  92831. readonly key: string;
  92832. /**
  92833. * If the effect has been compiled and prepared.
  92834. * @returns if the effect is compiled and prepared.
  92835. */
  92836. isReady(): boolean;
  92837. /**
  92838. * The engine the effect was initialized with.
  92839. * @returns the engine.
  92840. */
  92841. getEngine(): Engine;
  92842. /**
  92843. * The pipeline context for this effect
  92844. * @returns the associated pipeline context
  92845. */
  92846. getPipelineContext(): Nullable<IPipelineContext>;
  92847. /**
  92848. * The set of names of attribute variables for the shader.
  92849. * @returns An array of attribute names.
  92850. */
  92851. getAttributesNames(): string[];
  92852. /**
  92853. * Returns the attribute at the given index.
  92854. * @param index The index of the attribute.
  92855. * @returns The location of the attribute.
  92856. */
  92857. getAttributeLocation(index: number): number;
  92858. /**
  92859. * Returns the attribute based on the name of the variable.
  92860. * @param name of the attribute to look up.
  92861. * @returns the attribute location.
  92862. */
  92863. getAttributeLocationByName(name: string): number;
  92864. /**
  92865. * The number of attributes.
  92866. * @returns the numnber of attributes.
  92867. */
  92868. getAttributesCount(): number;
  92869. /**
  92870. * Gets the index of a uniform variable.
  92871. * @param uniformName of the uniform to look up.
  92872. * @returns the index.
  92873. */
  92874. getUniformIndex(uniformName: string): number;
  92875. /**
  92876. * Returns the attribute based on the name of the variable.
  92877. * @param uniformName of the uniform to look up.
  92878. * @returns the location of the uniform.
  92879. */
  92880. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92881. /**
  92882. * Returns an array of sampler variable names
  92883. * @returns The array of sampler variable neames.
  92884. */
  92885. getSamplers(): string[];
  92886. /**
  92887. * The error from the last compilation.
  92888. * @returns the error string.
  92889. */
  92890. getCompilationError(): string;
  92891. /**
  92892. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92893. * @param func The callback to be used.
  92894. */
  92895. executeWhenCompiled(func: (effect: Effect) => void): void;
  92896. private _checkIsReady;
  92897. /** @hidden */
  92898. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92899. /** @hidden */
  92900. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92901. /** @hidden */
  92902. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92903. /**
  92904. * Recompiles the webGL program
  92905. * @param vertexSourceCode The source code for the vertex shader.
  92906. * @param fragmentSourceCode The source code for the fragment shader.
  92907. * @param onCompiled Callback called when completed.
  92908. * @param onError Callback called on error.
  92909. * @hidden
  92910. */
  92911. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92912. /**
  92913. * Prepares the effect
  92914. * @hidden
  92915. */
  92916. _prepareEffect(): void;
  92917. /**
  92918. * Checks if the effect is supported. (Must be called after compilation)
  92919. */
  92920. readonly isSupported: boolean;
  92921. /**
  92922. * Binds a texture to the engine to be used as output of the shader.
  92923. * @param channel Name of the output variable.
  92924. * @param texture Texture to bind.
  92925. * @hidden
  92926. */
  92927. _bindTexture(channel: string, texture: InternalTexture): void;
  92928. /**
  92929. * Sets a texture on the engine to be used in the shader.
  92930. * @param channel Name of the sampler variable.
  92931. * @param texture Texture to set.
  92932. */
  92933. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92934. /**
  92935. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92936. * @param channel Name of the sampler variable.
  92937. * @param texture Texture to set.
  92938. */
  92939. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92940. /**
  92941. * Sets an array of textures on the engine to be used in the shader.
  92942. * @param channel Name of the variable.
  92943. * @param textures Textures to set.
  92944. */
  92945. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92946. /**
  92947. * 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)
  92948. * @param channel Name of the sampler variable.
  92949. * @param postProcess Post process to get the input texture from.
  92950. */
  92951. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92952. /**
  92953. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92954. * 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)
  92955. * @param channel Name of the sampler variable.
  92956. * @param postProcess Post process to get the output texture from.
  92957. */
  92958. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92959. /** @hidden */
  92960. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92961. /** @hidden */
  92962. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92963. /** @hidden */
  92964. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92965. /** @hidden */
  92966. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92967. /**
  92968. * Binds a buffer to a uniform.
  92969. * @param buffer Buffer to bind.
  92970. * @param name Name of the uniform variable to bind to.
  92971. */
  92972. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92973. /**
  92974. * Binds block to a uniform.
  92975. * @param blockName Name of the block to bind.
  92976. * @param index Index to bind.
  92977. */
  92978. bindUniformBlock(blockName: string, index: number): void;
  92979. /**
  92980. * Sets an interger value on a uniform variable.
  92981. * @param uniformName Name of the variable.
  92982. * @param value Value to be set.
  92983. * @returns this effect.
  92984. */
  92985. setInt(uniformName: string, value: number): Effect;
  92986. /**
  92987. * Sets an int array on a uniform variable.
  92988. * @param uniformName Name of the variable.
  92989. * @param array array to be set.
  92990. * @returns this effect.
  92991. */
  92992. setIntArray(uniformName: string, array: Int32Array): Effect;
  92993. /**
  92994. * 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)
  92995. * @param uniformName Name of the variable.
  92996. * @param array array to be set.
  92997. * @returns this effect.
  92998. */
  92999. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93000. /**
  93001. * 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)
  93002. * @param uniformName Name of the variable.
  93003. * @param array array to be set.
  93004. * @returns this effect.
  93005. */
  93006. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93007. /**
  93008. * 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)
  93009. * @param uniformName Name of the variable.
  93010. * @param array array to be set.
  93011. * @returns this effect.
  93012. */
  93013. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93014. /**
  93015. * Sets an float array on a uniform variable.
  93016. * @param uniformName Name of the variable.
  93017. * @param array array to be set.
  93018. * @returns this effect.
  93019. */
  93020. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93021. /**
  93022. * 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)
  93023. * @param uniformName Name of the variable.
  93024. * @param array array to be set.
  93025. * @returns this effect.
  93026. */
  93027. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93028. /**
  93029. * 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)
  93030. * @param uniformName Name of the variable.
  93031. * @param array array to be set.
  93032. * @returns this effect.
  93033. */
  93034. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93035. /**
  93036. * 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)
  93037. * @param uniformName Name of the variable.
  93038. * @param array array to be set.
  93039. * @returns this effect.
  93040. */
  93041. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93042. /**
  93043. * Sets an array on a uniform variable.
  93044. * @param uniformName Name of the variable.
  93045. * @param array array to be set.
  93046. * @returns this effect.
  93047. */
  93048. setArray(uniformName: string, array: number[]): Effect;
  93049. /**
  93050. * 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)
  93051. * @param uniformName Name of the variable.
  93052. * @param array array to be set.
  93053. * @returns this effect.
  93054. */
  93055. setArray2(uniformName: string, array: number[]): Effect;
  93056. /**
  93057. * 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)
  93058. * @param uniformName Name of the variable.
  93059. * @param array array to be set.
  93060. * @returns this effect.
  93061. */
  93062. setArray3(uniformName: string, array: number[]): Effect;
  93063. /**
  93064. * 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)
  93065. * @param uniformName Name of the variable.
  93066. * @param array array to be set.
  93067. * @returns this effect.
  93068. */
  93069. setArray4(uniformName: string, array: number[]): Effect;
  93070. /**
  93071. * Sets matrices on a uniform variable.
  93072. * @param uniformName Name of the variable.
  93073. * @param matrices matrices to be set.
  93074. * @returns this effect.
  93075. */
  93076. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93077. /**
  93078. * Sets matrix on a uniform variable.
  93079. * @param uniformName Name of the variable.
  93080. * @param matrix matrix to be set.
  93081. * @returns this effect.
  93082. */
  93083. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93084. /**
  93085. * 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)
  93086. * @param uniformName Name of the variable.
  93087. * @param matrix matrix to be set.
  93088. * @returns this effect.
  93089. */
  93090. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93091. /**
  93092. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93093. * @param uniformName Name of the variable.
  93094. * @param matrix matrix to be set.
  93095. * @returns this effect.
  93096. */
  93097. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93098. /**
  93099. * Sets a float on a uniform variable.
  93100. * @param uniformName Name of the variable.
  93101. * @param value value to be set.
  93102. * @returns this effect.
  93103. */
  93104. setFloat(uniformName: string, value: number): Effect;
  93105. /**
  93106. * Sets a boolean on a uniform variable.
  93107. * @param uniformName Name of the variable.
  93108. * @param bool value to be set.
  93109. * @returns this effect.
  93110. */
  93111. setBool(uniformName: string, bool: boolean): Effect;
  93112. /**
  93113. * Sets a Vector2 on a uniform variable.
  93114. * @param uniformName Name of the variable.
  93115. * @param vector2 vector2 to be set.
  93116. * @returns this effect.
  93117. */
  93118. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93119. /**
  93120. * Sets a float2 on a uniform variable.
  93121. * @param uniformName Name of the variable.
  93122. * @param x First float in float2.
  93123. * @param y Second float in float2.
  93124. * @returns this effect.
  93125. */
  93126. setFloat2(uniformName: string, x: number, y: number): Effect;
  93127. /**
  93128. * Sets a Vector3 on a uniform variable.
  93129. * @param uniformName Name of the variable.
  93130. * @param vector3 Value to be set.
  93131. * @returns this effect.
  93132. */
  93133. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93134. /**
  93135. * Sets a float3 on a uniform variable.
  93136. * @param uniformName Name of the variable.
  93137. * @param x First float in float3.
  93138. * @param y Second float in float3.
  93139. * @param z Third float in float3.
  93140. * @returns this effect.
  93141. */
  93142. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93143. /**
  93144. * Sets a Vector4 on a uniform variable.
  93145. * @param uniformName Name of the variable.
  93146. * @param vector4 Value to be set.
  93147. * @returns this effect.
  93148. */
  93149. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93150. /**
  93151. * Sets a float4 on a uniform variable.
  93152. * @param uniformName Name of the variable.
  93153. * @param x First float in float4.
  93154. * @param y Second float in float4.
  93155. * @param z Third float in float4.
  93156. * @param w Fourth float in float4.
  93157. * @returns this effect.
  93158. */
  93159. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93160. /**
  93161. * Sets a Color3 on a uniform variable.
  93162. * @param uniformName Name of the variable.
  93163. * @param color3 Value to be set.
  93164. * @returns this effect.
  93165. */
  93166. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93167. /**
  93168. * Sets a Color4 on a uniform variable.
  93169. * @param uniformName Name of the variable.
  93170. * @param color3 Value to be set.
  93171. * @param alpha Alpha value to be set.
  93172. * @returns this effect.
  93173. */
  93174. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93175. /**
  93176. * Sets a Color4 on a uniform variable
  93177. * @param uniformName defines the name of the variable
  93178. * @param color4 defines the value to be set
  93179. * @returns this effect.
  93180. */
  93181. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93182. /** Release all associated resources */
  93183. dispose(): void;
  93184. /**
  93185. * This function will add a new shader to the shader store
  93186. * @param name the name of the shader
  93187. * @param pixelShader optional pixel shader content
  93188. * @param vertexShader optional vertex shader content
  93189. */
  93190. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93191. /**
  93192. * Store of each shader (The can be looked up using effect.key)
  93193. */
  93194. static ShadersStore: {
  93195. [key: string]: string;
  93196. };
  93197. /**
  93198. * Store of each included file for a shader (The can be looked up using effect.key)
  93199. */
  93200. static IncludesShadersStore: {
  93201. [key: string]: string;
  93202. };
  93203. /**
  93204. * Resets the cache of effects.
  93205. */
  93206. static ResetCache(): void;
  93207. }
  93208. }
  93209. declare module BABYLON {
  93210. /**
  93211. * Uniform buffer objects.
  93212. *
  93213. * Handles blocks of uniform on the GPU.
  93214. *
  93215. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93216. *
  93217. * For more information, please refer to :
  93218. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93219. */
  93220. export class UniformBuffer {
  93221. private _engine;
  93222. private _buffer;
  93223. private _data;
  93224. private _bufferData;
  93225. private _dynamic?;
  93226. private _uniformLocations;
  93227. private _uniformSizes;
  93228. private _uniformLocationPointer;
  93229. private _needSync;
  93230. private _noUBO;
  93231. private _currentEffect;
  93232. private static _MAX_UNIFORM_SIZE;
  93233. private static _tempBuffer;
  93234. /**
  93235. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93236. * This is dynamic to allow compat with webgl 1 and 2.
  93237. * You will need to pass the name of the uniform as well as the value.
  93238. */
  93239. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93240. /**
  93241. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93242. * This is dynamic to allow compat with webgl 1 and 2.
  93243. * You will need to pass the name of the uniform as well as the value.
  93244. */
  93245. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93246. /**
  93247. * Lambda to Update a single float in a uniform buffer.
  93248. * This is dynamic to allow compat with webgl 1 and 2.
  93249. * You will need to pass the name of the uniform as well as the value.
  93250. */
  93251. updateFloat: (name: string, x: number) => void;
  93252. /**
  93253. * Lambda to Update a vec2 of float in a uniform buffer.
  93254. * This is dynamic to allow compat with webgl 1 and 2.
  93255. * You will need to pass the name of the uniform as well as the value.
  93256. */
  93257. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93258. /**
  93259. * Lambda to Update a vec3 of float in a uniform buffer.
  93260. * This is dynamic to allow compat with webgl 1 and 2.
  93261. * You will need to pass the name of the uniform as well as the value.
  93262. */
  93263. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93264. /**
  93265. * Lambda to Update a vec4 of float in a uniform buffer.
  93266. * This is dynamic to allow compat with webgl 1 and 2.
  93267. * You will need to pass the name of the uniform as well as the value.
  93268. */
  93269. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93270. /**
  93271. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93272. * This is dynamic to allow compat with webgl 1 and 2.
  93273. * You will need to pass the name of the uniform as well as the value.
  93274. */
  93275. updateMatrix: (name: string, mat: Matrix) => void;
  93276. /**
  93277. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93278. * This is dynamic to allow compat with webgl 1 and 2.
  93279. * You will need to pass the name of the uniform as well as the value.
  93280. */
  93281. updateVector3: (name: string, vector: Vector3) => void;
  93282. /**
  93283. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93284. * This is dynamic to allow compat with webgl 1 and 2.
  93285. * You will need to pass the name of the uniform as well as the value.
  93286. */
  93287. updateVector4: (name: string, vector: Vector4) => void;
  93288. /**
  93289. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93290. * This is dynamic to allow compat with webgl 1 and 2.
  93291. * You will need to pass the name of the uniform as well as the value.
  93292. */
  93293. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93294. /**
  93295. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93296. * This is dynamic to allow compat with webgl 1 and 2.
  93297. * You will need to pass the name of the uniform as well as the value.
  93298. */
  93299. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93300. /**
  93301. * Instantiates a new Uniform buffer objects.
  93302. *
  93303. * Handles blocks of uniform on the GPU.
  93304. *
  93305. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93306. *
  93307. * For more information, please refer to :
  93308. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93309. * @param engine Define the engine the buffer is associated with
  93310. * @param data Define the data contained in the buffer
  93311. * @param dynamic Define if the buffer is updatable
  93312. */
  93313. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93314. /**
  93315. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93316. * or just falling back on setUniformXXX calls.
  93317. */
  93318. readonly useUbo: boolean;
  93319. /**
  93320. * Indicates if the WebGL underlying uniform buffer is in sync
  93321. * with the javascript cache data.
  93322. */
  93323. readonly isSync: boolean;
  93324. /**
  93325. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93326. * Also, a dynamic UniformBuffer will disable cache verification and always
  93327. * update the underlying WebGL uniform buffer to the GPU.
  93328. * @returns if Dynamic, otherwise false
  93329. */
  93330. isDynamic(): boolean;
  93331. /**
  93332. * The data cache on JS side.
  93333. * @returns the underlying data as a float array
  93334. */
  93335. getData(): Float32Array;
  93336. /**
  93337. * The underlying WebGL Uniform buffer.
  93338. * @returns the webgl buffer
  93339. */
  93340. getBuffer(): Nullable<DataBuffer>;
  93341. /**
  93342. * std140 layout specifies how to align data within an UBO structure.
  93343. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93344. * for specs.
  93345. */
  93346. private _fillAlignment;
  93347. /**
  93348. * Adds an uniform in the buffer.
  93349. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93350. * for the layout to be correct !
  93351. * @param name Name of the uniform, as used in the uniform block in the shader.
  93352. * @param size Data size, or data directly.
  93353. */
  93354. addUniform(name: string, size: number | number[]): void;
  93355. /**
  93356. * Adds a Matrix 4x4 to the uniform buffer.
  93357. * @param name Name of the uniform, as used in the uniform block in the shader.
  93358. * @param mat A 4x4 matrix.
  93359. */
  93360. addMatrix(name: string, mat: Matrix): void;
  93361. /**
  93362. * Adds a vec2 to the uniform buffer.
  93363. * @param name Name of the uniform, as used in the uniform block in the shader.
  93364. * @param x Define the x component value of the vec2
  93365. * @param y Define the y component value of the vec2
  93366. */
  93367. addFloat2(name: string, x: number, y: number): void;
  93368. /**
  93369. * Adds a vec3 to the uniform buffer.
  93370. * @param name Name of the uniform, as used in the uniform block in the shader.
  93371. * @param x Define the x component value of the vec3
  93372. * @param y Define the y component value of the vec3
  93373. * @param z Define the z component value of the vec3
  93374. */
  93375. addFloat3(name: string, x: number, y: number, z: number): void;
  93376. /**
  93377. * Adds a vec3 to the uniform buffer.
  93378. * @param name Name of the uniform, as used in the uniform block in the shader.
  93379. * @param color Define the vec3 from a Color
  93380. */
  93381. addColor3(name: string, color: Color3): void;
  93382. /**
  93383. * Adds a vec4 to the uniform buffer.
  93384. * @param name Name of the uniform, as used in the uniform block in the shader.
  93385. * @param color Define the rgb components from a Color
  93386. * @param alpha Define the a component of the vec4
  93387. */
  93388. addColor4(name: string, color: Color3, alpha: number): void;
  93389. /**
  93390. * Adds a vec3 to the uniform buffer.
  93391. * @param name Name of the uniform, as used in the uniform block in the shader.
  93392. * @param vector Define the vec3 components from a Vector
  93393. */
  93394. addVector3(name: string, vector: Vector3): void;
  93395. /**
  93396. * Adds a Matrix 3x3 to the uniform buffer.
  93397. * @param name Name of the uniform, as used in the uniform block in the shader.
  93398. */
  93399. addMatrix3x3(name: string): void;
  93400. /**
  93401. * Adds a Matrix 2x2 to the uniform buffer.
  93402. * @param name Name of the uniform, as used in the uniform block in the shader.
  93403. */
  93404. addMatrix2x2(name: string): void;
  93405. /**
  93406. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93407. */
  93408. create(): void;
  93409. /** @hidden */
  93410. _rebuild(): void;
  93411. /**
  93412. * Updates the WebGL Uniform Buffer on the GPU.
  93413. * If the `dynamic` flag is set to true, no cache comparison is done.
  93414. * Otherwise, the buffer will be updated only if the cache differs.
  93415. */
  93416. update(): void;
  93417. /**
  93418. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93419. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93420. * @param data Define the flattened data
  93421. * @param size Define the size of the data.
  93422. */
  93423. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93424. private _updateMatrix3x3ForUniform;
  93425. private _updateMatrix3x3ForEffect;
  93426. private _updateMatrix2x2ForEffect;
  93427. private _updateMatrix2x2ForUniform;
  93428. private _updateFloatForEffect;
  93429. private _updateFloatForUniform;
  93430. private _updateFloat2ForEffect;
  93431. private _updateFloat2ForUniform;
  93432. private _updateFloat3ForEffect;
  93433. private _updateFloat3ForUniform;
  93434. private _updateFloat4ForEffect;
  93435. private _updateFloat4ForUniform;
  93436. private _updateMatrixForEffect;
  93437. private _updateMatrixForUniform;
  93438. private _updateVector3ForEffect;
  93439. private _updateVector3ForUniform;
  93440. private _updateVector4ForEffect;
  93441. private _updateVector4ForUniform;
  93442. private _updateColor3ForEffect;
  93443. private _updateColor3ForUniform;
  93444. private _updateColor4ForEffect;
  93445. private _updateColor4ForUniform;
  93446. /**
  93447. * Sets a sampler uniform on the effect.
  93448. * @param name Define the name of the sampler.
  93449. * @param texture Define the texture to set in the sampler
  93450. */
  93451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93452. /**
  93453. * Directly updates the value of the uniform in the cache AND on the GPU.
  93454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93455. * @param data Define the flattened data
  93456. */
  93457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93458. /**
  93459. * Binds this uniform buffer to an effect.
  93460. * @param effect Define the effect to bind the buffer to
  93461. * @param name Name of the uniform block in the shader.
  93462. */
  93463. bindToEffect(effect: Effect, name: string): void;
  93464. /**
  93465. * Disposes the uniform buffer.
  93466. */
  93467. dispose(): void;
  93468. }
  93469. }
  93470. declare module BABYLON {
  93471. /**
  93472. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93474. */
  93475. export class Analyser {
  93476. /**
  93477. * Gets or sets the smoothing
  93478. * @ignorenaming
  93479. */
  93480. SMOOTHING: number;
  93481. /**
  93482. * Gets or sets the FFT table size
  93483. * @ignorenaming
  93484. */
  93485. FFT_SIZE: number;
  93486. /**
  93487. * Gets or sets the bar graph amplitude
  93488. * @ignorenaming
  93489. */
  93490. BARGRAPHAMPLITUDE: number;
  93491. /**
  93492. * Gets or sets the position of the debug canvas
  93493. * @ignorenaming
  93494. */
  93495. DEBUGCANVASPOS: {
  93496. x: number;
  93497. y: number;
  93498. };
  93499. /**
  93500. * Gets or sets the debug canvas size
  93501. * @ignorenaming
  93502. */
  93503. DEBUGCANVASSIZE: {
  93504. width: number;
  93505. height: number;
  93506. };
  93507. private _byteFreqs;
  93508. private _byteTime;
  93509. private _floatFreqs;
  93510. private _webAudioAnalyser;
  93511. private _debugCanvas;
  93512. private _debugCanvasContext;
  93513. private _scene;
  93514. private _registerFunc;
  93515. private _audioEngine;
  93516. /**
  93517. * Creates a new analyser
  93518. * @param scene defines hosting scene
  93519. */
  93520. constructor(scene: Scene);
  93521. /**
  93522. * Get the number of data values you will have to play with for the visualization
  93523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93524. * @returns a number
  93525. */
  93526. getFrequencyBinCount(): number;
  93527. /**
  93528. * Gets the current frequency data as a byte array
  93529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93530. * @returns a Uint8Array
  93531. */
  93532. getByteFrequencyData(): Uint8Array;
  93533. /**
  93534. * Gets the current waveform as a byte array
  93535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93536. * @returns a Uint8Array
  93537. */
  93538. getByteTimeDomainData(): Uint8Array;
  93539. /**
  93540. * Gets the current frequency data as a float array
  93541. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93542. * @returns a Float32Array
  93543. */
  93544. getFloatFrequencyData(): Float32Array;
  93545. /**
  93546. * Renders the debug canvas
  93547. */
  93548. drawDebugCanvas(): void;
  93549. /**
  93550. * Stops rendering the debug canvas and removes it
  93551. */
  93552. stopDebugCanvas(): void;
  93553. /**
  93554. * Connects two audio nodes
  93555. * @param inputAudioNode defines first node to connect
  93556. * @param outputAudioNode defines second node to connect
  93557. */
  93558. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93559. /**
  93560. * Releases all associated resources
  93561. */
  93562. dispose(): void;
  93563. }
  93564. }
  93565. declare module BABYLON {
  93566. /**
  93567. * This represents an audio engine and it is responsible
  93568. * to play, synchronize and analyse sounds throughout the application.
  93569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93570. */
  93571. export interface IAudioEngine extends IDisposable {
  93572. /**
  93573. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93574. */
  93575. readonly canUseWebAudio: boolean;
  93576. /**
  93577. * Gets the current AudioContext if available.
  93578. */
  93579. readonly audioContext: Nullable<AudioContext>;
  93580. /**
  93581. * The master gain node defines the global audio volume of your audio engine.
  93582. */
  93583. readonly masterGain: GainNode;
  93584. /**
  93585. * Gets whether or not mp3 are supported by your browser.
  93586. */
  93587. readonly isMP3supported: boolean;
  93588. /**
  93589. * Gets whether or not ogg are supported by your browser.
  93590. */
  93591. readonly isOGGsupported: boolean;
  93592. /**
  93593. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93594. * @ignoreNaming
  93595. */
  93596. WarnedWebAudioUnsupported: boolean;
  93597. /**
  93598. * Defines if the audio engine relies on a custom unlocked button.
  93599. * In this case, the embedded button will not be displayed.
  93600. */
  93601. useCustomUnlockedButton: boolean;
  93602. /**
  93603. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93604. */
  93605. readonly unlocked: boolean;
  93606. /**
  93607. * Event raised when audio has been unlocked on the browser.
  93608. */
  93609. onAudioUnlockedObservable: Observable<AudioEngine>;
  93610. /**
  93611. * Event raised when audio has been locked on the browser.
  93612. */
  93613. onAudioLockedObservable: Observable<AudioEngine>;
  93614. /**
  93615. * Flags the audio engine in Locked state.
  93616. * This happens due to new browser policies preventing audio to autoplay.
  93617. */
  93618. lock(): void;
  93619. /**
  93620. * Unlocks the audio engine once a user action has been done on the dom.
  93621. * This is helpful to resume play once browser policies have been satisfied.
  93622. */
  93623. unlock(): void;
  93624. }
  93625. /**
  93626. * This represents the default audio engine used in babylon.
  93627. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93629. */
  93630. export class AudioEngine implements IAudioEngine {
  93631. private _audioContext;
  93632. private _audioContextInitialized;
  93633. private _muteButton;
  93634. private _hostElement;
  93635. /**
  93636. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93637. */
  93638. canUseWebAudio: boolean;
  93639. /**
  93640. * The master gain node defines the global audio volume of your audio engine.
  93641. */
  93642. masterGain: GainNode;
  93643. /**
  93644. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93645. * @ignoreNaming
  93646. */
  93647. WarnedWebAudioUnsupported: boolean;
  93648. /**
  93649. * Gets whether or not mp3 are supported by your browser.
  93650. */
  93651. isMP3supported: boolean;
  93652. /**
  93653. * Gets whether or not ogg are supported by your browser.
  93654. */
  93655. isOGGsupported: boolean;
  93656. /**
  93657. * Gets whether audio has been unlocked on the device.
  93658. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93659. * a user interaction has happened.
  93660. */
  93661. unlocked: boolean;
  93662. /**
  93663. * Defines if the audio engine relies on a custom unlocked button.
  93664. * In this case, the embedded button will not be displayed.
  93665. */
  93666. useCustomUnlockedButton: boolean;
  93667. /**
  93668. * Event raised when audio has been unlocked on the browser.
  93669. */
  93670. onAudioUnlockedObservable: Observable<AudioEngine>;
  93671. /**
  93672. * Event raised when audio has been locked on the browser.
  93673. */
  93674. onAudioLockedObservable: Observable<AudioEngine>;
  93675. /**
  93676. * Gets the current AudioContext if available.
  93677. */
  93678. readonly audioContext: Nullable<AudioContext>;
  93679. private _connectedAnalyser;
  93680. /**
  93681. * Instantiates a new audio engine.
  93682. *
  93683. * There should be only one per page as some browsers restrict the number
  93684. * of audio contexts you can create.
  93685. * @param hostElement defines the host element where to display the mute icon if necessary
  93686. */
  93687. constructor(hostElement?: Nullable<HTMLElement>);
  93688. /**
  93689. * Flags the audio engine in Locked state.
  93690. * This happens due to new browser policies preventing audio to autoplay.
  93691. */
  93692. lock(): void;
  93693. /**
  93694. * Unlocks the audio engine once a user action has been done on the dom.
  93695. * This is helpful to resume play once browser policies have been satisfied.
  93696. */
  93697. unlock(): void;
  93698. private _resumeAudioContext;
  93699. private _initializeAudioContext;
  93700. private _tryToRun;
  93701. private _triggerRunningState;
  93702. private _triggerSuspendedState;
  93703. private _displayMuteButton;
  93704. private _moveButtonToTopLeft;
  93705. private _onResize;
  93706. private _hideMuteButton;
  93707. /**
  93708. * Destroy and release the resources associated with the audio ccontext.
  93709. */
  93710. dispose(): void;
  93711. /**
  93712. * Gets the global volume sets on the master gain.
  93713. * @returns the global volume if set or -1 otherwise
  93714. */
  93715. getGlobalVolume(): number;
  93716. /**
  93717. * Sets the global volume of your experience (sets on the master gain).
  93718. * @param newVolume Defines the new global volume of the application
  93719. */
  93720. setGlobalVolume(newVolume: number): void;
  93721. /**
  93722. * Connect the audio engine to an audio analyser allowing some amazing
  93723. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93725. * @param analyser The analyser to connect to the engine
  93726. */
  93727. connectToAnalyser(analyser: Analyser): void;
  93728. }
  93729. }
  93730. declare module BABYLON {
  93731. /**
  93732. * Interface used to present a loading screen while loading a scene
  93733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93734. */
  93735. export interface ILoadingScreen {
  93736. /**
  93737. * Function called to display the loading screen
  93738. */
  93739. displayLoadingUI: () => void;
  93740. /**
  93741. * Function called to hide the loading screen
  93742. */
  93743. hideLoadingUI: () => void;
  93744. /**
  93745. * Gets or sets the color to use for the background
  93746. */
  93747. loadingUIBackgroundColor: string;
  93748. /**
  93749. * Gets or sets the text to display while loading
  93750. */
  93751. loadingUIText: string;
  93752. }
  93753. /**
  93754. * Class used for the default loading screen
  93755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93756. */
  93757. export class DefaultLoadingScreen implements ILoadingScreen {
  93758. private _renderingCanvas;
  93759. private _loadingText;
  93760. private _loadingDivBackgroundColor;
  93761. private _loadingDiv;
  93762. private _loadingTextDiv;
  93763. /** Gets or sets the logo url to use for the default loading screen */
  93764. static DefaultLogoUrl: string;
  93765. /** Gets or sets the spinner url to use for the default loading screen */
  93766. static DefaultSpinnerUrl: string;
  93767. /**
  93768. * Creates a new default loading screen
  93769. * @param _renderingCanvas defines the canvas used to render the scene
  93770. * @param _loadingText defines the default text to display
  93771. * @param _loadingDivBackgroundColor defines the default background color
  93772. */
  93773. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93774. /**
  93775. * Function called to display the loading screen
  93776. */
  93777. displayLoadingUI(): void;
  93778. /**
  93779. * Function called to hide the loading screen
  93780. */
  93781. hideLoadingUI(): void;
  93782. /**
  93783. * Gets or sets the text to display while loading
  93784. */
  93785. loadingUIText: string;
  93786. /**
  93787. * Gets or sets the color to use for the background
  93788. */
  93789. loadingUIBackgroundColor: string;
  93790. private _resizeLoadingUI;
  93791. }
  93792. }
  93793. declare module BABYLON {
  93794. /** @hidden */
  93795. export class WebGLPipelineContext implements IPipelineContext {
  93796. engine: Engine;
  93797. program: Nullable<WebGLProgram>;
  93798. context?: WebGLRenderingContext;
  93799. vertexShader?: WebGLShader;
  93800. fragmentShader?: WebGLShader;
  93801. isParallelCompiled: boolean;
  93802. onCompiled?: () => void;
  93803. transformFeedback?: WebGLTransformFeedback | null;
  93804. readonly isAsync: boolean;
  93805. readonly isReady: boolean;
  93806. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93807. }
  93808. }
  93809. declare module BABYLON {
  93810. /** @hidden */
  93811. export class WebGLDataBuffer extends DataBuffer {
  93812. private _buffer;
  93813. constructor(resource: WebGLBuffer);
  93814. readonly underlyingResource: any;
  93815. }
  93816. }
  93817. declare module BABYLON {
  93818. /** @hidden */
  93819. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93820. attributeProcessor(attribute: string): string;
  93821. varyingProcessor(varying: string, isFragment: boolean): string;
  93822. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93823. }
  93824. }
  93825. declare module BABYLON {
  93826. /**
  93827. * This class is used to track a performance counter which is number based.
  93828. * The user has access to many properties which give statistics of different nature.
  93829. *
  93830. * The implementer can track two kinds of Performance Counter: time and count.
  93831. * 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.
  93832. * 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.
  93833. */
  93834. export class PerfCounter {
  93835. /**
  93836. * Gets or sets a global boolean to turn on and off all the counters
  93837. */
  93838. static Enabled: boolean;
  93839. /**
  93840. * Returns the smallest value ever
  93841. */
  93842. readonly min: number;
  93843. /**
  93844. * Returns the biggest value ever
  93845. */
  93846. readonly max: number;
  93847. /**
  93848. * Returns the average value since the performance counter is running
  93849. */
  93850. readonly average: number;
  93851. /**
  93852. * Returns the average value of the last second the counter was monitored
  93853. */
  93854. readonly lastSecAverage: number;
  93855. /**
  93856. * Returns the current value
  93857. */
  93858. readonly current: number;
  93859. /**
  93860. * Gets the accumulated total
  93861. */
  93862. readonly total: number;
  93863. /**
  93864. * Gets the total value count
  93865. */
  93866. readonly count: number;
  93867. /**
  93868. * Creates a new counter
  93869. */
  93870. constructor();
  93871. /**
  93872. * Call this method to start monitoring a new frame.
  93873. * 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.
  93874. */
  93875. fetchNewFrame(): void;
  93876. /**
  93877. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93878. * @param newCount the count value to add to the monitored count
  93879. * @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.
  93880. */
  93881. addCount(newCount: number, fetchResult: boolean): void;
  93882. /**
  93883. * Start monitoring this performance counter
  93884. */
  93885. beginMonitoring(): void;
  93886. /**
  93887. * Compute the time lapsed since the previous beginMonitoring() call.
  93888. * @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
  93889. */
  93890. endMonitoring(newFrame?: boolean): void;
  93891. private _fetchResult;
  93892. private _startMonitoringTime;
  93893. private _min;
  93894. private _max;
  93895. private _average;
  93896. private _current;
  93897. private _totalValueCount;
  93898. private _totalAccumulated;
  93899. private _lastSecAverage;
  93900. private _lastSecAccumulated;
  93901. private _lastSecTime;
  93902. private _lastSecValueCount;
  93903. }
  93904. }
  93905. declare module BABYLON {
  93906. /**
  93907. * Interface for any object that can request an animation frame
  93908. */
  93909. export interface ICustomAnimationFrameRequester {
  93910. /**
  93911. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93912. */
  93913. renderFunction?: Function;
  93914. /**
  93915. * Called to request the next frame to render to
  93916. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93917. */
  93918. requestAnimationFrame: Function;
  93919. /**
  93920. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93921. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93922. */
  93923. requestID?: number;
  93924. }
  93925. }
  93926. declare module BABYLON {
  93927. /**
  93928. * Settings for finer control over video usage
  93929. */
  93930. export interface VideoTextureSettings {
  93931. /**
  93932. * Applies `autoplay` to video, if specified
  93933. */
  93934. autoPlay?: boolean;
  93935. /**
  93936. * Applies `loop` to video, if specified
  93937. */
  93938. loop?: boolean;
  93939. /**
  93940. * Automatically updates internal texture from video at every frame in the render loop
  93941. */
  93942. autoUpdateTexture: boolean;
  93943. /**
  93944. * Image src displayed during the video loading or until the user interacts with the video.
  93945. */
  93946. poster?: string;
  93947. }
  93948. /**
  93949. * If you want to display a video in your scene, this is the special texture for that.
  93950. * This special texture works similar to other textures, with the exception of a few parameters.
  93951. * @see https://doc.babylonjs.com/how_to/video_texture
  93952. */
  93953. export class VideoTexture extends Texture {
  93954. /**
  93955. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93956. */
  93957. readonly autoUpdateTexture: boolean;
  93958. /**
  93959. * The video instance used by the texture internally
  93960. */
  93961. readonly video: HTMLVideoElement;
  93962. private _onUserActionRequestedObservable;
  93963. /**
  93964. * Event triggerd when a dom action is required by the user to play the video.
  93965. * This happens due to recent changes in browser policies preventing video to auto start.
  93966. */
  93967. readonly onUserActionRequestedObservable: Observable<Texture>;
  93968. private _generateMipMaps;
  93969. private _engine;
  93970. private _stillImageCaptured;
  93971. private _displayingPosterTexture;
  93972. private _settings;
  93973. private _createInternalTextureOnEvent;
  93974. /**
  93975. * Creates a video texture.
  93976. * If you want to display a video in your scene, this is the special texture for that.
  93977. * This special texture works similar to other textures, with the exception of a few parameters.
  93978. * @see https://doc.babylonjs.com/how_to/video_texture
  93979. * @param name optional name, will detect from video source, if not defined
  93980. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93981. * @param scene is obviously the current scene.
  93982. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93983. * @param invertY is false by default but can be used to invert video on Y axis
  93984. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93985. * @param settings allows finer control over video usage
  93986. */
  93987. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93988. private _getName;
  93989. private _getVideo;
  93990. private _createInternalTexture;
  93991. private reset;
  93992. /**
  93993. * @hidden Internal method to initiate `update`.
  93994. */
  93995. _rebuild(): void;
  93996. /**
  93997. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93998. */
  93999. update(): void;
  94000. /**
  94001. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94002. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94003. */
  94004. updateTexture(isVisible: boolean): void;
  94005. protected _updateInternalTexture: () => void;
  94006. /**
  94007. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94008. * @param url New url.
  94009. */
  94010. updateURL(url: string): void;
  94011. /**
  94012. * Dispose the texture and release its associated resources.
  94013. */
  94014. dispose(): void;
  94015. /**
  94016. * Creates a video texture straight from a stream.
  94017. * @param scene Define the scene the texture should be created in
  94018. * @param stream Define the stream the texture should be created from
  94019. * @returns The created video texture as a promise
  94020. */
  94021. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94022. /**
  94023. * Creates a video texture straight from your WebCam video feed.
  94024. * @param scene Define the scene the texture should be created in
  94025. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94026. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94027. * @returns The created video texture as a promise
  94028. */
  94029. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94030. minWidth: number;
  94031. maxWidth: number;
  94032. minHeight: number;
  94033. maxHeight: number;
  94034. deviceId: string;
  94035. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94036. /**
  94037. * Creates a video texture straight from your WebCam video feed.
  94038. * @param scene Define the scene the texture should be created in
  94039. * @param onReady Define a callback to triggered once the texture will be ready
  94040. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94041. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94042. */
  94043. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94044. minWidth: number;
  94045. maxWidth: number;
  94046. minHeight: number;
  94047. maxHeight: number;
  94048. deviceId: string;
  94049. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94050. }
  94051. }
  94052. declare module BABYLON {
  94053. /**
  94054. * Defines the interface used by objects containing a viewport (like a camera)
  94055. */
  94056. interface IViewportOwnerLike {
  94057. /**
  94058. * Gets or sets the viewport
  94059. */
  94060. viewport: IViewportLike;
  94061. }
  94062. /**
  94063. * Interface for attribute information associated with buffer instanciation
  94064. */
  94065. export class InstancingAttributeInfo {
  94066. /**
  94067. * Index/offset of the attribute in the vertex shader
  94068. */
  94069. index: number;
  94070. /**
  94071. * size of the attribute, 1, 2, 3 or 4
  94072. */
  94073. attributeSize: number;
  94074. /**
  94075. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94076. * default is FLOAT
  94077. */
  94078. attribyteType: number;
  94079. /**
  94080. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94081. */
  94082. normalized: boolean;
  94083. /**
  94084. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94085. */
  94086. offset: number;
  94087. /**
  94088. * Name of the GLSL attribute, for debugging purpose only
  94089. */
  94090. attributeName: string;
  94091. }
  94092. /**
  94093. * Define options used to create a depth texture
  94094. */
  94095. export class DepthTextureCreationOptions {
  94096. /** Specifies whether or not a stencil should be allocated in the texture */
  94097. generateStencil?: boolean;
  94098. /** Specifies whether or not bilinear filtering is enable on the texture */
  94099. bilinearFiltering?: boolean;
  94100. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94101. comparisonFunction?: number;
  94102. /** Specifies if the created texture is a cube texture */
  94103. isCube?: boolean;
  94104. }
  94105. /**
  94106. * Class used to describe the capabilities of the engine relatively to the current browser
  94107. */
  94108. export class EngineCapabilities {
  94109. /** Maximum textures units per fragment shader */
  94110. maxTexturesImageUnits: number;
  94111. /** Maximum texture units per vertex shader */
  94112. maxVertexTextureImageUnits: number;
  94113. /** Maximum textures units in the entire pipeline */
  94114. maxCombinedTexturesImageUnits: number;
  94115. /** Maximum texture size */
  94116. maxTextureSize: number;
  94117. /** Maximum cube texture size */
  94118. maxCubemapTextureSize: number;
  94119. /** Maximum render texture size */
  94120. maxRenderTextureSize: number;
  94121. /** Maximum number of vertex attributes */
  94122. maxVertexAttribs: number;
  94123. /** Maximum number of varyings */
  94124. maxVaryingVectors: number;
  94125. /** Maximum number of uniforms per vertex shader */
  94126. maxVertexUniformVectors: number;
  94127. /** Maximum number of uniforms per fragment shader */
  94128. maxFragmentUniformVectors: number;
  94129. /** Defines if standard derivates (dx/dy) are supported */
  94130. standardDerivatives: boolean;
  94131. /** Defines if s3tc texture compression is supported */
  94132. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94133. /** Defines if pvrtc texture compression is supported */
  94134. pvrtc: any;
  94135. /** Defines if etc1 texture compression is supported */
  94136. etc1: any;
  94137. /** Defines if etc2 texture compression is supported */
  94138. etc2: any;
  94139. /** Defines if astc texture compression is supported */
  94140. astc: any;
  94141. /** Defines if float textures are supported */
  94142. textureFloat: boolean;
  94143. /** Defines if vertex array objects are supported */
  94144. vertexArrayObject: boolean;
  94145. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94146. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94147. /** Gets the maximum level of anisotropy supported */
  94148. maxAnisotropy: number;
  94149. /** Defines if instancing is supported */
  94150. instancedArrays: boolean;
  94151. /** Defines if 32 bits indices are supported */
  94152. uintIndices: boolean;
  94153. /** Defines if high precision shaders are supported */
  94154. highPrecisionShaderSupported: boolean;
  94155. /** Defines if depth reading in the fragment shader is supported */
  94156. fragmentDepthSupported: boolean;
  94157. /** Defines if float texture linear filtering is supported*/
  94158. textureFloatLinearFiltering: boolean;
  94159. /** Defines if rendering to float textures is supported */
  94160. textureFloatRender: boolean;
  94161. /** Defines if half float textures are supported*/
  94162. textureHalfFloat: boolean;
  94163. /** Defines if half float texture linear filtering is supported*/
  94164. textureHalfFloatLinearFiltering: boolean;
  94165. /** Defines if rendering to half float textures is supported */
  94166. textureHalfFloatRender: boolean;
  94167. /** Defines if textureLOD shader command is supported */
  94168. textureLOD: boolean;
  94169. /** Defines if draw buffers extension is supported */
  94170. drawBuffersExtension: boolean;
  94171. /** Defines if depth textures are supported */
  94172. depthTextureExtension: boolean;
  94173. /** Defines if float color buffer are supported */
  94174. colorBufferFloat: boolean;
  94175. /** Gets disjoint timer query extension (null if not supported) */
  94176. timerQuery: EXT_disjoint_timer_query;
  94177. /** Defines if timestamp can be used with timer query */
  94178. canUseTimestampForTimerQuery: boolean;
  94179. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94180. multiview: any;
  94181. /** Function used to let the system compiles shaders in background */
  94182. parallelShaderCompile: {
  94183. COMPLETION_STATUS_KHR: number;
  94184. };
  94185. /** Max number of texture samples for MSAA */
  94186. maxMSAASamples: number;
  94187. }
  94188. /** Interface defining initialization parameters for Engine class */
  94189. export interface EngineOptions extends WebGLContextAttributes {
  94190. /**
  94191. * Defines if the engine should no exceed a specified device ratio
  94192. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94193. */
  94194. limitDeviceRatio?: number;
  94195. /**
  94196. * Defines if webvr should be enabled automatically
  94197. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94198. */
  94199. autoEnableWebVR?: boolean;
  94200. /**
  94201. * Defines if webgl2 should be turned off even if supported
  94202. * @see http://doc.babylonjs.com/features/webgl2
  94203. */
  94204. disableWebGL2Support?: boolean;
  94205. /**
  94206. * Defines if webaudio should be initialized as well
  94207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94208. */
  94209. audioEngine?: boolean;
  94210. /**
  94211. * Defines if animations should run using a deterministic lock step
  94212. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94213. */
  94214. deterministicLockstep?: boolean;
  94215. /** Defines the maximum steps to use with deterministic lock step mode */
  94216. lockstepMaxSteps?: number;
  94217. /**
  94218. * Defines that engine should ignore context lost events
  94219. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94220. */
  94221. doNotHandleContextLost?: boolean;
  94222. /**
  94223. * Defines that engine should ignore modifying touch action attribute and style
  94224. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94225. */
  94226. doNotHandleTouchAction?: boolean;
  94227. /**
  94228. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94229. */
  94230. useHighPrecisionFloats?: boolean;
  94231. }
  94232. /**
  94233. * Defines the interface used by display changed events
  94234. */
  94235. export interface IDisplayChangedEventArgs {
  94236. /** Gets the vrDisplay object (if any) */
  94237. vrDisplay: Nullable<any>;
  94238. /** Gets a boolean indicating if webVR is supported */
  94239. vrSupported: boolean;
  94240. }
  94241. /**
  94242. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94243. */
  94244. export class Engine {
  94245. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94246. static ExceptionList: ({
  94247. key: string;
  94248. capture: string;
  94249. captureConstraint: number;
  94250. targets: string[];
  94251. } | {
  94252. key: string;
  94253. capture: null;
  94254. captureConstraint: null;
  94255. targets: string[];
  94256. })[];
  94257. /** Gets the list of created engines */
  94258. static readonly Instances: Engine[];
  94259. /**
  94260. * Gets the latest created engine
  94261. */
  94262. static readonly LastCreatedEngine: Nullable<Engine>;
  94263. /**
  94264. * Gets the latest created scene
  94265. */
  94266. static readonly LastCreatedScene: Nullable<Scene>;
  94267. /**
  94268. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94269. * @param flag defines which part of the materials must be marked as dirty
  94270. * @param predicate defines a predicate used to filter which materials should be affected
  94271. */
  94272. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94273. /** @hidden */
  94274. static _TextureLoaders: IInternalTextureLoader[];
  94275. /** Defines that alpha blending is disabled */
  94276. static readonly ALPHA_DISABLE: number;
  94277. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94278. static readonly ALPHA_ADD: number;
  94279. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94280. static readonly ALPHA_COMBINE: number;
  94281. /** Defines that alpha blending to DEST - SRC * DEST */
  94282. static readonly ALPHA_SUBTRACT: number;
  94283. /** Defines that alpha blending to SRC * DEST */
  94284. static readonly ALPHA_MULTIPLY: number;
  94285. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94286. static readonly ALPHA_MAXIMIZED: number;
  94287. /** Defines that alpha blending to SRC + DEST */
  94288. static readonly ALPHA_ONEONE: number;
  94289. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94290. static readonly ALPHA_PREMULTIPLIED: number;
  94291. /**
  94292. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94293. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94294. */
  94295. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94296. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94297. static readonly ALPHA_INTERPOLATE: number;
  94298. /**
  94299. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94300. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94301. */
  94302. static readonly ALPHA_SCREENMODE: number;
  94303. /** Defines that the ressource is not delayed*/
  94304. static readonly DELAYLOADSTATE_NONE: number;
  94305. /** Defines that the ressource was successfully delay loaded */
  94306. static readonly DELAYLOADSTATE_LOADED: number;
  94307. /** Defines that the ressource is currently delay loading */
  94308. static readonly DELAYLOADSTATE_LOADING: number;
  94309. /** Defines that the ressource is delayed and has not started loading */
  94310. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94311. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94312. static readonly NEVER: number;
  94313. /** 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 */
  94314. static readonly ALWAYS: number;
  94315. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94316. static readonly LESS: number;
  94317. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94318. static readonly EQUAL: number;
  94319. /** 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 */
  94320. static readonly LEQUAL: number;
  94321. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94322. static readonly GREATER: number;
  94323. /** 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 */
  94324. static readonly GEQUAL: number;
  94325. /** 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 */
  94326. static readonly NOTEQUAL: number;
  94327. /** Passed to stencilOperation to specify that stencil value must be kept */
  94328. static readonly KEEP: number;
  94329. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94330. static readonly REPLACE: number;
  94331. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94332. static readonly INCR: number;
  94333. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94334. static readonly DECR: number;
  94335. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94336. static readonly INVERT: number;
  94337. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94338. static readonly INCR_WRAP: number;
  94339. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94340. static readonly DECR_WRAP: number;
  94341. /** Texture is not repeating outside of 0..1 UVs */
  94342. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94343. /** Texture is repeating outside of 0..1 UVs */
  94344. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94345. /** Texture is repeating and mirrored */
  94346. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94347. /** ALPHA */
  94348. static readonly TEXTUREFORMAT_ALPHA: number;
  94349. /** LUMINANCE */
  94350. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94351. /** LUMINANCE_ALPHA */
  94352. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94353. /** RGB */
  94354. static readonly TEXTUREFORMAT_RGB: number;
  94355. /** RGBA */
  94356. static readonly TEXTUREFORMAT_RGBA: number;
  94357. /** RED */
  94358. static readonly TEXTUREFORMAT_RED: number;
  94359. /** RED (2nd reference) */
  94360. static readonly TEXTUREFORMAT_R: number;
  94361. /** RG */
  94362. static readonly TEXTUREFORMAT_RG: number;
  94363. /** RED_INTEGER */
  94364. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94365. /** RED_INTEGER (2nd reference) */
  94366. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94367. /** RG_INTEGER */
  94368. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94369. /** RGB_INTEGER */
  94370. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94371. /** RGBA_INTEGER */
  94372. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94373. /** UNSIGNED_BYTE */
  94374. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94375. /** UNSIGNED_BYTE (2nd reference) */
  94376. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94377. /** FLOAT */
  94378. static readonly TEXTURETYPE_FLOAT: number;
  94379. /** HALF_FLOAT */
  94380. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94381. /** BYTE */
  94382. static readonly TEXTURETYPE_BYTE: number;
  94383. /** SHORT */
  94384. static readonly TEXTURETYPE_SHORT: number;
  94385. /** UNSIGNED_SHORT */
  94386. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94387. /** INT */
  94388. static readonly TEXTURETYPE_INT: number;
  94389. /** UNSIGNED_INT */
  94390. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94391. /** UNSIGNED_SHORT_4_4_4_4 */
  94392. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94393. /** UNSIGNED_SHORT_5_5_5_1 */
  94394. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94395. /** UNSIGNED_SHORT_5_6_5 */
  94396. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94397. /** UNSIGNED_INT_2_10_10_10_REV */
  94398. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94399. /** UNSIGNED_INT_24_8 */
  94400. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94401. /** UNSIGNED_INT_10F_11F_11F_REV */
  94402. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94403. /** UNSIGNED_INT_5_9_9_9_REV */
  94404. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94405. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94406. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94407. /** nearest is mag = nearest and min = nearest and mip = linear */
  94408. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94409. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94410. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94411. /** Trilinear is mag = linear and min = linear and mip = linear */
  94412. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94413. /** nearest is mag = nearest and min = nearest and mip = linear */
  94414. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94415. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94416. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94417. /** Trilinear is mag = linear and min = linear and mip = linear */
  94418. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94419. /** mag = nearest and min = nearest and mip = nearest */
  94420. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94421. /** mag = nearest and min = linear and mip = nearest */
  94422. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94423. /** mag = nearest and min = linear and mip = linear */
  94424. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94425. /** mag = nearest and min = linear and mip = none */
  94426. static readonly TEXTURE_NEAREST_LINEAR: number;
  94427. /** mag = nearest and min = nearest and mip = none */
  94428. static readonly TEXTURE_NEAREST_NEAREST: number;
  94429. /** mag = linear and min = nearest and mip = nearest */
  94430. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94431. /** mag = linear and min = nearest and mip = linear */
  94432. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94433. /** mag = linear and min = linear and mip = none */
  94434. static readonly TEXTURE_LINEAR_LINEAR: number;
  94435. /** mag = linear and min = nearest and mip = none */
  94436. static readonly TEXTURE_LINEAR_NEAREST: number;
  94437. /** Explicit coordinates mode */
  94438. static readonly TEXTURE_EXPLICIT_MODE: number;
  94439. /** Spherical coordinates mode */
  94440. static readonly TEXTURE_SPHERICAL_MODE: number;
  94441. /** Planar coordinates mode */
  94442. static readonly TEXTURE_PLANAR_MODE: number;
  94443. /** Cubic coordinates mode */
  94444. static readonly TEXTURE_CUBIC_MODE: number;
  94445. /** Projection coordinates mode */
  94446. static readonly TEXTURE_PROJECTION_MODE: number;
  94447. /** Skybox coordinates mode */
  94448. static readonly TEXTURE_SKYBOX_MODE: number;
  94449. /** Inverse Cubic coordinates mode */
  94450. static readonly TEXTURE_INVCUBIC_MODE: number;
  94451. /** Equirectangular coordinates mode */
  94452. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94453. /** Equirectangular Fixed coordinates mode */
  94454. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94455. /** Equirectangular Fixed Mirrored coordinates mode */
  94456. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94457. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94458. static readonly SCALEMODE_FLOOR: number;
  94459. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94460. static readonly SCALEMODE_NEAREST: number;
  94461. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94462. static readonly SCALEMODE_CEILING: number;
  94463. /**
  94464. * Returns the current npm package of the sdk
  94465. */
  94466. static readonly NpmPackage: string;
  94467. /**
  94468. * Returns the current version of the framework
  94469. */
  94470. static readonly Version: string;
  94471. /**
  94472. * Returns a string describing the current engine
  94473. */
  94474. readonly description: string;
  94475. /**
  94476. * Gets or sets the epsilon value used by collision engine
  94477. */
  94478. static CollisionsEpsilon: number;
  94479. /**
  94480. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94481. */
  94482. static ShadersRepository: string;
  94483. /**
  94484. * Method called to create the default loading screen.
  94485. * This can be overriden in your own app.
  94486. * @param canvas The rendering canvas element
  94487. * @returns The loading screen
  94488. */
  94489. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94490. /**
  94491. * Method called to create the default rescale post process on each engine.
  94492. */
  94493. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94494. /** @hidden */
  94495. _shaderProcessor: IShaderProcessor;
  94496. /**
  94497. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94498. */
  94499. forcePOTTextures: boolean;
  94500. /**
  94501. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94502. */
  94503. isFullscreen: boolean;
  94504. /**
  94505. * Gets a boolean indicating if the pointer is currently locked
  94506. */
  94507. isPointerLock: boolean;
  94508. /**
  94509. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94510. */
  94511. cullBackFaces: boolean;
  94512. /**
  94513. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94514. */
  94515. renderEvenInBackground: boolean;
  94516. /**
  94517. * Gets or sets a boolean indicating that cache can be kept between frames
  94518. */
  94519. preventCacheWipeBetweenFrames: boolean;
  94520. /**
  94521. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94522. **/
  94523. enableOfflineSupport: boolean;
  94524. /**
  94525. * 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)
  94526. **/
  94527. disableManifestCheck: boolean;
  94528. /**
  94529. * Gets the list of created scenes
  94530. */
  94531. scenes: Scene[];
  94532. /**
  94533. * Event raised when a new scene is created
  94534. */
  94535. onNewSceneAddedObservable: Observable<Scene>;
  94536. /**
  94537. * Gets the list of created postprocesses
  94538. */
  94539. postProcesses: PostProcess[];
  94540. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94541. validateShaderPrograms: boolean;
  94542. /**
  94543. * Observable event triggered each time the rendering canvas is resized
  94544. */
  94545. onResizeObservable: Observable<Engine>;
  94546. /**
  94547. * Observable event triggered each time the canvas loses focus
  94548. */
  94549. onCanvasBlurObservable: Observable<Engine>;
  94550. /**
  94551. * Observable event triggered each time the canvas gains focus
  94552. */
  94553. onCanvasFocusObservable: Observable<Engine>;
  94554. /**
  94555. * Observable event triggered each time the canvas receives pointerout event
  94556. */
  94557. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94558. /**
  94559. * Observable event triggered before each texture is initialized
  94560. */
  94561. onBeforeTextureInitObservable: Observable<Texture>;
  94562. /**
  94563. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94564. */
  94565. disableUniformBuffers: boolean;
  94566. /** @hidden */
  94567. _uniformBuffers: UniformBuffer[];
  94568. /**
  94569. * Gets a boolean indicating that the engine supports uniform buffers
  94570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94571. */
  94572. readonly supportsUniformBuffers: boolean;
  94573. /**
  94574. * Observable raised when the engine begins a new frame
  94575. */
  94576. onBeginFrameObservable: Observable<Engine>;
  94577. /**
  94578. * If set, will be used to request the next animation frame for the render loop
  94579. */
  94580. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94581. /**
  94582. * Observable raised when the engine ends the current frame
  94583. */
  94584. onEndFrameObservable: Observable<Engine>;
  94585. /**
  94586. * Observable raised when the engine is about to compile a shader
  94587. */
  94588. onBeforeShaderCompilationObservable: Observable<Engine>;
  94589. /**
  94590. * Observable raised when the engine has jsut compiled a shader
  94591. */
  94592. onAfterShaderCompilationObservable: Observable<Engine>;
  94593. /** @hidden */
  94594. _gl: WebGLRenderingContext;
  94595. private _renderingCanvas;
  94596. private _windowIsBackground;
  94597. private _webGLVersion;
  94598. protected _highPrecisionShadersAllowed: boolean;
  94599. /** @hidden */
  94600. readonly _shouldUseHighPrecisionShader: boolean;
  94601. /**
  94602. * Gets a boolean indicating that only power of 2 textures are supported
  94603. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94604. */
  94605. readonly needPOTTextures: boolean;
  94606. /** @hidden */
  94607. _badOS: boolean;
  94608. /** @hidden */
  94609. _badDesktopOS: boolean;
  94610. /**
  94611. * Gets the audio engine
  94612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94613. * @ignorenaming
  94614. */
  94615. static audioEngine: IAudioEngine;
  94616. /**
  94617. * Default AudioEngine factory responsible of creating the Audio Engine.
  94618. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94619. */
  94620. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94621. /**
  94622. * Default offline support factory responsible of creating a tool used to store data locally.
  94623. * By default, this will create a Database object if the workload has been embedded.
  94624. */
  94625. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94626. private _onFocus;
  94627. private _onBlur;
  94628. private _onCanvasPointerOut;
  94629. private _onCanvasBlur;
  94630. private _onCanvasFocus;
  94631. private _onFullscreenChange;
  94632. private _onPointerLockChange;
  94633. private _hardwareScalingLevel;
  94634. /** @hidden */
  94635. _caps: EngineCapabilities;
  94636. private _pointerLockRequested;
  94637. private _isStencilEnable;
  94638. private _colorWrite;
  94639. private _loadingScreen;
  94640. /** @hidden */
  94641. _drawCalls: PerfCounter;
  94642. private _glVersion;
  94643. private _glRenderer;
  94644. private _glVendor;
  94645. private _videoTextureSupported;
  94646. private _renderingQueueLaunched;
  94647. private _activeRenderLoops;
  94648. private _deterministicLockstep;
  94649. private _lockstepMaxSteps;
  94650. /**
  94651. * Observable signaled when a context lost event is raised
  94652. */
  94653. onContextLostObservable: Observable<Engine>;
  94654. /**
  94655. * Observable signaled when a context restored event is raised
  94656. */
  94657. onContextRestoredObservable: Observable<Engine>;
  94658. private _onContextLost;
  94659. private _onContextRestored;
  94660. private _contextWasLost;
  94661. /** @hidden */
  94662. _doNotHandleContextLost: boolean;
  94663. /**
  94664. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94666. */
  94667. doNotHandleContextLost: boolean;
  94668. private _performanceMonitor;
  94669. private _fps;
  94670. private _deltaTime;
  94671. /**
  94672. * Turn this value on if you want to pause FPS computation when in background
  94673. */
  94674. disablePerformanceMonitorInBackground: boolean;
  94675. /**
  94676. * Gets the performance monitor attached to this engine
  94677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94678. */
  94679. readonly performanceMonitor: PerformanceMonitor;
  94680. /**
  94681. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94682. */
  94683. disableVertexArrayObjects: boolean;
  94684. /** @hidden */
  94685. protected _depthCullingState: _DepthCullingState;
  94686. /** @hidden */
  94687. protected _stencilState: _StencilState;
  94688. /** @hidden */
  94689. protected _alphaState: _AlphaState;
  94690. /** @hidden */
  94691. protected _alphaMode: number;
  94692. /** @hidden */
  94693. _internalTexturesCache: InternalTexture[];
  94694. /** @hidden */
  94695. protected _activeChannel: number;
  94696. private _currentTextureChannel;
  94697. /** @hidden */
  94698. protected _boundTexturesCache: {
  94699. [key: string]: Nullable<InternalTexture>;
  94700. };
  94701. /** @hidden */
  94702. protected _currentEffect: Nullable<Effect>;
  94703. /** @hidden */
  94704. protected _currentProgram: Nullable<WebGLProgram>;
  94705. private _compiledEffects;
  94706. private _vertexAttribArraysEnabled;
  94707. /** @hidden */
  94708. protected _cachedViewport: Nullable<IViewportLike>;
  94709. private _cachedVertexArrayObject;
  94710. /** @hidden */
  94711. protected _cachedVertexBuffers: any;
  94712. /** @hidden */
  94713. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94714. /** @hidden */
  94715. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94716. /** @hidden */
  94717. _currentRenderTarget: Nullable<InternalTexture>;
  94718. private _uintIndicesCurrentlySet;
  94719. private _currentBoundBuffer;
  94720. /** @hidden */
  94721. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94722. private _currentBufferPointers;
  94723. private _currentInstanceLocations;
  94724. private _currentInstanceBuffers;
  94725. private _textureUnits;
  94726. /** @hidden */
  94727. _workingCanvas: Nullable<HTMLCanvasElement>;
  94728. /** @hidden */
  94729. _workingContext: Nullable<CanvasRenderingContext2D>;
  94730. private _rescalePostProcess;
  94731. private _dummyFramebuffer;
  94732. private _externalData;
  94733. /** @hidden */
  94734. _bindedRenderFunction: any;
  94735. private _vaoRecordInProgress;
  94736. private _mustWipeVertexAttributes;
  94737. private _emptyTexture;
  94738. private _emptyCubeTexture;
  94739. private _emptyTexture3D;
  94740. /** @hidden */
  94741. _frameHandler: number;
  94742. private _nextFreeTextureSlots;
  94743. private _maxSimultaneousTextures;
  94744. private _activeRequests;
  94745. private _texturesSupported;
  94746. /** @hidden */
  94747. _textureFormatInUse: Nullable<string>;
  94748. /**
  94749. * Gets the list of texture formats supported
  94750. */
  94751. readonly texturesSupported: Array<string>;
  94752. /**
  94753. * Gets the list of texture formats in use
  94754. */
  94755. readonly textureFormatInUse: Nullable<string>;
  94756. /**
  94757. * Gets the current viewport
  94758. */
  94759. readonly currentViewport: Nullable<IViewportLike>;
  94760. /**
  94761. * Gets the default empty texture
  94762. */
  94763. readonly emptyTexture: InternalTexture;
  94764. /**
  94765. * Gets the default empty 3D texture
  94766. */
  94767. readonly emptyTexture3D: InternalTexture;
  94768. /**
  94769. * Gets the default empty cube texture
  94770. */
  94771. readonly emptyCubeTexture: InternalTexture;
  94772. /**
  94773. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94774. */
  94775. readonly premultipliedAlpha: boolean;
  94776. /**
  94777. * Creates a new engine
  94778. * @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
  94779. * @param antialias defines enable antialiasing (default: false)
  94780. * @param options defines further options to be sent to the getContext() function
  94781. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94782. */
  94783. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94784. /**
  94785. * Initializes a webVR display and starts listening to display change events
  94786. * The onVRDisplayChangedObservable will be notified upon these changes
  94787. * @returns The onVRDisplayChangedObservable
  94788. */
  94789. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94790. /** @hidden */
  94791. _prepareVRComponent(): void;
  94792. /** @hidden */
  94793. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94794. /** @hidden */
  94795. _submitVRFrame(): void;
  94796. /**
  94797. * Call this function to leave webVR mode
  94798. * Will do nothing if webVR is not supported or if there is no webVR device
  94799. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94800. */
  94801. disableVR(): void;
  94802. /**
  94803. * Gets a boolean indicating that the system is in VR mode and is presenting
  94804. * @returns true if VR mode is engaged
  94805. */
  94806. isVRPresenting(): boolean;
  94807. /** @hidden */
  94808. _requestVRFrame(): void;
  94809. private _disableTouchAction;
  94810. private _rebuildInternalTextures;
  94811. private _rebuildEffects;
  94812. /**
  94813. * Gets a boolean indicating if all created effects are ready
  94814. * @returns true if all effects are ready
  94815. */
  94816. areAllEffectsReady(): boolean;
  94817. private _rebuildBuffers;
  94818. private _initGLContext;
  94819. /**
  94820. * Gets version of the current webGL context
  94821. */
  94822. readonly webGLVersion: number;
  94823. /**
  94824. * Gets a string idenfifying the name of the class
  94825. * @returns "Engine" string
  94826. */
  94827. getClassName(): string;
  94828. /**
  94829. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94830. */
  94831. readonly isStencilEnable: boolean;
  94832. /** @hidden */
  94833. _prepareWorkingCanvas(): void;
  94834. /**
  94835. * Reset the texture cache to empty state
  94836. */
  94837. resetTextureCache(): void;
  94838. /**
  94839. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94841. * @returns true if engine is in deterministic lock step mode
  94842. */
  94843. isDeterministicLockStep(): boolean;
  94844. /**
  94845. * Gets the max steps when engine is running in deterministic lock step
  94846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94847. * @returns the max steps
  94848. */
  94849. getLockstepMaxSteps(): number;
  94850. /**
  94851. * Gets an object containing information about the current webGL context
  94852. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94853. */
  94854. getGlInfo(): {
  94855. vendor: string;
  94856. renderer: string;
  94857. version: string;
  94858. };
  94859. /**
  94860. * Gets current aspect ratio
  94861. * @param viewportOwner defines the camera to use to get the aspect ratio
  94862. * @param useScreen defines if screen size must be used (or the current render target if any)
  94863. * @returns a number defining the aspect ratio
  94864. */
  94865. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94866. /**
  94867. * Gets current screen aspect ratio
  94868. * @returns a number defining the aspect ratio
  94869. */
  94870. getScreenAspectRatio(): number;
  94871. /**
  94872. * Gets the current render width
  94873. * @param useScreen defines if screen size must be used (or the current render target if any)
  94874. * @returns a number defining the current render width
  94875. */
  94876. getRenderWidth(useScreen?: boolean): number;
  94877. /**
  94878. * Gets the current render height
  94879. * @param useScreen defines if screen size must be used (or the current render target if any)
  94880. * @returns a number defining the current render height
  94881. */
  94882. getRenderHeight(useScreen?: boolean): number;
  94883. /**
  94884. * Gets the HTML canvas attached with the current webGL context
  94885. * @returns a HTML canvas
  94886. */
  94887. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94888. /**
  94889. * Gets host window
  94890. * @returns the host window object
  94891. */
  94892. getHostWindow(): Window;
  94893. /**
  94894. * Gets host document
  94895. * @returns the host document object
  94896. */
  94897. getHostDocument(): Document;
  94898. /**
  94899. * Gets the client rect of the HTML canvas attached with the current webGL context
  94900. * @returns a client rectanglee
  94901. */
  94902. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94903. /**
  94904. * Defines the hardware scaling level.
  94905. * By default the hardware scaling level is computed from the window device ratio.
  94906. * 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.
  94907. * @param level defines the level to use
  94908. */
  94909. setHardwareScalingLevel(level: number): void;
  94910. /**
  94911. * Gets the current hardware scaling level.
  94912. * By default the hardware scaling level is computed from the window device ratio.
  94913. * 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.
  94914. * @returns a number indicating the current hardware scaling level
  94915. */
  94916. getHardwareScalingLevel(): number;
  94917. /**
  94918. * Gets the list of loaded textures
  94919. * @returns an array containing all loaded textures
  94920. */
  94921. getLoadedTexturesCache(): InternalTexture[];
  94922. /**
  94923. * Gets the object containing all engine capabilities
  94924. * @returns the EngineCapabilities object
  94925. */
  94926. getCaps(): EngineCapabilities;
  94927. /**
  94928. * Gets the current depth function
  94929. * @returns a number defining the depth function
  94930. */
  94931. getDepthFunction(): Nullable<number>;
  94932. /**
  94933. * Sets the current depth function
  94934. * @param depthFunc defines the function to use
  94935. */
  94936. setDepthFunction(depthFunc: number): void;
  94937. /**
  94938. * Sets the current depth function to GREATER
  94939. */
  94940. setDepthFunctionToGreater(): void;
  94941. /**
  94942. * Sets the current depth function to GEQUAL
  94943. */
  94944. setDepthFunctionToGreaterOrEqual(): void;
  94945. /**
  94946. * Sets the current depth function to LESS
  94947. */
  94948. setDepthFunctionToLess(): void;
  94949. private _cachedStencilBuffer;
  94950. private _cachedStencilFunction;
  94951. private _cachedStencilMask;
  94952. private _cachedStencilOperationPass;
  94953. private _cachedStencilOperationFail;
  94954. private _cachedStencilOperationDepthFail;
  94955. private _cachedStencilReference;
  94956. /**
  94957. * Caches the the state of the stencil buffer
  94958. */
  94959. cacheStencilState(): void;
  94960. /**
  94961. * Restores the state of the stencil buffer
  94962. */
  94963. restoreStencilState(): void;
  94964. /**
  94965. * Sets the current depth function to LEQUAL
  94966. */
  94967. setDepthFunctionToLessOrEqual(): void;
  94968. /**
  94969. * Gets a boolean indicating if stencil buffer is enabled
  94970. * @returns the current stencil buffer state
  94971. */
  94972. getStencilBuffer(): boolean;
  94973. /**
  94974. * Enable or disable the stencil buffer
  94975. * @param enable defines if the stencil buffer must be enabled or disabled
  94976. */
  94977. setStencilBuffer(enable: boolean): void;
  94978. /**
  94979. * Gets the current stencil mask
  94980. * @returns a number defining the new stencil mask to use
  94981. */
  94982. getStencilMask(): number;
  94983. /**
  94984. * Sets the current stencil mask
  94985. * @param mask defines the new stencil mask to use
  94986. */
  94987. setStencilMask(mask: number): void;
  94988. /**
  94989. * Gets the current stencil function
  94990. * @returns a number defining the stencil function to use
  94991. */
  94992. getStencilFunction(): number;
  94993. /**
  94994. * Gets the current stencil reference value
  94995. * @returns a number defining the stencil reference value to use
  94996. */
  94997. getStencilFunctionReference(): number;
  94998. /**
  94999. * Gets the current stencil mask
  95000. * @returns a number defining the stencil mask to use
  95001. */
  95002. getStencilFunctionMask(): number;
  95003. /**
  95004. * Sets the current stencil function
  95005. * @param stencilFunc defines the new stencil function to use
  95006. */
  95007. setStencilFunction(stencilFunc: number): void;
  95008. /**
  95009. * Sets the current stencil reference
  95010. * @param reference defines the new stencil reference to use
  95011. */
  95012. setStencilFunctionReference(reference: number): void;
  95013. /**
  95014. * Sets the current stencil mask
  95015. * @param mask defines the new stencil mask to use
  95016. */
  95017. setStencilFunctionMask(mask: number): void;
  95018. /**
  95019. * Gets the current stencil operation when stencil fails
  95020. * @returns a number defining stencil operation to use when stencil fails
  95021. */
  95022. getStencilOperationFail(): number;
  95023. /**
  95024. * Gets the current stencil operation when depth fails
  95025. * @returns a number defining stencil operation to use when depth fails
  95026. */
  95027. getStencilOperationDepthFail(): number;
  95028. /**
  95029. * Gets the current stencil operation when stencil passes
  95030. * @returns a number defining stencil operation to use when stencil passes
  95031. */
  95032. getStencilOperationPass(): number;
  95033. /**
  95034. * Sets the stencil operation to use when stencil fails
  95035. * @param operation defines the stencil operation to use when stencil fails
  95036. */
  95037. setStencilOperationFail(operation: number): void;
  95038. /**
  95039. * Sets the stencil operation to use when depth fails
  95040. * @param operation defines the stencil operation to use when depth fails
  95041. */
  95042. setStencilOperationDepthFail(operation: number): void;
  95043. /**
  95044. * Sets the stencil operation to use when stencil passes
  95045. * @param operation defines the stencil operation to use when stencil passes
  95046. */
  95047. setStencilOperationPass(operation: number): void;
  95048. /**
  95049. * Sets a boolean indicating if the dithering state is enabled or disabled
  95050. * @param value defines the dithering state
  95051. */
  95052. setDitheringState(value: boolean): void;
  95053. /**
  95054. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95055. * @param value defines the rasterizer state
  95056. */
  95057. setRasterizerState(value: boolean): void;
  95058. /**
  95059. * stop executing a render loop function and remove it from the execution array
  95060. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95061. */
  95062. stopRenderLoop(renderFunction?: () => void): void;
  95063. /** @hidden */
  95064. _renderLoop(): void;
  95065. /**
  95066. * Register and execute a render loop. The engine can have more than one render function
  95067. * @param renderFunction defines the function to continuously execute
  95068. */
  95069. runRenderLoop(renderFunction: () => void): void;
  95070. /**
  95071. * Toggle full screen mode
  95072. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95073. */
  95074. switchFullscreen(requestPointerLock: boolean): void;
  95075. /**
  95076. * Enters full screen mode
  95077. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95078. */
  95079. enterFullscreen(requestPointerLock: boolean): void;
  95080. /**
  95081. * Exits full screen mode
  95082. */
  95083. exitFullscreen(): void;
  95084. /**
  95085. * Enters Pointerlock mode
  95086. */
  95087. enterPointerlock(): void;
  95088. /**
  95089. * Exits Pointerlock mode
  95090. */
  95091. exitPointerlock(): void;
  95092. /**
  95093. * Clear the current render buffer or the current render target (if any is set up)
  95094. * @param color defines the color to use
  95095. * @param backBuffer defines if the back buffer must be cleared
  95096. * @param depth defines if the depth buffer must be cleared
  95097. * @param stencil defines if the stencil buffer must be cleared
  95098. */
  95099. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95100. /**
  95101. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95102. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95103. * @param y defines the y-coordinate of the corner of the clear rectangle
  95104. * @param width defines the width of the clear rectangle
  95105. * @param height defines the height of the clear rectangle
  95106. * @param clearColor defines the clear color
  95107. */
  95108. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95109. /**
  95110. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95111. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95112. * @param y defines the y-coordinate of the corner of the clear rectangle
  95113. * @param width defines the width of the clear rectangle
  95114. * @param height defines the height of the clear rectangle
  95115. */
  95116. enableScissor(x: number, y: number, width: number, height: number): void;
  95117. /**
  95118. * Disable previously set scissor test rectangle
  95119. */
  95120. disableScissor(): void;
  95121. private _viewportCached;
  95122. /** @hidden */
  95123. _viewport(x: number, y: number, width: number, height: number): void;
  95124. /**
  95125. * Set the WebGL's viewport
  95126. * @param viewport defines the viewport element to be used
  95127. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95128. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95129. */
  95130. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95131. /**
  95132. * Directly set the WebGL Viewport
  95133. * @param x defines the x coordinate of the viewport (in screen space)
  95134. * @param y defines the y coordinate of the viewport (in screen space)
  95135. * @param width defines the width of the viewport (in screen space)
  95136. * @param height defines the height of the viewport (in screen space)
  95137. * @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
  95138. */
  95139. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95140. /**
  95141. * Begin a new frame
  95142. */
  95143. beginFrame(): void;
  95144. /**
  95145. * Enf the current frame
  95146. */
  95147. endFrame(): void;
  95148. /**
  95149. * Resize the view according to the canvas' size
  95150. */
  95151. resize(): void;
  95152. /**
  95153. * Force a specific size of the canvas
  95154. * @param width defines the new canvas' width
  95155. * @param height defines the new canvas' height
  95156. */
  95157. setSize(width: number, height: number): void;
  95158. /**
  95159. * Binds the frame buffer to the specified texture.
  95160. * @param texture The texture to render to or null for the default canvas
  95161. * @param faceIndex The face of the texture to render to in case of cube texture
  95162. * @param requiredWidth The width of the target to render to
  95163. * @param requiredHeight The height of the target to render to
  95164. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95165. * @param depthStencilTexture The depth stencil texture to use to render
  95166. * @param lodLevel defines le lod level to bind to the frame buffer
  95167. */
  95168. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95169. /** @hidden */
  95170. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95171. /**
  95172. * Unbind the current render target texture from the webGL context
  95173. * @param texture defines the render target texture to unbind
  95174. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95175. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95176. */
  95177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95178. /**
  95179. * Force the mipmap generation for the given render target texture
  95180. * @param texture defines the render target texture to use
  95181. */
  95182. generateMipMapsForCubemap(texture: InternalTexture): void;
  95183. /**
  95184. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95185. */
  95186. flushFramebuffer(): void;
  95187. /**
  95188. * Unbind the current render target and bind the default framebuffer
  95189. */
  95190. restoreDefaultFramebuffer(): void;
  95191. /**
  95192. * Create an uniform buffer
  95193. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95194. * @param elements defines the content of the uniform buffer
  95195. * @returns the webGL uniform buffer
  95196. */
  95197. createUniformBuffer(elements: FloatArray): DataBuffer;
  95198. /**
  95199. * Create a dynamic uniform buffer
  95200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95201. * @param elements defines the content of the uniform buffer
  95202. * @returns the webGL uniform buffer
  95203. */
  95204. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95205. /**
  95206. * Update an existing uniform buffer
  95207. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95208. * @param uniformBuffer defines the target uniform buffer
  95209. * @param elements defines the content to update
  95210. * @param offset defines the offset in the uniform buffer where update should start
  95211. * @param count defines the size of the data to update
  95212. */
  95213. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95214. private _resetVertexBufferBinding;
  95215. /**
  95216. * Creates a vertex buffer
  95217. * @param data the data for the vertex buffer
  95218. * @returns the new WebGL static buffer
  95219. */
  95220. createVertexBuffer(data: DataArray): DataBuffer;
  95221. /**
  95222. * Creates a dynamic vertex buffer
  95223. * @param data the data for the dynamic vertex buffer
  95224. * @returns the new WebGL dynamic buffer
  95225. */
  95226. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95227. /**
  95228. * Update a dynamic index buffer
  95229. * @param indexBuffer defines the target index buffer
  95230. * @param indices defines the data to update
  95231. * @param offset defines the offset in the target index buffer where update should start
  95232. */
  95233. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95234. /**
  95235. * Updates a dynamic vertex buffer.
  95236. * @param vertexBuffer the vertex buffer to update
  95237. * @param data the data used to update the vertex buffer
  95238. * @param byteOffset the byte offset of the data
  95239. * @param byteLength the byte length of the data
  95240. */
  95241. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95242. private _resetIndexBufferBinding;
  95243. /**
  95244. * Creates a new index buffer
  95245. * @param indices defines the content of the index buffer
  95246. * @param updatable defines if the index buffer must be updatable
  95247. * @returns a new webGL buffer
  95248. */
  95249. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95250. /**
  95251. * Bind a webGL buffer to the webGL context
  95252. * @param buffer defines the buffer to bind
  95253. */
  95254. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95255. /**
  95256. * Bind an uniform buffer to the current webGL context
  95257. * @param buffer defines the buffer to bind
  95258. */
  95259. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95260. /**
  95261. * Bind a buffer to the current webGL context at a given location
  95262. * @param buffer defines the buffer to bind
  95263. * @param location defines the index where to bind the buffer
  95264. */
  95265. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95266. /**
  95267. * Bind a specific block at a given index in a specific shader program
  95268. * @param pipelineContext defines the pipeline context to use
  95269. * @param blockName defines the block name
  95270. * @param index defines the index where to bind the block
  95271. */
  95272. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95273. private bindIndexBuffer;
  95274. private bindBuffer;
  95275. /**
  95276. * update the bound buffer with the given data
  95277. * @param data defines the data to update
  95278. */
  95279. updateArrayBuffer(data: Float32Array): void;
  95280. private _vertexAttribPointer;
  95281. private _bindIndexBufferWithCache;
  95282. private _bindVertexBuffersAttributes;
  95283. /**
  95284. * Records a vertex array object
  95285. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95286. * @param vertexBuffers defines the list of vertex buffers to store
  95287. * @param indexBuffer defines the index buffer to store
  95288. * @param effect defines the effect to store
  95289. * @returns the new vertex array object
  95290. */
  95291. recordVertexArrayObject(vertexBuffers: {
  95292. [key: string]: VertexBuffer;
  95293. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95294. /**
  95295. * Bind a specific vertex array object
  95296. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95297. * @param vertexArrayObject defines the vertex array object to bind
  95298. * @param indexBuffer defines the index buffer to bind
  95299. */
  95300. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95301. /**
  95302. * Bind webGl buffers directly to the webGL context
  95303. * @param vertexBuffer defines the vertex buffer to bind
  95304. * @param indexBuffer defines the index buffer to bind
  95305. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95306. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95307. * @param effect defines the effect associated with the vertex buffer
  95308. */
  95309. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95310. private _unbindVertexArrayObject;
  95311. /**
  95312. * Bind a list of vertex buffers to the webGL context
  95313. * @param vertexBuffers defines the list of vertex buffers to bind
  95314. * @param indexBuffer defines the index buffer to bind
  95315. * @param effect defines the effect associated with the vertex buffers
  95316. */
  95317. bindBuffers(vertexBuffers: {
  95318. [key: string]: Nullable<VertexBuffer>;
  95319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95320. /**
  95321. * Unbind all instance attributes
  95322. */
  95323. unbindInstanceAttributes(): void;
  95324. /**
  95325. * Release and free the memory of a vertex array object
  95326. * @param vao defines the vertex array object to delete
  95327. */
  95328. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95329. /** @hidden */
  95330. _releaseBuffer(buffer: DataBuffer): boolean;
  95331. /**
  95332. * Creates a webGL buffer to use with instanciation
  95333. * @param capacity defines the size of the buffer
  95334. * @returns the webGL buffer
  95335. */
  95336. createInstancesBuffer(capacity: number): DataBuffer;
  95337. /**
  95338. * Delete a webGL buffer used with instanciation
  95339. * @param buffer defines the webGL buffer to delete
  95340. */
  95341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95342. /**
  95343. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95344. * @param instancesBuffer defines the webGL buffer to update and bind
  95345. * @param data defines the data to store in the buffer
  95346. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95347. */
  95348. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95349. /**
  95350. * Apply all cached states (depth, culling, stencil and alpha)
  95351. */
  95352. applyStates(): void;
  95353. /**
  95354. * Send a draw order
  95355. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95356. * @param indexStart defines the starting index
  95357. * @param indexCount defines the number of index to draw
  95358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95359. */
  95360. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95361. /**
  95362. * Draw a list of points
  95363. * @param verticesStart defines the index of first vertex to draw
  95364. * @param verticesCount defines the count of vertices to draw
  95365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95366. */
  95367. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95368. /**
  95369. * Draw a list of unindexed primitives
  95370. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95371. * @param verticesStart defines the index of first vertex to draw
  95372. * @param verticesCount defines the count of vertices to draw
  95373. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95374. */
  95375. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95376. /**
  95377. * Draw a list of indexed primitives
  95378. * @param fillMode defines the primitive to use
  95379. * @param indexStart defines the starting index
  95380. * @param indexCount defines the number of index to draw
  95381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95382. */
  95383. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95384. /**
  95385. * Draw a list of unindexed primitives
  95386. * @param fillMode defines the primitive to use
  95387. * @param verticesStart defines the index of first vertex to draw
  95388. * @param verticesCount defines the count of vertices to draw
  95389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95390. */
  95391. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95392. private _drawMode;
  95393. /** @hidden */
  95394. _releaseEffect(effect: Effect): void;
  95395. /** @hidden */
  95396. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95397. /**
  95398. * Create a new effect (used to store vertex/fragment shaders)
  95399. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95400. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95401. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95402. * @param samplers defines an array of string used to represent textures
  95403. * @param defines defines the string containing the defines to use to compile the shaders
  95404. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95405. * @param onCompiled defines a function to call when the effect creation is successful
  95406. * @param onError defines a function to call when the effect creation has failed
  95407. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95408. * @returns the new Effect
  95409. */
  95410. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  95411. private _compileShader;
  95412. private _compileRawShader;
  95413. /**
  95414. * Directly creates a webGL program
  95415. * @param pipelineContext defines the pipeline context to attach to
  95416. * @param vertexCode defines the vertex shader code to use
  95417. * @param fragmentCode defines the fragment shader code to use
  95418. * @param context defines the webGL context to use (if not set, the current one will be used)
  95419. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95420. * @returns the new webGL program
  95421. */
  95422. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95423. /**
  95424. * Creates a webGL program
  95425. * @param pipelineContext defines the pipeline context to attach to
  95426. * @param vertexCode defines the vertex shader code to use
  95427. * @param fragmentCode defines the fragment shader code to use
  95428. * @param defines defines the string containing the defines to use to compile the shaders
  95429. * @param context defines the webGL context to use (if not set, the current one will be used)
  95430. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95431. * @returns the new webGL program
  95432. */
  95433. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95434. /**
  95435. * Creates a new pipeline context
  95436. * @returns the new pipeline
  95437. */
  95438. createPipelineContext(): WebGLPipelineContext;
  95439. private _createShaderProgram;
  95440. private _finalizePipelineContext;
  95441. /** @hidden */
  95442. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95443. /** @hidden */
  95444. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95445. /** @hidden */
  95446. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95447. /**
  95448. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95449. * @param pipelineContext defines the pipeline context to use
  95450. * @param uniformsNames defines the list of uniform names
  95451. * @returns an array of webGL uniform locations
  95452. */
  95453. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95454. /**
  95455. * Gets the lsit of active attributes for a given webGL program
  95456. * @param pipelineContext defines the pipeline context to use
  95457. * @param attributesNames defines the list of attribute names to get
  95458. * @returns an array of indices indicating the offset of each attribute
  95459. */
  95460. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95461. /**
  95462. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95463. * @param effect defines the effect to activate
  95464. */
  95465. enableEffect(effect: Nullable<Effect>): void;
  95466. /**
  95467. * Set the value of an uniform to an array of int32
  95468. * @param uniform defines the webGL uniform location where to store the value
  95469. * @param array defines the array of int32 to store
  95470. */
  95471. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95472. /**
  95473. * Set the value of an uniform to an array of int32 (stored as vec2)
  95474. * @param uniform defines the webGL uniform location where to store the value
  95475. * @param array defines the array of int32 to store
  95476. */
  95477. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95478. /**
  95479. * Set the value of an uniform to an array of int32 (stored as vec3)
  95480. * @param uniform defines the webGL uniform location where to store the value
  95481. * @param array defines the array of int32 to store
  95482. */
  95483. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95484. /**
  95485. * Set the value of an uniform to an array of int32 (stored as vec4)
  95486. * @param uniform defines the webGL uniform location where to store the value
  95487. * @param array defines the array of int32 to store
  95488. */
  95489. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95490. /**
  95491. * Set the value of an uniform to an array of float32
  95492. * @param uniform defines the webGL uniform location where to store the value
  95493. * @param array defines the array of float32 to store
  95494. */
  95495. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95496. /**
  95497. * Set the value of an uniform to an array of float32 (stored as vec2)
  95498. * @param uniform defines the webGL uniform location where to store the value
  95499. * @param array defines the array of float32 to store
  95500. */
  95501. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95502. /**
  95503. * Set the value of an uniform to an array of float32 (stored as vec3)
  95504. * @param uniform defines the webGL uniform location where to store the value
  95505. * @param array defines the array of float32 to store
  95506. */
  95507. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95508. /**
  95509. * Set the value of an uniform to an array of float32 (stored as vec4)
  95510. * @param uniform defines the webGL uniform location where to store the value
  95511. * @param array defines the array of float32 to store
  95512. */
  95513. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95514. /**
  95515. * Set the value of an uniform to an array of number
  95516. * @param uniform defines the webGL uniform location where to store the value
  95517. * @param array defines the array of number to store
  95518. */
  95519. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95520. /**
  95521. * Set the value of an uniform to an array of number (stored as vec2)
  95522. * @param uniform defines the webGL uniform location where to store the value
  95523. * @param array defines the array of number to store
  95524. */
  95525. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95526. /**
  95527. * Set the value of an uniform to an array of number (stored as vec3)
  95528. * @param uniform defines the webGL uniform location where to store the value
  95529. * @param array defines the array of number to store
  95530. */
  95531. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95532. /**
  95533. * Set the value of an uniform to an array of number (stored as vec4)
  95534. * @param uniform defines the webGL uniform location where to store the value
  95535. * @param array defines the array of number to store
  95536. */
  95537. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95538. /**
  95539. * Set the value of an uniform to an array of float32 (stored as matrices)
  95540. * @param uniform defines the webGL uniform location where to store the value
  95541. * @param matrices defines the array of float32 to store
  95542. */
  95543. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95544. /**
  95545. * Set the value of an uniform to a matrix (3x3)
  95546. * @param uniform defines the webGL uniform location where to store the value
  95547. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95548. */
  95549. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95550. /**
  95551. * Set the value of an uniform to a matrix (2x2)
  95552. * @param uniform defines the webGL uniform location where to store the value
  95553. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95554. */
  95555. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95556. /**
  95557. * Set the value of an uniform to a number (int)
  95558. * @param uniform defines the webGL uniform location where to store the value
  95559. * @param value defines the int number to store
  95560. */
  95561. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95562. /**
  95563. * Set the value of an uniform to a number (float)
  95564. * @param uniform defines the webGL uniform location where to store the value
  95565. * @param value defines the float number to store
  95566. */
  95567. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95568. /**
  95569. * Set the value of an uniform to a vec2
  95570. * @param uniform defines the webGL uniform location where to store the value
  95571. * @param x defines the 1st component of the value
  95572. * @param y defines the 2nd component of the value
  95573. */
  95574. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95575. /**
  95576. * Set the value of an uniform to a vec3
  95577. * @param uniform defines the webGL uniform location where to store the value
  95578. * @param x defines the 1st component of the value
  95579. * @param y defines the 2nd component of the value
  95580. * @param z defines the 3rd component of the value
  95581. */
  95582. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95583. /**
  95584. * Set the value of an uniform to a boolean
  95585. * @param uniform defines the webGL uniform location where to store the value
  95586. * @param bool defines the boolean to store
  95587. */
  95588. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95589. /**
  95590. * Set the value of an uniform to a vec4
  95591. * @param uniform defines the webGL uniform location where to store the value
  95592. * @param x defines the 1st component of the value
  95593. * @param y defines the 2nd component of the value
  95594. * @param z defines the 3rd component of the value
  95595. * @param w defines the 4th component of the value
  95596. */
  95597. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95598. /**
  95599. * Sets a Color4 on a uniform variable
  95600. * @param uniform defines the uniform location
  95601. * @param color4 defines the value to be set
  95602. */
  95603. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95604. /**
  95605. * Set various states to the webGL context
  95606. * @param culling defines backface culling state
  95607. * @param zOffset defines the value to apply to zOffset (0 by default)
  95608. * @param force defines if states must be applied even if cache is up to date
  95609. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95610. */
  95611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95612. /**
  95613. * Set the z offset to apply to current rendering
  95614. * @param value defines the offset to apply
  95615. */
  95616. setZOffset(value: number): void;
  95617. /**
  95618. * Gets the current value of the zOffset
  95619. * @returns the current zOffset state
  95620. */
  95621. getZOffset(): number;
  95622. /**
  95623. * Enable or disable depth buffering
  95624. * @param enable defines the state to set
  95625. */
  95626. setDepthBuffer(enable: boolean): void;
  95627. /**
  95628. * Gets a boolean indicating if depth writing is enabled
  95629. * @returns the current depth writing state
  95630. */
  95631. getDepthWrite(): boolean;
  95632. /**
  95633. * Enable or disable depth writing
  95634. * @param enable defines the state to set
  95635. */
  95636. setDepthWrite(enable: boolean): void;
  95637. /**
  95638. * Enable or disable color writing
  95639. * @param enable defines the state to set
  95640. */
  95641. setColorWrite(enable: boolean): void;
  95642. /**
  95643. * Gets a boolean indicating if color writing is enabled
  95644. * @returns the current color writing state
  95645. */
  95646. getColorWrite(): boolean;
  95647. /**
  95648. * Sets alpha constants used by some alpha blending modes
  95649. * @param r defines the red component
  95650. * @param g defines the green component
  95651. * @param b defines the blue component
  95652. * @param a defines the alpha component
  95653. */
  95654. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95655. /**
  95656. * Sets the current alpha mode
  95657. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95658. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95660. */
  95661. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95662. /**
  95663. * Gets the current alpha mode
  95664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95665. * @returns the current alpha mode
  95666. */
  95667. getAlphaMode(): number;
  95668. /**
  95669. * Clears the list of texture accessible through engine.
  95670. * This can help preventing texture load conflict due to name collision.
  95671. */
  95672. clearInternalTexturesCache(): void;
  95673. /**
  95674. * Force the entire cache to be cleared
  95675. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95676. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95677. */
  95678. wipeCaches(bruteForce?: boolean): void;
  95679. /**
  95680. * Set the compressed texture format to use, based on the formats you have, and the formats
  95681. * supported by the hardware / browser.
  95682. *
  95683. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95684. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95685. * to API arguments needed to compressed textures. This puts the burden on the container
  95686. * generator to house the arcane code for determining these for current & future formats.
  95687. *
  95688. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95689. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95690. *
  95691. * Note: The result of this call is not taken into account when a texture is base64.
  95692. *
  95693. * @param formatsAvailable defines the list of those format families you have created
  95694. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95695. *
  95696. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95697. * @returns The extension selected.
  95698. */
  95699. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95700. /** @hidden */
  95701. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95702. min: number;
  95703. mag: number;
  95704. };
  95705. /** @hidden */
  95706. _createTexture(): WebGLTexture;
  95707. /**
  95708. * Usually called from Texture.ts.
  95709. * Passed information to create a WebGLTexture
  95710. * @param urlArg defines a value which contains one of the following:
  95711. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95712. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95713. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95715. * @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)
  95716. * @param scene needed for loading to the correct scene
  95717. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95718. * @param onLoad optional callback to be called upon successful completion
  95719. * @param onError optional callback to be called upon failure
  95720. * @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
  95721. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95722. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95723. * @param forcedExtension defines the extension to use to pick the right loader
  95724. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95725. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95726. */
  95727. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  95728. /**
  95729. * @hidden
  95730. * Rescales a texture
  95731. * @param source input texutre
  95732. * @param destination destination texture
  95733. * @param scene scene to use to render the resize
  95734. * @param internalFormat format to use when resizing
  95735. * @param onComplete callback to be called when resize has completed
  95736. */
  95737. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95738. private _unpackFlipYCached;
  95739. /**
  95740. * In case you are sharing the context with other applications, it might
  95741. * be interested to not cache the unpack flip y state to ensure a consistent
  95742. * value would be set.
  95743. */
  95744. enableUnpackFlipYCached: boolean;
  95745. /** @hidden */
  95746. _unpackFlipY(value: boolean): void;
  95747. /** @hidden */
  95748. _getUnpackAlignement(): number;
  95749. /**
  95750. * Creates a dynamic texture
  95751. * @param width defines the width of the texture
  95752. * @param height defines the height of the texture
  95753. * @param generateMipMaps defines if the engine should generate the mip levels
  95754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95755. * @returns the dynamic texture inside an InternalTexture
  95756. */
  95757. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95758. /**
  95759. * Update the sampling mode of a given texture
  95760. * @param samplingMode defines the required sampling mode
  95761. * @param texture defines the texture to update
  95762. */
  95763. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95764. /**
  95765. * Update the content of a dynamic texture
  95766. * @param texture defines the texture to update
  95767. * @param canvas defines the canvas containing the source
  95768. * @param invertY defines if data must be stored with Y axis inverted
  95769. * @param premulAlpha defines if alpha is stored as premultiplied
  95770. * @param format defines the format of the data
  95771. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95772. */
  95773. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95774. /**
  95775. * Update a video texture
  95776. * @param texture defines the texture to update
  95777. * @param video defines the video element to use
  95778. * @param invertY defines if data must be stored with Y axis inverted
  95779. */
  95780. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95781. /**
  95782. * Updates a depth texture Comparison Mode and Function.
  95783. * If the comparison Function is equal to 0, the mode will be set to none.
  95784. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95785. * @param texture The texture to set the comparison function for
  95786. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95787. */
  95788. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95789. /** @hidden */
  95790. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95791. width: number;
  95792. height: number;
  95793. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95794. /**
  95795. * Creates a depth stencil texture.
  95796. * This is only available in WebGL 2 or with the depth texture extension available.
  95797. * @param size The size of face edge in the texture.
  95798. * @param options The options defining the texture.
  95799. * @returns The texture
  95800. */
  95801. createDepthStencilTexture(size: number | {
  95802. width: number;
  95803. height: number;
  95804. }, options: DepthTextureCreationOptions): InternalTexture;
  95805. /**
  95806. * Creates a depth stencil texture.
  95807. * This is only available in WebGL 2 or with the depth texture extension available.
  95808. * @param size The size of face edge in the texture.
  95809. * @param options The options defining the texture.
  95810. * @returns The texture
  95811. */
  95812. private _createDepthStencilTexture;
  95813. /**
  95814. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95815. * @param renderTarget The render target to set the frame buffer for
  95816. */
  95817. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95818. /**
  95819. * Creates a new render target texture
  95820. * @param size defines the size of the texture
  95821. * @param options defines the options used to create the texture
  95822. * @returns a new render target texture stored in an InternalTexture
  95823. */
  95824. createRenderTargetTexture(size: number | {
  95825. width: number;
  95826. height: number;
  95827. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95828. /** @hidden */
  95829. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95830. /**
  95831. * Updates the sample count of a render target texture
  95832. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95833. * @param texture defines the texture to update
  95834. * @param samples defines the sample count to set
  95835. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95836. */
  95837. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95838. /** @hidden */
  95839. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95840. /** @hidden */
  95841. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95842. /** @hidden */
  95843. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95844. /** @hidden */
  95845. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95846. /**
  95847. * @hidden
  95848. */
  95849. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95850. private _prepareWebGLTextureContinuation;
  95851. private _prepareWebGLTexture;
  95852. /** @hidden */
  95853. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95854. /** @hidden */
  95855. _releaseFramebufferObjects(texture: InternalTexture): void;
  95856. /** @hidden */
  95857. _releaseTexture(texture: InternalTexture): void;
  95858. private setProgram;
  95859. private _boundUniforms;
  95860. /**
  95861. * Binds an effect to the webGL context
  95862. * @param effect defines the effect to bind
  95863. */
  95864. bindSamplers(effect: Effect): void;
  95865. private _activateCurrentTexture;
  95866. /** @hidden */
  95867. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95868. /** @hidden */
  95869. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95870. /**
  95871. * Sets a texture to the webGL context from a postprocess
  95872. * @param channel defines the channel to use
  95873. * @param postProcess defines the source postprocess
  95874. */
  95875. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95876. /**
  95877. * Binds the output of the passed in post process to the texture channel specified
  95878. * @param channel The channel the texture should be bound to
  95879. * @param postProcess The post process which's output should be bound
  95880. */
  95881. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95882. /**
  95883. * Unbind all textures from the webGL context
  95884. */
  95885. unbindAllTextures(): void;
  95886. /**
  95887. * Sets a texture to the according uniform.
  95888. * @param channel The texture channel
  95889. * @param uniform The uniform to set
  95890. * @param texture The texture to apply
  95891. */
  95892. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95893. /**
  95894. * Sets a depth stencil texture from a render target to the according uniform.
  95895. * @param channel The texture channel
  95896. * @param uniform The uniform to set
  95897. * @param texture The render target texture containing the depth stencil texture to apply
  95898. */
  95899. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95900. private _bindSamplerUniformToChannel;
  95901. private _getTextureWrapMode;
  95902. private _setTexture;
  95903. /**
  95904. * Sets an array of texture to the webGL context
  95905. * @param channel defines the channel where the texture array must be set
  95906. * @param uniform defines the associated uniform location
  95907. * @param textures defines the array of textures to bind
  95908. */
  95909. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95910. /** @hidden */
  95911. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95912. private _setTextureParameterFloat;
  95913. private _setTextureParameterInteger;
  95914. /**
  95915. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95916. * @param x defines the x coordinate of the rectangle where pixels must be read
  95917. * @param y defines the y coordinate of the rectangle where pixels must be read
  95918. * @param width defines the width of the rectangle where pixels must be read
  95919. * @param height defines the height of the rectangle where pixels must be read
  95920. * @returns a Uint8Array containing RGBA colors
  95921. */
  95922. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95923. /**
  95924. * Add an externaly attached data from its key.
  95925. * This method call will fail and return false, if such key already exists.
  95926. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95927. * @param key the unique key that identifies the data
  95928. * @param data the data object to associate to the key for this Engine instance
  95929. * @return true if no such key were already present and the data was added successfully, false otherwise
  95930. */
  95931. addExternalData<T>(key: string, data: T): boolean;
  95932. /**
  95933. * Get an externaly attached data from its key
  95934. * @param key the unique key that identifies the data
  95935. * @return the associated data, if present (can be null), or undefined if not present
  95936. */
  95937. getExternalData<T>(key: string): T;
  95938. /**
  95939. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95940. * @param key the unique key that identifies the data
  95941. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95942. * @return the associated data, can be null if the factory returned null.
  95943. */
  95944. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95945. /**
  95946. * Remove an externaly attached data from the Engine instance
  95947. * @param key the unique key that identifies the data
  95948. * @return true if the data was successfully removed, false if it doesn't exist
  95949. */
  95950. removeExternalData(key: string): boolean;
  95951. /**
  95952. * Unbind all vertex attributes from the webGL context
  95953. */
  95954. unbindAllAttributes(): void;
  95955. /**
  95956. * 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
  95957. */
  95958. releaseEffects(): void;
  95959. /**
  95960. * Dispose and release all associated resources
  95961. */
  95962. dispose(): void;
  95963. /**
  95964. * Display the loading screen
  95965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95966. */
  95967. displayLoadingUI(): void;
  95968. /**
  95969. * Hide the loading screen
  95970. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95971. */
  95972. hideLoadingUI(): void;
  95973. /**
  95974. * Gets the current loading screen object
  95975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95976. */
  95977. /**
  95978. * Sets the current loading screen object
  95979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95980. */
  95981. loadingScreen: ILoadingScreen;
  95982. /**
  95983. * Sets the current loading screen text
  95984. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95985. */
  95986. loadingUIText: string;
  95987. /**
  95988. * Sets the current loading screen background color
  95989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95990. */
  95991. loadingUIBackgroundColor: string;
  95992. /**
  95993. * Attach a new callback raised when context lost event is fired
  95994. * @param callback defines the callback to call
  95995. */
  95996. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95997. /**
  95998. * Attach a new callback raised when context restored event is fired
  95999. * @param callback defines the callback to call
  96000. */
  96001. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96002. /**
  96003. * Gets the source code of the vertex shader associated with a specific webGL program
  96004. * @param program defines the program to use
  96005. * @returns a string containing the source code of the vertex shader associated with the program
  96006. */
  96007. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96008. /**
  96009. * Gets the source code of the fragment shader associated with a specific webGL program
  96010. * @param program defines the program to use
  96011. * @returns a string containing the source code of the fragment shader associated with the program
  96012. */
  96013. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96014. /**
  96015. * Get the current error code of the webGL context
  96016. * @returns the error code
  96017. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96018. */
  96019. getError(): number;
  96020. /**
  96021. * Gets the current framerate
  96022. * @returns a number representing the framerate
  96023. */
  96024. getFps(): number;
  96025. /**
  96026. * Gets the time spent between current and previous frame
  96027. * @returns a number representing the delta time in ms
  96028. */
  96029. getDeltaTime(): number;
  96030. private _measureFps;
  96031. /** @hidden */
  96032. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96033. private _canRenderToFloatFramebuffer;
  96034. private _canRenderToHalfFloatFramebuffer;
  96035. private _canRenderToFramebuffer;
  96036. /** @hidden */
  96037. _getWebGLTextureType(type: number): number;
  96038. /** @hidden */
  96039. _getInternalFormat(format: number): number;
  96040. /** @hidden */
  96041. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96042. /** @hidden */
  96043. _getRGBAMultiSampleBufferFormat(type: number): number;
  96044. /** @hidden */
  96045. _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;
  96046. /** @hidden */
  96047. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96048. /**
  96049. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96050. * @returns true if the engine can be created
  96051. * @ignorenaming
  96052. */
  96053. static isSupported(): boolean;
  96054. /**
  96055. * Find the next highest power of two.
  96056. * @param x Number to start search from.
  96057. * @return Next highest power of two.
  96058. */
  96059. static CeilingPOT(x: number): number;
  96060. /**
  96061. * Find the next lowest power of two.
  96062. * @param x Number to start search from.
  96063. * @return Next lowest power of two.
  96064. */
  96065. static FloorPOT(x: number): number;
  96066. /**
  96067. * Find the nearest power of two.
  96068. * @param x Number to start search from.
  96069. * @return Next nearest power of two.
  96070. */
  96071. static NearestPOT(x: number): number;
  96072. /**
  96073. * Get the closest exponent of two
  96074. * @param value defines the value to approximate
  96075. * @param max defines the maximum value to return
  96076. * @param mode defines how to define the closest value
  96077. * @returns closest exponent of two of the given value
  96078. */
  96079. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96080. /**
  96081. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96082. * @param func - the function to be called
  96083. * @param requester - the object that will request the next frame. Falls back to window.
  96084. * @returns frame number
  96085. */
  96086. static QueueNewFrame(func: () => void, requester?: any): number;
  96087. /**
  96088. * Ask the browser to promote the current element to pointerlock mode
  96089. * @param element defines the DOM element to promote
  96090. */
  96091. static _RequestPointerlock(element: HTMLElement): void;
  96092. /**
  96093. * Asks the browser to exit pointerlock mode
  96094. */
  96095. static _ExitPointerlock(): void;
  96096. /**
  96097. * Ask the browser to promote the current element to fullscreen rendering mode
  96098. * @param element defines the DOM element to promote
  96099. */
  96100. static _RequestFullscreen(element: HTMLElement): void;
  96101. /**
  96102. * Asks the browser to exit fullscreen mode
  96103. */
  96104. static _ExitFullscreen(): void;
  96105. }
  96106. }
  96107. declare module BABYLON {
  96108. /**
  96109. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96110. * during the life time of the application.
  96111. */
  96112. export class EngineStore {
  96113. /** Gets the list of created engines */
  96114. static Instances: Engine[];
  96115. /** @hidden */
  96116. static _LastCreatedScene: Nullable<Scene>;
  96117. /**
  96118. * Gets the latest created engine
  96119. */
  96120. static readonly LastCreatedEngine: Nullable<Engine>;
  96121. /**
  96122. * Gets the latest created scene
  96123. */
  96124. static readonly LastCreatedScene: Nullable<Scene>;
  96125. /**
  96126. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96127. * @ignorenaming
  96128. */
  96129. static UseFallbackTexture: boolean;
  96130. /**
  96131. * Texture content used if a texture cannot loaded
  96132. * @ignorenaming
  96133. */
  96134. static FallbackTexture: string;
  96135. }
  96136. }
  96137. declare module BABYLON {
  96138. /**
  96139. * Helper class that provides a small promise polyfill
  96140. */
  96141. export class PromisePolyfill {
  96142. /**
  96143. * Static function used to check if the polyfill is required
  96144. * If this is the case then the function will inject the polyfill to window.Promise
  96145. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96146. */
  96147. static Apply(force?: boolean): void;
  96148. }
  96149. }
  96150. declare module BABYLON {
  96151. /**
  96152. * Interface for screenshot methods with describe argument called `size` as object with options
  96153. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96154. */
  96155. export interface IScreenshotSize {
  96156. /**
  96157. * number in pixels for canvas height
  96158. */
  96159. height?: number;
  96160. /**
  96161. * multiplier allowing render at a higher or lower resolution
  96162. * If value is defined then height and width will be ignored and taken from camera
  96163. */
  96164. precision?: number;
  96165. /**
  96166. * number in pixels for canvas width
  96167. */
  96168. width?: number;
  96169. }
  96170. }
  96171. declare module BABYLON {
  96172. interface IColor4Like {
  96173. r: float;
  96174. g: float;
  96175. b: float;
  96176. a: float;
  96177. }
  96178. /**
  96179. * Class containing a set of static utilities functions
  96180. */
  96181. export class Tools {
  96182. /**
  96183. * Gets or sets the base URL to use to load assets
  96184. */
  96185. static BaseUrl: string;
  96186. /**
  96187. * Enable/Disable Custom HTTP Request Headers globally.
  96188. * default = false
  96189. * @see CustomRequestHeaders
  96190. */
  96191. static UseCustomRequestHeaders: boolean;
  96192. /**
  96193. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96194. * i.e. when loading files, where the server/service expects an Authorization header
  96195. */
  96196. static CustomRequestHeaders: {
  96197. [key: string]: string;
  96198. };
  96199. /**
  96200. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96201. */
  96202. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96203. /**
  96204. * Default behaviour for cors in the application.
  96205. * It can be a string if the expected behavior is identical in the entire app.
  96206. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96207. */
  96208. static CorsBehavior: string | ((url: string | string[]) => string);
  96209. /**
  96210. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96211. * @ignorenaming
  96212. */
  96213. static UseFallbackTexture: boolean;
  96214. /**
  96215. * Use this object to register external classes like custom textures or material
  96216. * to allow the laoders to instantiate them
  96217. */
  96218. static RegisteredExternalClasses: {
  96219. [key: string]: Object;
  96220. };
  96221. /**
  96222. * Texture content used if a texture cannot loaded
  96223. * @ignorenaming
  96224. */
  96225. static fallbackTexture: string;
  96226. /**
  96227. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96228. * @param u defines the coordinate on X axis
  96229. * @param v defines the coordinate on Y axis
  96230. * @param width defines the width of the source data
  96231. * @param height defines the height of the source data
  96232. * @param pixels defines the source byte array
  96233. * @param color defines the output color
  96234. */
  96235. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96236. /**
  96237. * Interpolates between a and b via alpha
  96238. * @param a The lower value (returned when alpha = 0)
  96239. * @param b The upper value (returned when alpha = 1)
  96240. * @param alpha The interpolation-factor
  96241. * @return The mixed value
  96242. */
  96243. static Mix(a: number, b: number, alpha: number): number;
  96244. /**
  96245. * Tries to instantiate a new object from a given class name
  96246. * @param className defines the class name to instantiate
  96247. * @returns the new object or null if the system was not able to do the instantiation
  96248. */
  96249. static Instantiate(className: string): any;
  96250. /**
  96251. * Provides a slice function that will work even on IE
  96252. * @param data defines the array to slice
  96253. * @param start defines the start of the data (optional)
  96254. * @param end defines the end of the data (optional)
  96255. * @returns the new sliced array
  96256. */
  96257. static Slice<T>(data: T, start?: number, end?: number): T;
  96258. /**
  96259. * Polyfill for setImmediate
  96260. * @param action defines the action to execute after the current execution block
  96261. */
  96262. static SetImmediate(action: () => void): void;
  96263. /**
  96264. * Function indicating if a number is an exponent of 2
  96265. * @param value defines the value to test
  96266. * @returns true if the value is an exponent of 2
  96267. */
  96268. static IsExponentOfTwo(value: number): boolean;
  96269. private static _tmpFloatArray;
  96270. /**
  96271. * Returns the nearest 32-bit single precision float representation of a Number
  96272. * @param value A Number. If the parameter is of a different type, it will get converted
  96273. * to a number or to NaN if it cannot be converted
  96274. * @returns number
  96275. */
  96276. static FloatRound(value: number): number;
  96277. /**
  96278. * Extracts the filename from a path
  96279. * @param path defines the path to use
  96280. * @returns the filename
  96281. */
  96282. static GetFilename(path: string): string;
  96283. /**
  96284. * Extracts the "folder" part of a path (everything before the filename).
  96285. * @param uri The URI to extract the info from
  96286. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96287. * @returns The "folder" part of the path
  96288. */
  96289. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96290. /**
  96291. * Extracts text content from a DOM element hierarchy
  96292. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96293. */
  96294. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96295. /**
  96296. * Convert an angle in radians to degrees
  96297. * @param angle defines the angle to convert
  96298. * @returns the angle in degrees
  96299. */
  96300. static ToDegrees(angle: number): number;
  96301. /**
  96302. * Convert an angle in degrees to radians
  96303. * @param angle defines the angle to convert
  96304. * @returns the angle in radians
  96305. */
  96306. static ToRadians(angle: number): number;
  96307. /**
  96308. * Encode a buffer to a base64 string
  96309. * @param buffer defines the buffer to encode
  96310. * @returns the encoded string
  96311. */
  96312. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96313. /**
  96314. * Returns an array if obj is not an array
  96315. * @param obj defines the object to evaluate as an array
  96316. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96317. * @returns either obj directly if obj is an array or a new array containing obj
  96318. */
  96319. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96320. /**
  96321. * Gets the pointer prefix to use
  96322. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96323. */
  96324. static GetPointerPrefix(): string;
  96325. /**
  96326. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96327. * @param url define the url we are trying
  96328. * @param element define the dom element where to configure the cors policy
  96329. */
  96330. static SetCorsBehavior(url: string | string[], element: {
  96331. crossOrigin: string | null;
  96332. }): void;
  96333. /**
  96334. * Removes unwanted characters from an url
  96335. * @param url defines the url to clean
  96336. * @returns the cleaned url
  96337. */
  96338. static CleanUrl(url: string): string;
  96339. /**
  96340. * Gets or sets a function used to pre-process url before using them to load assets
  96341. */
  96342. static PreprocessUrl: (url: string) => string;
  96343. /**
  96344. * Loads an image as an HTMLImageElement.
  96345. * @param input url string, ArrayBuffer, or Blob to load
  96346. * @param onLoad callback called when the image successfully loads
  96347. * @param onError callback called when the image fails to load
  96348. * @param offlineProvider offline provider for caching
  96349. * @returns the HTMLImageElement of the loaded image
  96350. */
  96351. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96352. /**
  96353. * Loads a file
  96354. * @param url url string, ArrayBuffer, or Blob to load
  96355. * @param onSuccess callback called when the file successfully loads
  96356. * @param onProgress callback called while file is loading (if the server supports this mode)
  96357. * @param offlineProvider defines the offline provider for caching
  96358. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96359. * @param onError callback called when the file fails to load
  96360. * @returns a file request object
  96361. */
  96362. 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;
  96363. /**
  96364. * Loads a file from a url
  96365. * @param url the file url to load
  96366. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96367. */
  96368. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96369. /**
  96370. * Load a script (identified by an url). When the url returns, the
  96371. * content of this file is added into a new script element, attached to the DOM (body element)
  96372. * @param scriptUrl defines the url of the script to laod
  96373. * @param onSuccess defines the callback called when the script is loaded
  96374. * @param onError defines the callback to call if an error occurs
  96375. * @param scriptId defines the id of the script element
  96376. */
  96377. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96378. /**
  96379. * Load an asynchronous script (identified by an url). When the url returns, the
  96380. * content of this file is added into a new script element, attached to the DOM (body element)
  96381. * @param scriptUrl defines the url of the script to laod
  96382. * @param scriptId defines the id of the script element
  96383. * @returns a promise request object
  96384. */
  96385. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96386. /**
  96387. * Loads a file from a blob
  96388. * @param fileToLoad defines the blob to use
  96389. * @param callback defines the callback to call when data is loaded
  96390. * @param progressCallback defines the callback to call during loading process
  96391. * @returns a file request object
  96392. */
  96393. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96394. /**
  96395. * Loads a file
  96396. * @param fileToLoad defines the file to load
  96397. * @param callback defines the callback to call when data is loaded
  96398. * @param progressCallBack defines the callback to call during loading process
  96399. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96400. * @returns a file request object
  96401. */
  96402. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96403. /**
  96404. * Creates a data url from a given string content
  96405. * @param content defines the content to convert
  96406. * @returns the new data url link
  96407. */
  96408. static FileAsURL(content: string): string;
  96409. /**
  96410. * Format the given number to a specific decimal format
  96411. * @param value defines the number to format
  96412. * @param decimals defines the number of decimals to use
  96413. * @returns the formatted string
  96414. */
  96415. static Format(value: number, decimals?: number): string;
  96416. /**
  96417. * Tries to copy an object by duplicating every property
  96418. * @param source defines the source object
  96419. * @param destination defines the target object
  96420. * @param doNotCopyList defines a list of properties to avoid
  96421. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96422. */
  96423. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96424. /**
  96425. * Gets a boolean indicating if the given object has no own property
  96426. * @param obj defines the object to test
  96427. * @returns true if object has no own property
  96428. */
  96429. static IsEmpty(obj: any): boolean;
  96430. /**
  96431. * Function used to register events at window level
  96432. * @param windowElement defines the Window object to use
  96433. * @param events defines the events to register
  96434. */
  96435. static RegisterTopRootEvents(windowElement: Window, events: {
  96436. name: string;
  96437. handler: Nullable<(e: FocusEvent) => any>;
  96438. }[]): void;
  96439. /**
  96440. * Function used to unregister events from window level
  96441. * @param windowElement defines the Window object to use
  96442. * @param events defines the events to unregister
  96443. */
  96444. static UnregisterTopRootEvents(windowElement: Window, events: {
  96445. name: string;
  96446. handler: Nullable<(e: FocusEvent) => any>;
  96447. }[]): void;
  96448. /**
  96449. * @ignore
  96450. */
  96451. static _ScreenshotCanvas: HTMLCanvasElement;
  96452. /**
  96453. * Dumps the current bound framebuffer
  96454. * @param width defines the rendering width
  96455. * @param height defines the rendering height
  96456. * @param engine defines the hosting engine
  96457. * @param successCallback defines the callback triggered once the data are available
  96458. * @param mimeType defines the mime type of the result
  96459. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96460. */
  96461. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96462. /**
  96463. * Converts the canvas data to blob.
  96464. * This acts as a polyfill for browsers not supporting the to blob function.
  96465. * @param canvas Defines the canvas to extract the data from
  96466. * @param successCallback Defines the callback triggered once the data are available
  96467. * @param mimeType Defines the mime type of the result
  96468. */
  96469. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96470. /**
  96471. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96472. * @param successCallback defines the callback triggered once the data are available
  96473. * @param mimeType defines the mime type of the result
  96474. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96475. */
  96476. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96477. /**
  96478. * Downloads a blob in the browser
  96479. * @param blob defines the blob to download
  96480. * @param fileName defines the name of the downloaded file
  96481. */
  96482. static Download(blob: Blob, fileName: string): void;
  96483. /**
  96484. * Captures a screenshot of the current rendering
  96485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96486. * @param engine defines the rendering engine
  96487. * @param camera defines the source camera
  96488. * @param size This parameter can be set to a single number or to an object with the
  96489. * following (optional) properties: precision, width, height. If a single number is passed,
  96490. * it will be used for both width and height. If an object is passed, the screenshot size
  96491. * will be derived from the parameters. The precision property is a multiplier allowing
  96492. * rendering at a higher or lower resolution
  96493. * @param successCallback defines the callback receives a single parameter which contains the
  96494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96495. * src parameter of an <img> to display it
  96496. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96497. * Check your browser for supported MIME types
  96498. */
  96499. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96500. /**
  96501. * Captures a screenshot of the current rendering
  96502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96503. * @param engine defines the rendering engine
  96504. * @param camera defines the source camera
  96505. * @param size This parameter can be set to a single number or to an object with the
  96506. * following (optional) properties: precision, width, height. If a single number is passed,
  96507. * it will be used for both width and height. If an object is passed, the screenshot size
  96508. * will be derived from the parameters. The precision property is a multiplier allowing
  96509. * rendering at a higher or lower resolution
  96510. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96511. * Check your browser for supported MIME types
  96512. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96513. * to the src parameter of an <img> to display it
  96514. */
  96515. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96516. /**
  96517. * Generates an image screenshot from the specified camera.
  96518. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96519. * @param engine The engine to use for rendering
  96520. * @param camera The camera to use for rendering
  96521. * @param size This parameter can be set to a single number or to an object with the
  96522. * following (optional) properties: precision, width, height. If a single number is passed,
  96523. * it will be used for both width and height. If an object is passed, the screenshot size
  96524. * will be derived from the parameters. The precision property is a multiplier allowing
  96525. * rendering at a higher or lower resolution
  96526. * @param successCallback The callback receives a single parameter which contains the
  96527. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96528. * src parameter of an <img> to display it
  96529. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96530. * Check your browser for supported MIME types
  96531. * @param samples Texture samples (default: 1)
  96532. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96533. * @param fileName A name for for the downloaded file.
  96534. */
  96535. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96536. /**
  96537. * Generates an image screenshot from the specified camera.
  96538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96539. * @param engine The engine to use for rendering
  96540. * @param camera The camera to use for rendering
  96541. * @param size This parameter can be set to a single number or to an object with the
  96542. * following (optional) properties: precision, width, height. If a single number is passed,
  96543. * it will be used for both width and height. If an object is passed, the screenshot size
  96544. * will be derived from the parameters. The precision property is a multiplier allowing
  96545. * rendering at a higher or lower resolution
  96546. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96547. * Check your browser for supported MIME types
  96548. * @param samples Texture samples (default: 1)
  96549. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96550. * @param fileName A name for for the downloaded file.
  96551. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96552. * to the src parameter of an <img> to display it
  96553. */
  96554. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96555. /**
  96556. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96557. * Be aware Math.random() could cause collisions, but:
  96558. * "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"
  96559. * @returns a pseudo random id
  96560. */
  96561. static RandomId(): string;
  96562. /**
  96563. * Test if the given uri is a base64 string
  96564. * @param uri The uri to test
  96565. * @return True if the uri is a base64 string or false otherwise
  96566. */
  96567. static IsBase64(uri: string): boolean;
  96568. /**
  96569. * Decode the given base64 uri.
  96570. * @param uri The uri to decode
  96571. * @return The decoded base64 data.
  96572. */
  96573. static DecodeBase64(uri: string): ArrayBuffer;
  96574. /**
  96575. * Gets the absolute url.
  96576. * @param url the input url
  96577. * @return the absolute url
  96578. */
  96579. static GetAbsoluteUrl(url: string): string;
  96580. /**
  96581. * No log
  96582. */
  96583. static readonly NoneLogLevel: number;
  96584. /**
  96585. * Only message logs
  96586. */
  96587. static readonly MessageLogLevel: number;
  96588. /**
  96589. * Only warning logs
  96590. */
  96591. static readonly WarningLogLevel: number;
  96592. /**
  96593. * Only error logs
  96594. */
  96595. static readonly ErrorLogLevel: number;
  96596. /**
  96597. * All logs
  96598. */
  96599. static readonly AllLogLevel: number;
  96600. /**
  96601. * Gets a value indicating the number of loading errors
  96602. * @ignorenaming
  96603. */
  96604. static readonly errorsCount: number;
  96605. /**
  96606. * Callback called when a new log is added
  96607. */
  96608. static OnNewCacheEntry: (entry: string) => void;
  96609. /**
  96610. * Log a message to the console
  96611. * @param message defines the message to log
  96612. */
  96613. static Log(message: string): void;
  96614. /**
  96615. * Write a warning message to the console
  96616. * @param message defines the message to log
  96617. */
  96618. static Warn(message: string): void;
  96619. /**
  96620. * Write an error message to the console
  96621. * @param message defines the message to log
  96622. */
  96623. static Error(message: string): void;
  96624. /**
  96625. * Gets current log cache (list of logs)
  96626. */
  96627. static readonly LogCache: string;
  96628. /**
  96629. * Clears the log cache
  96630. */
  96631. static ClearLogCache(): void;
  96632. /**
  96633. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96634. */
  96635. static LogLevels: number;
  96636. /**
  96637. * Checks if the window object exists
  96638. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96639. */
  96640. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96641. /**
  96642. * No performance log
  96643. */
  96644. static readonly PerformanceNoneLogLevel: number;
  96645. /**
  96646. * Use user marks to log performance
  96647. */
  96648. static readonly PerformanceUserMarkLogLevel: number;
  96649. /**
  96650. * Log performance to the console
  96651. */
  96652. static readonly PerformanceConsoleLogLevel: number;
  96653. private static _performance;
  96654. /**
  96655. * Sets the current performance log level
  96656. */
  96657. static PerformanceLogLevel: number;
  96658. private static _StartPerformanceCounterDisabled;
  96659. private static _EndPerformanceCounterDisabled;
  96660. private static _StartUserMark;
  96661. private static _EndUserMark;
  96662. private static _StartPerformanceConsole;
  96663. private static _EndPerformanceConsole;
  96664. /**
  96665. * Starts a performance counter
  96666. */
  96667. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96668. /**
  96669. * Ends a specific performance coutner
  96670. */
  96671. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96672. /**
  96673. * Gets either window.performance.now() if supported or Date.now() else
  96674. */
  96675. static readonly Now: number;
  96676. /**
  96677. * This method will return the name of the class used to create the instance of the given object.
  96678. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96679. * @param object the object to get the class name from
  96680. * @param isType defines if the object is actually a type
  96681. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96682. */
  96683. static GetClassName(object: any, isType?: boolean): string;
  96684. /**
  96685. * Gets the first element of an array satisfying a given predicate
  96686. * @param array defines the array to browse
  96687. * @param predicate defines the predicate to use
  96688. * @returns null if not found or the element
  96689. */
  96690. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96691. /**
  96692. * This method will return the name of the full name of the class, including its owning module (if any).
  96693. * 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).
  96694. * @param object the object to get the class name from
  96695. * @param isType defines if the object is actually a type
  96696. * @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.
  96697. * @ignorenaming
  96698. */
  96699. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96700. /**
  96701. * Returns a promise that resolves after the given amount of time.
  96702. * @param delay Number of milliseconds to delay
  96703. * @returns Promise that resolves after the given amount of time
  96704. */
  96705. static DelayAsync(delay: number): Promise<void>;
  96706. }
  96707. /**
  96708. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96709. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96710. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96711. * @param name The name of the class, case should be preserved
  96712. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96713. */
  96714. export function className(name: string, module?: string): (target: Object) => void;
  96715. /**
  96716. * An implementation of a loop for asynchronous functions.
  96717. */
  96718. export class AsyncLoop {
  96719. /**
  96720. * Defines the number of iterations for the loop
  96721. */
  96722. iterations: number;
  96723. /**
  96724. * Defines the current index of the loop.
  96725. */
  96726. index: number;
  96727. private _done;
  96728. private _fn;
  96729. private _successCallback;
  96730. /**
  96731. * Constructor.
  96732. * @param iterations the number of iterations.
  96733. * @param func the function to run each iteration
  96734. * @param successCallback the callback that will be called upon succesful execution
  96735. * @param offset starting offset.
  96736. */
  96737. constructor(
  96738. /**
  96739. * Defines the number of iterations for the loop
  96740. */
  96741. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96742. /**
  96743. * Execute the next iteration. Must be called after the last iteration was finished.
  96744. */
  96745. executeNext(): void;
  96746. /**
  96747. * Break the loop and run the success callback.
  96748. */
  96749. breakLoop(): void;
  96750. /**
  96751. * Create and run an async loop.
  96752. * @param iterations the number of iterations.
  96753. * @param fn the function to run each iteration
  96754. * @param successCallback the callback that will be called upon succesful execution
  96755. * @param offset starting offset.
  96756. * @returns the created async loop object
  96757. */
  96758. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96759. /**
  96760. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96761. * @param iterations total number of iterations
  96762. * @param syncedIterations number of synchronous iterations in each async iteration.
  96763. * @param fn the function to call each iteration.
  96764. * @param callback a success call back that will be called when iterating stops.
  96765. * @param breakFunction a break condition (optional)
  96766. * @param timeout timeout settings for the setTimeout function. default - 0.
  96767. * @returns the created async loop object
  96768. */
  96769. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96770. }
  96771. }
  96772. declare module BABYLON {
  96773. /** @hidden */
  96774. export interface ICollisionCoordinator {
  96775. createCollider(): Collider;
  96776. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96777. init(scene: Scene): void;
  96778. }
  96779. /** @hidden */
  96780. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96781. private _scene;
  96782. private _scaledPosition;
  96783. private _scaledVelocity;
  96784. private _finalPosition;
  96785. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96786. createCollider(): Collider;
  96787. init(scene: Scene): void;
  96788. private _collideWithWorld;
  96789. }
  96790. }
  96791. declare module BABYLON {
  96792. /**
  96793. * Class used to manage all inputs for the scene.
  96794. */
  96795. export class InputManager {
  96796. /** The distance in pixel that you have to move to prevent some events */
  96797. static DragMovementThreshold: number;
  96798. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96799. static LongPressDelay: number;
  96800. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96801. static DoubleClickDelay: number;
  96802. /** If you need to check double click without raising a single click at first click, enable this flag */
  96803. static ExclusiveDoubleClickMode: boolean;
  96804. private _wheelEventName;
  96805. private _onPointerMove;
  96806. private _onPointerDown;
  96807. private _onPointerUp;
  96808. private _initClickEvent;
  96809. private _initActionManager;
  96810. private _delayedSimpleClick;
  96811. private _delayedSimpleClickTimeout;
  96812. private _previousDelayedSimpleClickTimeout;
  96813. private _meshPickProceed;
  96814. private _previousButtonPressed;
  96815. private _currentPickResult;
  96816. private _previousPickResult;
  96817. private _totalPointersPressed;
  96818. private _doubleClickOccured;
  96819. private _pointerOverMesh;
  96820. private _pickedDownMesh;
  96821. private _pickedUpMesh;
  96822. private _pointerX;
  96823. private _pointerY;
  96824. private _unTranslatedPointerX;
  96825. private _unTranslatedPointerY;
  96826. private _startingPointerPosition;
  96827. private _previousStartingPointerPosition;
  96828. private _startingPointerTime;
  96829. private _previousStartingPointerTime;
  96830. private _pointerCaptures;
  96831. private _onKeyDown;
  96832. private _onKeyUp;
  96833. private _onCanvasFocusObserver;
  96834. private _onCanvasBlurObserver;
  96835. private _scene;
  96836. /**
  96837. * Creates a new InputManager
  96838. * @param scene defines the hosting scene
  96839. */
  96840. constructor(scene: Scene);
  96841. /**
  96842. * Gets the mesh that is currently under the pointer
  96843. */
  96844. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96845. /**
  96846. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96847. */
  96848. readonly unTranslatedPointer: Vector2;
  96849. /**
  96850. * Gets or sets the current on-screen X position of the pointer
  96851. */
  96852. pointerX: number;
  96853. /**
  96854. * Gets or sets the current on-screen Y position of the pointer
  96855. */
  96856. pointerY: number;
  96857. private _updatePointerPosition;
  96858. private _processPointerMove;
  96859. private _setRayOnPointerInfo;
  96860. private _checkPrePointerObservable;
  96861. /**
  96862. * Use this method to simulate a pointer move on a mesh
  96863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96866. */
  96867. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96868. /**
  96869. * Use this method to simulate a pointer down on a mesh
  96870. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96871. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96872. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96873. */
  96874. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96875. private _processPointerDown;
  96876. /** @hidden */
  96877. _isPointerSwiping(): boolean;
  96878. /**
  96879. * Use this method to simulate a pointer up on a mesh
  96880. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96881. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96882. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96883. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96884. */
  96885. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96886. private _processPointerUp;
  96887. /**
  96888. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96889. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96890. * @returns true if the pointer was captured
  96891. */
  96892. isPointerCaptured(pointerId?: number): boolean;
  96893. /**
  96894. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96895. * @param attachUp defines if you want to attach events to pointerup
  96896. * @param attachDown defines if you want to attach events to pointerdown
  96897. * @param attachMove defines if you want to attach events to pointermove
  96898. */
  96899. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96900. /**
  96901. * Detaches all event handlers
  96902. */
  96903. detachControl(): void;
  96904. /**
  96905. * Force the value of meshUnderPointer
  96906. * @param mesh defines the mesh to use
  96907. */
  96908. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96909. /**
  96910. * Gets the mesh under the pointer
  96911. * @returns a Mesh or null if no mesh is under the pointer
  96912. */
  96913. getPointerOverMesh(): Nullable<AbstractMesh>;
  96914. }
  96915. }
  96916. declare module BABYLON {
  96917. /**
  96918. * Helper class used to generate session unique ID
  96919. */
  96920. export class UniqueIdGenerator {
  96921. private static _UniqueIdCounter;
  96922. /**
  96923. * Gets an unique (relatively to the current scene) Id
  96924. */
  96925. static readonly UniqueId: number;
  96926. }
  96927. }
  96928. declare module BABYLON {
  96929. /**
  96930. * This class defines the direct association between an animation and a target
  96931. */
  96932. export class TargetedAnimation {
  96933. /**
  96934. * Animation to perform
  96935. */
  96936. animation: Animation;
  96937. /**
  96938. * Target to animate
  96939. */
  96940. target: any;
  96941. /**
  96942. * Serialize the object
  96943. * @returns the JSON object representing the current entity
  96944. */
  96945. serialize(): any;
  96946. }
  96947. /**
  96948. * Use this class to create coordinated animations on multiple targets
  96949. */
  96950. export class AnimationGroup implements IDisposable {
  96951. /** The name of the animation group */
  96952. name: string;
  96953. private _scene;
  96954. private _targetedAnimations;
  96955. private _animatables;
  96956. private _from;
  96957. private _to;
  96958. private _isStarted;
  96959. private _isPaused;
  96960. private _speedRatio;
  96961. private _loopAnimation;
  96962. /**
  96963. * Gets or sets the unique id of the node
  96964. */
  96965. uniqueId: number;
  96966. /**
  96967. * This observable will notify when one animation have ended
  96968. */
  96969. onAnimationEndObservable: Observable<TargetedAnimation>;
  96970. /**
  96971. * Observer raised when one animation loops
  96972. */
  96973. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96974. /**
  96975. * This observable will notify when all animations have ended.
  96976. */
  96977. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96978. /**
  96979. * This observable will notify when all animations have paused.
  96980. */
  96981. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96982. /**
  96983. * This observable will notify when all animations are playing.
  96984. */
  96985. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96986. /**
  96987. * Gets the first frame
  96988. */
  96989. readonly from: number;
  96990. /**
  96991. * Gets the last frame
  96992. */
  96993. readonly to: number;
  96994. /**
  96995. * Define if the animations are started
  96996. */
  96997. readonly isStarted: boolean;
  96998. /**
  96999. * Gets a value indicating that the current group is playing
  97000. */
  97001. readonly isPlaying: boolean;
  97002. /**
  97003. * Gets or sets the speed ratio to use for all animations
  97004. */
  97005. /**
  97006. * Gets or sets the speed ratio to use for all animations
  97007. */
  97008. speedRatio: number;
  97009. /**
  97010. * Gets or sets if all animations should loop or not
  97011. */
  97012. loopAnimation: boolean;
  97013. /**
  97014. * Gets the targeted animations for this animation group
  97015. */
  97016. readonly targetedAnimations: Array<TargetedAnimation>;
  97017. /**
  97018. * returning the list of animatables controlled by this animation group.
  97019. */
  97020. readonly animatables: Array<Animatable>;
  97021. /**
  97022. * Instantiates a new Animation Group.
  97023. * This helps managing several animations at once.
  97024. * @see http://doc.babylonjs.com/how_to/group
  97025. * @param name Defines the name of the group
  97026. * @param scene Defines the scene the group belongs to
  97027. */
  97028. constructor(
  97029. /** The name of the animation group */
  97030. name: string, scene?: Nullable<Scene>);
  97031. /**
  97032. * Add an animation (with its target) in the group
  97033. * @param animation defines the animation we want to add
  97034. * @param target defines the target of the animation
  97035. * @returns the TargetedAnimation object
  97036. */
  97037. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97038. /**
  97039. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97040. * It can add constant keys at begin or end
  97041. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97042. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97043. * @returns the animation group
  97044. */
  97045. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97046. /**
  97047. * Start all animations on given targets
  97048. * @param loop defines if animations must loop
  97049. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97050. * @param from defines the from key (optional)
  97051. * @param to defines the to key (optional)
  97052. * @returns the current animation group
  97053. */
  97054. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97055. /**
  97056. * Pause all animations
  97057. * @returns the animation group
  97058. */
  97059. pause(): AnimationGroup;
  97060. /**
  97061. * Play all animations to initial state
  97062. * This function will start() the animations if they were not started or will restart() them if they were paused
  97063. * @param loop defines if animations must loop
  97064. * @returns the animation group
  97065. */
  97066. play(loop?: boolean): AnimationGroup;
  97067. /**
  97068. * Reset all animations to initial state
  97069. * @returns the animation group
  97070. */
  97071. reset(): AnimationGroup;
  97072. /**
  97073. * Restart animations from key 0
  97074. * @returns the animation group
  97075. */
  97076. restart(): AnimationGroup;
  97077. /**
  97078. * Stop all animations
  97079. * @returns the animation group
  97080. */
  97081. stop(): AnimationGroup;
  97082. /**
  97083. * Set animation weight for all animatables
  97084. * @param weight defines the weight to use
  97085. * @return the animationGroup
  97086. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97087. */
  97088. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97089. /**
  97090. * Synchronize and normalize all animatables with a source animatable
  97091. * @param root defines the root animatable to synchronize with
  97092. * @return the animationGroup
  97093. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97094. */
  97095. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97096. /**
  97097. * Goes to a specific frame in this animation group
  97098. * @param frame the frame number to go to
  97099. * @return the animationGroup
  97100. */
  97101. goToFrame(frame: number): AnimationGroup;
  97102. /**
  97103. * Dispose all associated resources
  97104. */
  97105. dispose(): void;
  97106. private _checkAnimationGroupEnded;
  97107. /**
  97108. * Clone the current animation group and returns a copy
  97109. * @param newName defines the name of the new group
  97110. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97111. * @returns the new aniamtion group
  97112. */
  97113. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97114. /**
  97115. * Serializes the animationGroup to an object
  97116. * @returns Serialized object
  97117. */
  97118. serialize(): any;
  97119. /**
  97120. * Returns a new AnimationGroup object parsed from the source provided.
  97121. * @param parsedAnimationGroup defines the source
  97122. * @param scene defines the scene that will receive the animationGroup
  97123. * @returns a new AnimationGroup
  97124. */
  97125. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97126. /**
  97127. * Returns the string "AnimationGroup"
  97128. * @returns "AnimationGroup"
  97129. */
  97130. getClassName(): string;
  97131. /**
  97132. * Creates a detailled string about the object
  97133. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97134. * @returns a string representing the object
  97135. */
  97136. toString(fullDetails?: boolean): string;
  97137. }
  97138. }
  97139. declare module BABYLON {
  97140. /**
  97141. * Define an interface for all classes that will hold resources
  97142. */
  97143. export interface IDisposable {
  97144. /**
  97145. * Releases all held resources
  97146. */
  97147. dispose(): void;
  97148. }
  97149. /** Interface defining initialization parameters for Scene class */
  97150. export interface SceneOptions {
  97151. /**
  97152. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97153. * It will improve performance when the number of geometries becomes important.
  97154. */
  97155. useGeometryUniqueIdsMap?: boolean;
  97156. /**
  97157. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97158. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97159. */
  97160. useMaterialMeshMap?: boolean;
  97161. /**
  97162. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97163. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97164. */
  97165. useClonedMeshhMap?: boolean;
  97166. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97167. virtual?: boolean;
  97168. }
  97169. /**
  97170. * Represents a scene to be rendered by the engine.
  97171. * @see http://doc.babylonjs.com/features/scene
  97172. */
  97173. export class Scene extends AbstractScene implements IAnimatable {
  97174. /** The fog is deactivated */
  97175. static readonly FOGMODE_NONE: number;
  97176. /** The fog density is following an exponential function */
  97177. static readonly FOGMODE_EXP: number;
  97178. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97179. static readonly FOGMODE_EXP2: number;
  97180. /** The fog density is following a linear function. */
  97181. static readonly FOGMODE_LINEAR: number;
  97182. /**
  97183. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97185. */
  97186. static MinDeltaTime: number;
  97187. /**
  97188. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97190. */
  97191. static MaxDeltaTime: number;
  97192. /**
  97193. * Factory used to create the default material.
  97194. * @param name The name of the material to create
  97195. * @param scene The scene to create the material for
  97196. * @returns The default material
  97197. */
  97198. static DefaultMaterialFactory(scene: Scene): Material;
  97199. /**
  97200. * Factory used to create the a collision coordinator.
  97201. * @returns The collision coordinator
  97202. */
  97203. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97204. /** @hidden */
  97205. _inputManager: InputManager;
  97206. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97207. cameraToUseForPointers: Nullable<Camera>;
  97208. /** @hidden */
  97209. readonly _isScene: boolean;
  97210. /**
  97211. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97212. */
  97213. autoClear: boolean;
  97214. /**
  97215. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97216. */
  97217. autoClearDepthAndStencil: boolean;
  97218. /**
  97219. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97220. */
  97221. clearColor: Color4;
  97222. /**
  97223. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97224. */
  97225. ambientColor: Color3;
  97226. /**
  97227. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97228. * It should only be one of the following (if not the default embedded one):
  97229. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97230. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97231. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97232. * The material properties need to be setup according to the type of texture in use.
  97233. */
  97234. environmentBRDFTexture: BaseTexture;
  97235. /** @hidden */
  97236. protected _environmentTexture: Nullable<BaseTexture>;
  97237. /**
  97238. * Texture used in all pbr material as the reflection texture.
  97239. * As in the majority of the scene they are the same (exception for multi room and so on),
  97240. * this is easier to reference from here than from all the materials.
  97241. */
  97242. /**
  97243. * Texture used in all pbr material as the reflection texture.
  97244. * As in the majority of the scene they are the same (exception for multi room and so on),
  97245. * this is easier to set here than in all the materials.
  97246. */
  97247. environmentTexture: Nullable<BaseTexture>;
  97248. /** @hidden */
  97249. protected _environmentIntensity: number;
  97250. /**
  97251. * Intensity of the environment in all pbr material.
  97252. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97253. * As in the majority of the scene they are the same (exception for multi room and so on),
  97254. * this is easier to reference from here than from all the materials.
  97255. */
  97256. /**
  97257. * Intensity of the environment in all pbr material.
  97258. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97259. * As in the majority of the scene they are the same (exception for multi room and so on),
  97260. * this is easier to set here than in all the materials.
  97261. */
  97262. environmentIntensity: number;
  97263. /** @hidden */
  97264. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97265. /**
  97266. * Default image processing configuration used either in the rendering
  97267. * Forward main pass or through the imageProcessingPostProcess if present.
  97268. * As in the majority of the scene they are the same (exception for multi camera),
  97269. * this is easier to reference from here than from all the materials and post process.
  97270. *
  97271. * No setter as we it is a shared configuration, you can set the values instead.
  97272. */
  97273. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97274. private _forceWireframe;
  97275. /**
  97276. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97277. */
  97278. forceWireframe: boolean;
  97279. private _forcePointsCloud;
  97280. /**
  97281. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97282. */
  97283. forcePointsCloud: boolean;
  97284. /**
  97285. * Gets or sets the active clipplane 1
  97286. */
  97287. clipPlane: Nullable<Plane>;
  97288. /**
  97289. * Gets or sets the active clipplane 2
  97290. */
  97291. clipPlane2: Nullable<Plane>;
  97292. /**
  97293. * Gets or sets the active clipplane 3
  97294. */
  97295. clipPlane3: Nullable<Plane>;
  97296. /**
  97297. * Gets or sets the active clipplane 4
  97298. */
  97299. clipPlane4: Nullable<Plane>;
  97300. /**
  97301. * Gets or sets a boolean indicating if animations are enabled
  97302. */
  97303. animationsEnabled: boolean;
  97304. private _animationPropertiesOverride;
  97305. /**
  97306. * Gets or sets the animation properties override
  97307. */
  97308. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97309. /**
  97310. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97311. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97312. */
  97313. useConstantAnimationDeltaTime: boolean;
  97314. /**
  97315. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97316. * Please note that it requires to run a ray cast through the scene on every frame
  97317. */
  97318. constantlyUpdateMeshUnderPointer: boolean;
  97319. /**
  97320. * Defines the HTML cursor to use when hovering over interactive elements
  97321. */
  97322. hoverCursor: string;
  97323. /**
  97324. * Defines the HTML default cursor to use (empty by default)
  97325. */
  97326. defaultCursor: string;
  97327. /**
  97328. * This is used to call preventDefault() on pointer down
  97329. * in order to block unwanted artifacts like system double clicks
  97330. */
  97331. preventDefaultOnPointerDown: boolean;
  97332. /**
  97333. * This is used to call preventDefault() on pointer up
  97334. * in order to block unwanted artifacts like system double clicks
  97335. */
  97336. preventDefaultOnPointerUp: boolean;
  97337. /**
  97338. * Gets or sets user defined metadata
  97339. */
  97340. metadata: any;
  97341. /**
  97342. * For internal use only. Please do not use.
  97343. */
  97344. reservedDataStore: any;
  97345. /**
  97346. * Gets the name of the plugin used to load this scene (null by default)
  97347. */
  97348. loadingPluginName: string;
  97349. /**
  97350. * Use this array to add regular expressions used to disable offline support for specific urls
  97351. */
  97352. disableOfflineSupportExceptionRules: RegExp[];
  97353. /**
  97354. * An event triggered when the scene is disposed.
  97355. */
  97356. onDisposeObservable: Observable<Scene>;
  97357. private _onDisposeObserver;
  97358. /** Sets a function to be executed when this scene is disposed. */
  97359. onDispose: () => void;
  97360. /**
  97361. * An event triggered before rendering the scene (right after animations and physics)
  97362. */
  97363. onBeforeRenderObservable: Observable<Scene>;
  97364. private _onBeforeRenderObserver;
  97365. /** Sets a function to be executed before rendering this scene */
  97366. beforeRender: Nullable<() => void>;
  97367. /**
  97368. * An event triggered after rendering the scene
  97369. */
  97370. onAfterRenderObservable: Observable<Scene>;
  97371. /**
  97372. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97373. */
  97374. onAfterRenderCameraObservable: Observable<Camera>;
  97375. private _onAfterRenderObserver;
  97376. /** Sets a function to be executed after rendering this scene */
  97377. afterRender: Nullable<() => void>;
  97378. /**
  97379. * An event triggered before animating the scene
  97380. */
  97381. onBeforeAnimationsObservable: Observable<Scene>;
  97382. /**
  97383. * An event triggered after animations processing
  97384. */
  97385. onAfterAnimationsObservable: Observable<Scene>;
  97386. /**
  97387. * An event triggered before draw calls are ready to be sent
  97388. */
  97389. onBeforeDrawPhaseObservable: Observable<Scene>;
  97390. /**
  97391. * An event triggered after draw calls have been sent
  97392. */
  97393. onAfterDrawPhaseObservable: Observable<Scene>;
  97394. /**
  97395. * An event triggered when the scene is ready
  97396. */
  97397. onReadyObservable: Observable<Scene>;
  97398. /**
  97399. * An event triggered before rendering a camera
  97400. */
  97401. onBeforeCameraRenderObservable: Observable<Camera>;
  97402. private _onBeforeCameraRenderObserver;
  97403. /** Sets a function to be executed before rendering a camera*/
  97404. beforeCameraRender: () => void;
  97405. /**
  97406. * An event triggered after rendering a camera
  97407. */
  97408. onAfterCameraRenderObservable: Observable<Camera>;
  97409. private _onAfterCameraRenderObserver;
  97410. /** Sets a function to be executed after rendering a camera*/
  97411. afterCameraRender: () => void;
  97412. /**
  97413. * An event triggered when active meshes evaluation is about to start
  97414. */
  97415. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97416. /**
  97417. * An event triggered when active meshes evaluation is done
  97418. */
  97419. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97420. /**
  97421. * An event triggered when particles rendering is about to start
  97422. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97423. */
  97424. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97425. /**
  97426. * An event triggered when particles rendering is done
  97427. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97428. */
  97429. onAfterParticlesRenderingObservable: Observable<Scene>;
  97430. /**
  97431. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97432. */
  97433. onDataLoadedObservable: Observable<Scene>;
  97434. /**
  97435. * An event triggered when a camera is created
  97436. */
  97437. onNewCameraAddedObservable: Observable<Camera>;
  97438. /**
  97439. * An event triggered when a camera is removed
  97440. */
  97441. onCameraRemovedObservable: Observable<Camera>;
  97442. /**
  97443. * An event triggered when a light is created
  97444. */
  97445. onNewLightAddedObservable: Observable<Light>;
  97446. /**
  97447. * An event triggered when a light is removed
  97448. */
  97449. onLightRemovedObservable: Observable<Light>;
  97450. /**
  97451. * An event triggered when a geometry is created
  97452. */
  97453. onNewGeometryAddedObservable: Observable<Geometry>;
  97454. /**
  97455. * An event triggered when a geometry is removed
  97456. */
  97457. onGeometryRemovedObservable: Observable<Geometry>;
  97458. /**
  97459. * An event triggered when a transform node is created
  97460. */
  97461. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97462. /**
  97463. * An event triggered when a transform node is removed
  97464. */
  97465. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97466. /**
  97467. * An event triggered when a mesh is created
  97468. */
  97469. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97470. /**
  97471. * An event triggered when a mesh is removed
  97472. */
  97473. onMeshRemovedObservable: Observable<AbstractMesh>;
  97474. /**
  97475. * An event triggered when a skeleton is created
  97476. */
  97477. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97478. /**
  97479. * An event triggered when a skeleton is removed
  97480. */
  97481. onSkeletonRemovedObservable: Observable<Skeleton>;
  97482. /**
  97483. * An event triggered when a material is created
  97484. */
  97485. onNewMaterialAddedObservable: Observable<Material>;
  97486. /**
  97487. * An event triggered when a material is removed
  97488. */
  97489. onMaterialRemovedObservable: Observable<Material>;
  97490. /**
  97491. * An event triggered when a texture is created
  97492. */
  97493. onNewTextureAddedObservable: Observable<BaseTexture>;
  97494. /**
  97495. * An event triggered when a texture is removed
  97496. */
  97497. onTextureRemovedObservable: Observable<BaseTexture>;
  97498. /**
  97499. * An event triggered when render targets are about to be rendered
  97500. * Can happen multiple times per frame.
  97501. */
  97502. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97503. /**
  97504. * An event triggered when render targets were rendered.
  97505. * Can happen multiple times per frame.
  97506. */
  97507. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97508. /**
  97509. * An event triggered before calculating deterministic simulation step
  97510. */
  97511. onBeforeStepObservable: Observable<Scene>;
  97512. /**
  97513. * An event triggered after calculating deterministic simulation step
  97514. */
  97515. onAfterStepObservable: Observable<Scene>;
  97516. /**
  97517. * An event triggered when the activeCamera property is updated
  97518. */
  97519. onActiveCameraChanged: Observable<Scene>;
  97520. /**
  97521. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97522. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97523. * 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)
  97524. */
  97525. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97526. /**
  97527. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97528. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97529. * 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)
  97530. */
  97531. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97532. /**
  97533. * This Observable will when a mesh has been imported into the scene.
  97534. */
  97535. onMeshImportedObservable: Observable<AbstractMesh>;
  97536. /**
  97537. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97538. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97539. */
  97540. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97541. /** @hidden */
  97542. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97543. /**
  97544. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97545. */
  97546. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97547. /**
  97548. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97549. */
  97550. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97551. /**
  97552. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97553. */
  97554. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97555. /** Callback called when a pointer move is detected */
  97556. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97557. /** Callback called when a pointer down is detected */
  97558. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97559. /** Callback called when a pointer up is detected */
  97560. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97561. /** Callback called when a pointer pick is detected */
  97562. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97563. /**
  97564. * 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).
  97565. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97566. */
  97567. onPrePointerObservable: Observable<PointerInfoPre>;
  97568. /**
  97569. * Observable event triggered each time an input event is received from the rendering canvas
  97570. */
  97571. onPointerObservable: Observable<PointerInfo>;
  97572. /**
  97573. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97574. */
  97575. readonly unTranslatedPointer: Vector2;
  97576. /**
  97577. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97578. */
  97579. static DragMovementThreshold: number;
  97580. /**
  97581. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97582. */
  97583. static LongPressDelay: number;
  97584. /**
  97585. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97586. */
  97587. static DoubleClickDelay: number;
  97588. /** If you need to check double click without raising a single click at first click, enable this flag */
  97589. static ExclusiveDoubleClickMode: boolean;
  97590. /** @hidden */
  97591. _mirroredCameraPosition: Nullable<Vector3>;
  97592. /**
  97593. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97594. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97595. */
  97596. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97597. /**
  97598. * Observable event triggered each time an keyboard event is received from the hosting window
  97599. */
  97600. onKeyboardObservable: Observable<KeyboardInfo>;
  97601. private _useRightHandedSystem;
  97602. /**
  97603. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97604. */
  97605. useRightHandedSystem: boolean;
  97606. private _timeAccumulator;
  97607. private _currentStepId;
  97608. private _currentInternalStep;
  97609. /**
  97610. * Sets the step Id used by deterministic lock step
  97611. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97612. * @param newStepId defines the step Id
  97613. */
  97614. setStepId(newStepId: number): void;
  97615. /**
  97616. * Gets the step Id used by deterministic lock step
  97617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97618. * @returns the step Id
  97619. */
  97620. getStepId(): number;
  97621. /**
  97622. * Gets the internal step used by deterministic lock step
  97623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97624. * @returns the internal step
  97625. */
  97626. getInternalStep(): number;
  97627. private _fogEnabled;
  97628. /**
  97629. * Gets or sets a boolean indicating if fog is enabled on this scene
  97630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97631. * (Default is true)
  97632. */
  97633. fogEnabled: boolean;
  97634. private _fogMode;
  97635. /**
  97636. * Gets or sets the fog mode to use
  97637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97638. * | mode | value |
  97639. * | --- | --- |
  97640. * | FOGMODE_NONE | 0 |
  97641. * | FOGMODE_EXP | 1 |
  97642. * | FOGMODE_EXP2 | 2 |
  97643. * | FOGMODE_LINEAR | 3 |
  97644. */
  97645. fogMode: number;
  97646. /**
  97647. * Gets or sets the fog color to use
  97648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97649. * (Default is Color3(0.2, 0.2, 0.3))
  97650. */
  97651. fogColor: Color3;
  97652. /**
  97653. * Gets or sets the fog density to use
  97654. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97655. * (Default is 0.1)
  97656. */
  97657. fogDensity: number;
  97658. /**
  97659. * Gets or sets the fog start distance to use
  97660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97661. * (Default is 0)
  97662. */
  97663. fogStart: number;
  97664. /**
  97665. * Gets or sets the fog end distance to use
  97666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97667. * (Default is 1000)
  97668. */
  97669. fogEnd: number;
  97670. private _shadowsEnabled;
  97671. /**
  97672. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97673. */
  97674. shadowsEnabled: boolean;
  97675. private _lightsEnabled;
  97676. /**
  97677. * Gets or sets a boolean indicating if lights are enabled on this scene
  97678. */
  97679. lightsEnabled: boolean;
  97680. /** All of the active cameras added to this scene. */
  97681. activeCameras: Camera[];
  97682. /** @hidden */
  97683. _activeCamera: Nullable<Camera>;
  97684. /** Gets or sets the current active camera */
  97685. activeCamera: Nullable<Camera>;
  97686. private _defaultMaterial;
  97687. /** The default material used on meshes when no material is affected */
  97688. /** The default material used on meshes when no material is affected */
  97689. defaultMaterial: Material;
  97690. private _texturesEnabled;
  97691. /**
  97692. * Gets or sets a boolean indicating if textures are enabled on this scene
  97693. */
  97694. texturesEnabled: boolean;
  97695. /**
  97696. * Gets or sets a boolean indicating if particles are enabled on this scene
  97697. */
  97698. particlesEnabled: boolean;
  97699. /**
  97700. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97701. */
  97702. spritesEnabled: boolean;
  97703. private _skeletonsEnabled;
  97704. /**
  97705. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97706. */
  97707. skeletonsEnabled: boolean;
  97708. /**
  97709. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97710. */
  97711. lensFlaresEnabled: boolean;
  97712. /**
  97713. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97715. */
  97716. collisionsEnabled: boolean;
  97717. private _collisionCoordinator;
  97718. /** @hidden */
  97719. readonly collisionCoordinator: ICollisionCoordinator;
  97720. /**
  97721. * Defines the gravity applied to this scene (used only for collisions)
  97722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97723. */
  97724. gravity: Vector3;
  97725. /**
  97726. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97727. */
  97728. postProcessesEnabled: boolean;
  97729. /**
  97730. * The list of postprocesses added to the scene
  97731. */
  97732. postProcesses: PostProcess[];
  97733. /**
  97734. * Gets the current postprocess manager
  97735. */
  97736. postProcessManager: PostProcessManager;
  97737. /**
  97738. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97739. */
  97740. renderTargetsEnabled: boolean;
  97741. /**
  97742. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97743. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97744. */
  97745. dumpNextRenderTargets: boolean;
  97746. /**
  97747. * The list of user defined render targets added to the scene
  97748. */
  97749. customRenderTargets: RenderTargetTexture[];
  97750. /**
  97751. * Defines if texture loading must be delayed
  97752. * If true, textures will only be loaded when they need to be rendered
  97753. */
  97754. useDelayedTextureLoading: boolean;
  97755. /**
  97756. * Gets the list of meshes imported to the scene through SceneLoader
  97757. */
  97758. importedMeshesFiles: String[];
  97759. /**
  97760. * Gets or sets a boolean indicating if probes are enabled on this scene
  97761. */
  97762. probesEnabled: boolean;
  97763. /**
  97764. * Gets or sets the current offline provider to use to store scene data
  97765. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97766. */
  97767. offlineProvider: IOfflineProvider;
  97768. /**
  97769. * Gets or sets the action manager associated with the scene
  97770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97771. */
  97772. actionManager: AbstractActionManager;
  97773. private _meshesForIntersections;
  97774. /**
  97775. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97776. */
  97777. proceduralTexturesEnabled: boolean;
  97778. private _engine;
  97779. private _totalVertices;
  97780. /** @hidden */
  97781. _activeIndices: PerfCounter;
  97782. /** @hidden */
  97783. _activeParticles: PerfCounter;
  97784. /** @hidden */
  97785. _activeBones: PerfCounter;
  97786. private _animationRatio;
  97787. /** @hidden */
  97788. _animationTimeLast: number;
  97789. /** @hidden */
  97790. _animationTime: number;
  97791. /**
  97792. * Gets or sets a general scale for animation speed
  97793. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97794. */
  97795. animationTimeScale: number;
  97796. /** @hidden */
  97797. _cachedMaterial: Nullable<Material>;
  97798. /** @hidden */
  97799. _cachedEffect: Nullable<Effect>;
  97800. /** @hidden */
  97801. _cachedVisibility: Nullable<number>;
  97802. private _renderId;
  97803. private _frameId;
  97804. private _executeWhenReadyTimeoutId;
  97805. private _intermediateRendering;
  97806. private _viewUpdateFlag;
  97807. private _projectionUpdateFlag;
  97808. /** @hidden */
  97809. _toBeDisposed: Nullable<IDisposable>[];
  97810. private _activeRequests;
  97811. /** @hidden */
  97812. _pendingData: any[];
  97813. private _isDisposed;
  97814. /**
  97815. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97816. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97817. */
  97818. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97819. private _activeMeshes;
  97820. private _processedMaterials;
  97821. private _renderTargets;
  97822. /** @hidden */
  97823. _activeParticleSystems: SmartArray<IParticleSystem>;
  97824. private _activeSkeletons;
  97825. private _softwareSkinnedMeshes;
  97826. private _renderingManager;
  97827. /** @hidden */
  97828. _activeAnimatables: Animatable[];
  97829. private _transformMatrix;
  97830. private _sceneUbo;
  97831. /** @hidden */
  97832. _viewMatrix: Matrix;
  97833. private _projectionMatrix;
  97834. /** @hidden */
  97835. _forcedViewPosition: Nullable<Vector3>;
  97836. /** @hidden */
  97837. _frustumPlanes: Plane[];
  97838. /**
  97839. * Gets the list of frustum planes (built from the active camera)
  97840. */
  97841. readonly frustumPlanes: Plane[];
  97842. /**
  97843. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97844. * This is useful if there are more lights that the maximum simulteanous authorized
  97845. */
  97846. requireLightSorting: boolean;
  97847. /** @hidden */
  97848. readonly useMaterialMeshMap: boolean;
  97849. /** @hidden */
  97850. readonly useClonedMeshhMap: boolean;
  97851. private _externalData;
  97852. private _uid;
  97853. /**
  97854. * @hidden
  97855. * Backing store of defined scene components.
  97856. */
  97857. _components: ISceneComponent[];
  97858. /**
  97859. * @hidden
  97860. * Backing store of defined scene components.
  97861. */
  97862. _serializableComponents: ISceneSerializableComponent[];
  97863. /**
  97864. * List of components to register on the next registration step.
  97865. */
  97866. private _transientComponents;
  97867. /**
  97868. * Registers the transient components if needed.
  97869. */
  97870. private _registerTransientComponents;
  97871. /**
  97872. * @hidden
  97873. * Add a component to the scene.
  97874. * Note that the ccomponent could be registered on th next frame if this is called after
  97875. * the register component stage.
  97876. * @param component Defines the component to add to the scene
  97877. */
  97878. _addComponent(component: ISceneComponent): void;
  97879. /**
  97880. * @hidden
  97881. * Gets a component from the scene.
  97882. * @param name defines the name of the component to retrieve
  97883. * @returns the component or null if not present
  97884. */
  97885. _getComponent(name: string): Nullable<ISceneComponent>;
  97886. /**
  97887. * @hidden
  97888. * Defines the actions happening before camera updates.
  97889. */
  97890. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97891. /**
  97892. * @hidden
  97893. * Defines the actions happening before clear the canvas.
  97894. */
  97895. _beforeClearStage: Stage<SimpleStageAction>;
  97896. /**
  97897. * @hidden
  97898. * Defines the actions when collecting render targets for the frame.
  97899. */
  97900. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97901. /**
  97902. * @hidden
  97903. * Defines the actions happening for one camera in the frame.
  97904. */
  97905. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97906. /**
  97907. * @hidden
  97908. * Defines the actions happening during the per mesh ready checks.
  97909. */
  97910. _isReadyForMeshStage: Stage<MeshStageAction>;
  97911. /**
  97912. * @hidden
  97913. * Defines the actions happening before evaluate active mesh checks.
  97914. */
  97915. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97916. /**
  97917. * @hidden
  97918. * Defines the actions happening during the evaluate sub mesh checks.
  97919. */
  97920. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97921. /**
  97922. * @hidden
  97923. * Defines the actions happening during the active mesh stage.
  97924. */
  97925. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97926. /**
  97927. * @hidden
  97928. * Defines the actions happening during the per camera render target step.
  97929. */
  97930. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97931. /**
  97932. * @hidden
  97933. * Defines the actions happening just before the active camera is drawing.
  97934. */
  97935. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97936. /**
  97937. * @hidden
  97938. * Defines the actions happening just before a render target is drawing.
  97939. */
  97940. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97941. /**
  97942. * @hidden
  97943. * Defines the actions happening just before a rendering group is drawing.
  97944. */
  97945. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97946. /**
  97947. * @hidden
  97948. * Defines the actions happening just before a mesh is drawing.
  97949. */
  97950. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97951. /**
  97952. * @hidden
  97953. * Defines the actions happening just after a mesh has been drawn.
  97954. */
  97955. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97956. /**
  97957. * @hidden
  97958. * Defines the actions happening just after a rendering group has been drawn.
  97959. */
  97960. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97961. /**
  97962. * @hidden
  97963. * Defines the actions happening just after the active camera has been drawn.
  97964. */
  97965. _afterCameraDrawStage: Stage<CameraStageAction>;
  97966. /**
  97967. * @hidden
  97968. * Defines the actions happening just after a render target has been drawn.
  97969. */
  97970. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97971. /**
  97972. * @hidden
  97973. * Defines the actions happening just after rendering all cameras and computing intersections.
  97974. */
  97975. _afterRenderStage: Stage<SimpleStageAction>;
  97976. /**
  97977. * @hidden
  97978. * Defines the actions happening when a pointer move event happens.
  97979. */
  97980. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97981. /**
  97982. * @hidden
  97983. * Defines the actions happening when a pointer down event happens.
  97984. */
  97985. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97986. /**
  97987. * @hidden
  97988. * Defines the actions happening when a pointer up event happens.
  97989. */
  97990. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97991. /**
  97992. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97993. */
  97994. private geometriesByUniqueId;
  97995. /**
  97996. * Creates a new Scene
  97997. * @param engine defines the engine to use to render this scene
  97998. * @param options defines the scene options
  97999. */
  98000. constructor(engine: Engine, options?: SceneOptions);
  98001. /**
  98002. * Gets a string idenfifying the name of the class
  98003. * @returns "Scene" string
  98004. */
  98005. getClassName(): string;
  98006. private _defaultMeshCandidates;
  98007. /**
  98008. * @hidden
  98009. */
  98010. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98011. private _defaultSubMeshCandidates;
  98012. /**
  98013. * @hidden
  98014. */
  98015. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98016. /**
  98017. * Sets the default candidate providers for the scene.
  98018. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98019. * and getCollidingSubMeshCandidates to their default function
  98020. */
  98021. setDefaultCandidateProviders(): void;
  98022. /**
  98023. * Gets the mesh that is currently under the pointer
  98024. */
  98025. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98026. /**
  98027. * Gets or sets the current on-screen X position of the pointer
  98028. */
  98029. pointerX: number;
  98030. /**
  98031. * Gets or sets the current on-screen Y position of the pointer
  98032. */
  98033. pointerY: number;
  98034. /**
  98035. * Gets the cached material (ie. the latest rendered one)
  98036. * @returns the cached material
  98037. */
  98038. getCachedMaterial(): Nullable<Material>;
  98039. /**
  98040. * Gets the cached effect (ie. the latest rendered one)
  98041. * @returns the cached effect
  98042. */
  98043. getCachedEffect(): Nullable<Effect>;
  98044. /**
  98045. * Gets the cached visibility state (ie. the latest rendered one)
  98046. * @returns the cached visibility state
  98047. */
  98048. getCachedVisibility(): Nullable<number>;
  98049. /**
  98050. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98051. * @param material defines the current material
  98052. * @param effect defines the current effect
  98053. * @param visibility defines the current visibility state
  98054. * @returns true if one parameter is not cached
  98055. */
  98056. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98057. /**
  98058. * Gets the engine associated with the scene
  98059. * @returns an Engine
  98060. */
  98061. getEngine(): Engine;
  98062. /**
  98063. * Gets the total number of vertices rendered per frame
  98064. * @returns the total number of vertices rendered per frame
  98065. */
  98066. getTotalVertices(): number;
  98067. /**
  98068. * Gets the performance counter for total vertices
  98069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98070. */
  98071. readonly totalVerticesPerfCounter: PerfCounter;
  98072. /**
  98073. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98074. * @returns the total number of active indices rendered per frame
  98075. */
  98076. getActiveIndices(): number;
  98077. /**
  98078. * Gets the performance counter for active indices
  98079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98080. */
  98081. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98082. /**
  98083. * Gets the total number of active particles rendered per frame
  98084. * @returns the total number of active particles rendered per frame
  98085. */
  98086. getActiveParticles(): number;
  98087. /**
  98088. * Gets the performance counter for active particles
  98089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98090. */
  98091. readonly activeParticlesPerfCounter: PerfCounter;
  98092. /**
  98093. * Gets the total number of active bones rendered per frame
  98094. * @returns the total number of active bones rendered per frame
  98095. */
  98096. getActiveBones(): number;
  98097. /**
  98098. * Gets the performance counter for active bones
  98099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98100. */
  98101. readonly activeBonesPerfCounter: PerfCounter;
  98102. /**
  98103. * Gets the array of active meshes
  98104. * @returns an array of AbstractMesh
  98105. */
  98106. getActiveMeshes(): SmartArray<AbstractMesh>;
  98107. /**
  98108. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98109. * @returns a number
  98110. */
  98111. getAnimationRatio(): number;
  98112. /**
  98113. * Gets an unique Id for the current render phase
  98114. * @returns a number
  98115. */
  98116. getRenderId(): number;
  98117. /**
  98118. * Gets an unique Id for the current frame
  98119. * @returns a number
  98120. */
  98121. getFrameId(): number;
  98122. /** Call this function if you want to manually increment the render Id*/
  98123. incrementRenderId(): void;
  98124. private _createUbo;
  98125. /**
  98126. * Use this method to simulate a pointer move on a mesh
  98127. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98128. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98129. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98130. * @returns the current scene
  98131. */
  98132. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98133. /**
  98134. * Use this method to simulate a pointer down on a mesh
  98135. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98136. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98137. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98138. * @returns the current scene
  98139. */
  98140. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98141. /**
  98142. * Use this method to simulate a pointer up on a mesh
  98143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98146. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98147. * @returns the current scene
  98148. */
  98149. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98150. /**
  98151. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98152. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98153. * @returns true if the pointer was captured
  98154. */
  98155. isPointerCaptured(pointerId?: number): boolean;
  98156. /**
  98157. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98158. * @param attachUp defines if you want to attach events to pointerup
  98159. * @param attachDown defines if you want to attach events to pointerdown
  98160. * @param attachMove defines if you want to attach events to pointermove
  98161. */
  98162. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98163. /** Detaches all event handlers*/
  98164. detachControl(): void;
  98165. /**
  98166. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98167. * Delay loaded resources are not taking in account
  98168. * @return true if all required resources are ready
  98169. */
  98170. isReady(): boolean;
  98171. /** Resets all cached information relative to material (including effect and visibility) */
  98172. resetCachedMaterial(): void;
  98173. /**
  98174. * Registers a function to be called before every frame render
  98175. * @param func defines the function to register
  98176. */
  98177. registerBeforeRender(func: () => void): void;
  98178. /**
  98179. * Unregisters a function called before every frame render
  98180. * @param func defines the function to unregister
  98181. */
  98182. unregisterBeforeRender(func: () => void): void;
  98183. /**
  98184. * Registers a function to be called after every frame render
  98185. * @param func defines the function to register
  98186. */
  98187. registerAfterRender(func: () => void): void;
  98188. /**
  98189. * Unregisters a function called after every frame render
  98190. * @param func defines the function to unregister
  98191. */
  98192. unregisterAfterRender(func: () => void): void;
  98193. private _executeOnceBeforeRender;
  98194. /**
  98195. * The provided function will run before render once and will be disposed afterwards.
  98196. * A timeout delay can be provided so that the function will be executed in N ms.
  98197. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98198. * @param func The function to be executed.
  98199. * @param timeout optional delay in ms
  98200. */
  98201. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98202. /** @hidden */
  98203. _addPendingData(data: any): void;
  98204. /** @hidden */
  98205. _removePendingData(data: any): void;
  98206. /**
  98207. * Returns the number of items waiting to be loaded
  98208. * @returns the number of items waiting to be loaded
  98209. */
  98210. getWaitingItemsCount(): number;
  98211. /**
  98212. * Returns a boolean indicating if the scene is still loading data
  98213. */
  98214. readonly isLoading: boolean;
  98215. /**
  98216. * Registers a function to be executed when the scene is ready
  98217. * @param {Function} func - the function to be executed
  98218. */
  98219. executeWhenReady(func: () => void): void;
  98220. /**
  98221. * Returns a promise that resolves when the scene is ready
  98222. * @returns A promise that resolves when the scene is ready
  98223. */
  98224. whenReadyAsync(): Promise<void>;
  98225. /** @hidden */
  98226. _checkIsReady(): void;
  98227. /**
  98228. * Gets all animatable attached to the scene
  98229. */
  98230. readonly animatables: Animatable[];
  98231. /**
  98232. * Resets the last animation time frame.
  98233. * Useful to override when animations start running when loading a scene for the first time.
  98234. */
  98235. resetLastAnimationTimeFrame(): void;
  98236. /**
  98237. * Gets the current view matrix
  98238. * @returns a Matrix
  98239. */
  98240. getViewMatrix(): Matrix;
  98241. /**
  98242. * Gets the current projection matrix
  98243. * @returns a Matrix
  98244. */
  98245. getProjectionMatrix(): Matrix;
  98246. /**
  98247. * Gets the current transform matrix
  98248. * @returns a Matrix made of View * Projection
  98249. */
  98250. getTransformMatrix(): Matrix;
  98251. /**
  98252. * Sets the current transform matrix
  98253. * @param viewL defines the View matrix to use
  98254. * @param projectionL defines the Projection matrix to use
  98255. * @param viewR defines the right View matrix to use (if provided)
  98256. * @param projectionR defines the right Projection matrix to use (if provided)
  98257. */
  98258. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98259. /**
  98260. * Gets the uniform buffer used to store scene data
  98261. * @returns a UniformBuffer
  98262. */
  98263. getSceneUniformBuffer(): UniformBuffer;
  98264. /**
  98265. * Gets an unique (relatively to the current scene) Id
  98266. * @returns an unique number for the scene
  98267. */
  98268. getUniqueId(): number;
  98269. /**
  98270. * Add a mesh to the list of scene's meshes
  98271. * @param newMesh defines the mesh to add
  98272. * @param recursive if all child meshes should also be added to the scene
  98273. */
  98274. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98275. /**
  98276. * Remove a mesh for the list of scene's meshes
  98277. * @param toRemove defines the mesh to remove
  98278. * @param recursive if all child meshes should also be removed from the scene
  98279. * @returns the index where the mesh was in the mesh list
  98280. */
  98281. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98282. /**
  98283. * Add a transform node to the list of scene's transform nodes
  98284. * @param newTransformNode defines the transform node to add
  98285. */
  98286. addTransformNode(newTransformNode: TransformNode): void;
  98287. /**
  98288. * Remove a transform node for the list of scene's transform nodes
  98289. * @param toRemove defines the transform node to remove
  98290. * @returns the index where the transform node was in the transform node list
  98291. */
  98292. removeTransformNode(toRemove: TransformNode): number;
  98293. /**
  98294. * Remove a skeleton for the list of scene's skeletons
  98295. * @param toRemove defines the skeleton to remove
  98296. * @returns the index where the skeleton was in the skeleton list
  98297. */
  98298. removeSkeleton(toRemove: Skeleton): number;
  98299. /**
  98300. * Remove a morph target for the list of scene's morph targets
  98301. * @param toRemove defines the morph target to remove
  98302. * @returns the index where the morph target was in the morph target list
  98303. */
  98304. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98305. /**
  98306. * Remove a light for the list of scene's lights
  98307. * @param toRemove defines the light to remove
  98308. * @returns the index where the light was in the light list
  98309. */
  98310. removeLight(toRemove: Light): number;
  98311. /**
  98312. * Remove a camera for the list of scene's cameras
  98313. * @param toRemove defines the camera to remove
  98314. * @returns the index where the camera was in the camera list
  98315. */
  98316. removeCamera(toRemove: Camera): number;
  98317. /**
  98318. * Remove a particle system for the list of scene's particle systems
  98319. * @param toRemove defines the particle system to remove
  98320. * @returns the index where the particle system was in the particle system list
  98321. */
  98322. removeParticleSystem(toRemove: IParticleSystem): number;
  98323. /**
  98324. * Remove a animation for the list of scene's animations
  98325. * @param toRemove defines the animation to remove
  98326. * @returns the index where the animation was in the animation list
  98327. */
  98328. removeAnimation(toRemove: Animation): number;
  98329. /**
  98330. * Will stop the animation of the given target
  98331. * @param target - the target
  98332. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98333. * @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)
  98334. */
  98335. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98336. /**
  98337. * Removes the given animation group from this scene.
  98338. * @param toRemove The animation group to remove
  98339. * @returns The index of the removed animation group
  98340. */
  98341. removeAnimationGroup(toRemove: AnimationGroup): number;
  98342. /**
  98343. * Removes the given multi-material from this scene.
  98344. * @param toRemove The multi-material to remove
  98345. * @returns The index of the removed multi-material
  98346. */
  98347. removeMultiMaterial(toRemove: MultiMaterial): number;
  98348. /**
  98349. * Removes the given material from this scene.
  98350. * @param toRemove The material to remove
  98351. * @returns The index of the removed material
  98352. */
  98353. removeMaterial(toRemove: Material): number;
  98354. /**
  98355. * Removes the given action manager from this scene.
  98356. * @param toRemove The action manager to remove
  98357. * @returns The index of the removed action manager
  98358. */
  98359. removeActionManager(toRemove: AbstractActionManager): number;
  98360. /**
  98361. * Removes the given texture from this scene.
  98362. * @param toRemove The texture to remove
  98363. * @returns The index of the removed texture
  98364. */
  98365. removeTexture(toRemove: BaseTexture): number;
  98366. /**
  98367. * Adds the given light to this scene
  98368. * @param newLight The light to add
  98369. */
  98370. addLight(newLight: Light): void;
  98371. /**
  98372. * Sorts the list list based on light priorities
  98373. */
  98374. sortLightsByPriority(): void;
  98375. /**
  98376. * Adds the given camera to this scene
  98377. * @param newCamera The camera to add
  98378. */
  98379. addCamera(newCamera: Camera): void;
  98380. /**
  98381. * Adds the given skeleton to this scene
  98382. * @param newSkeleton The skeleton to add
  98383. */
  98384. addSkeleton(newSkeleton: Skeleton): void;
  98385. /**
  98386. * Adds the given particle system to this scene
  98387. * @param newParticleSystem The particle system to add
  98388. */
  98389. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98390. /**
  98391. * Adds the given animation to this scene
  98392. * @param newAnimation The animation to add
  98393. */
  98394. addAnimation(newAnimation: Animation): void;
  98395. /**
  98396. * Adds the given animation group to this scene.
  98397. * @param newAnimationGroup The animation group to add
  98398. */
  98399. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98400. /**
  98401. * Adds the given multi-material to this scene
  98402. * @param newMultiMaterial The multi-material to add
  98403. */
  98404. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98405. /**
  98406. * Adds the given material to this scene
  98407. * @param newMaterial The material to add
  98408. */
  98409. addMaterial(newMaterial: Material): void;
  98410. /**
  98411. * Adds the given morph target to this scene
  98412. * @param newMorphTargetManager The morph target to add
  98413. */
  98414. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98415. /**
  98416. * Adds the given geometry to this scene
  98417. * @param newGeometry The geometry to add
  98418. */
  98419. addGeometry(newGeometry: Geometry): void;
  98420. /**
  98421. * Adds the given action manager to this scene
  98422. * @param newActionManager The action manager to add
  98423. */
  98424. addActionManager(newActionManager: AbstractActionManager): void;
  98425. /**
  98426. * Adds the given texture to this scene.
  98427. * @param newTexture The texture to add
  98428. */
  98429. addTexture(newTexture: BaseTexture): void;
  98430. /**
  98431. * Switch active camera
  98432. * @param newCamera defines the new active camera
  98433. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98434. */
  98435. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98436. /**
  98437. * sets the active camera of the scene using its ID
  98438. * @param id defines the camera's ID
  98439. * @return the new active camera or null if none found.
  98440. */
  98441. setActiveCameraByID(id: string): Nullable<Camera>;
  98442. /**
  98443. * sets the active camera of the scene using its name
  98444. * @param name defines the camera's name
  98445. * @returns the new active camera or null if none found.
  98446. */
  98447. setActiveCameraByName(name: string): Nullable<Camera>;
  98448. /**
  98449. * get an animation group using its name
  98450. * @param name defines the material's name
  98451. * @return the animation group or null if none found.
  98452. */
  98453. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98454. /**
  98455. * Get a material using its unique id
  98456. * @param uniqueId defines the material's unique id
  98457. * @return the material or null if none found.
  98458. */
  98459. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98460. /**
  98461. * get a material using its id
  98462. * @param id defines the material's ID
  98463. * @return the material or null if none found.
  98464. */
  98465. getMaterialByID(id: string): Nullable<Material>;
  98466. /**
  98467. * Gets a the last added material using a given id
  98468. * @param id defines the material's ID
  98469. * @return the last material with the given id or null if none found.
  98470. */
  98471. getLastMaterialByID(id: string): Nullable<Material>;
  98472. /**
  98473. * Gets a material using its name
  98474. * @param name defines the material's name
  98475. * @return the material or null if none found.
  98476. */
  98477. getMaterialByName(name: string): Nullable<Material>;
  98478. /**
  98479. * Get a texture using its unique id
  98480. * @param uniqueId defines the texture's unique id
  98481. * @return the texture or null if none found.
  98482. */
  98483. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98484. /**
  98485. * Gets a camera using its id
  98486. * @param id defines the id to look for
  98487. * @returns the camera or null if not found
  98488. */
  98489. getCameraByID(id: string): Nullable<Camera>;
  98490. /**
  98491. * Gets a camera using its unique id
  98492. * @param uniqueId defines the unique id to look for
  98493. * @returns the camera or null if not found
  98494. */
  98495. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98496. /**
  98497. * Gets a camera using its name
  98498. * @param name defines the camera's name
  98499. * @return the camera or null if none found.
  98500. */
  98501. getCameraByName(name: string): Nullable<Camera>;
  98502. /**
  98503. * Gets a bone using its id
  98504. * @param id defines the bone's id
  98505. * @return the bone or null if not found
  98506. */
  98507. getBoneByID(id: string): Nullable<Bone>;
  98508. /**
  98509. * Gets a bone using its id
  98510. * @param name defines the bone's name
  98511. * @return the bone or null if not found
  98512. */
  98513. getBoneByName(name: string): Nullable<Bone>;
  98514. /**
  98515. * Gets a light node using its name
  98516. * @param name defines the the light's name
  98517. * @return the light or null if none found.
  98518. */
  98519. getLightByName(name: string): Nullable<Light>;
  98520. /**
  98521. * Gets a light node using its id
  98522. * @param id defines the light's id
  98523. * @return the light or null if none found.
  98524. */
  98525. getLightByID(id: string): Nullable<Light>;
  98526. /**
  98527. * Gets a light node using its scene-generated unique ID
  98528. * @param uniqueId defines the light's unique id
  98529. * @return the light or null if none found.
  98530. */
  98531. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98532. /**
  98533. * Gets a particle system by id
  98534. * @param id defines the particle system id
  98535. * @return the corresponding system or null if none found
  98536. */
  98537. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98538. /**
  98539. * Gets a geometry using its ID
  98540. * @param id defines the geometry's id
  98541. * @return the geometry or null if none found.
  98542. */
  98543. getGeometryByID(id: string): Nullable<Geometry>;
  98544. private _getGeometryByUniqueID;
  98545. /**
  98546. * Add a new geometry to this scene
  98547. * @param geometry defines the geometry to be added to the scene.
  98548. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98549. * @return a boolean defining if the geometry was added or not
  98550. */
  98551. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98552. /**
  98553. * Removes an existing geometry
  98554. * @param geometry defines the geometry to be removed from the scene
  98555. * @return a boolean defining if the geometry was removed or not
  98556. */
  98557. removeGeometry(geometry: Geometry): boolean;
  98558. /**
  98559. * Gets the list of geometries attached to the scene
  98560. * @returns an array of Geometry
  98561. */
  98562. getGeometries(): Geometry[];
  98563. /**
  98564. * Gets the first added mesh found of a given ID
  98565. * @param id defines the id to search for
  98566. * @return the mesh found or null if not found at all
  98567. */
  98568. getMeshByID(id: string): Nullable<AbstractMesh>;
  98569. /**
  98570. * Gets a list of meshes using their id
  98571. * @param id defines the id to search for
  98572. * @returns a list of meshes
  98573. */
  98574. getMeshesByID(id: string): Array<AbstractMesh>;
  98575. /**
  98576. * Gets the first added transform node found of a given ID
  98577. * @param id defines the id to search for
  98578. * @return the found transform node or null if not found at all.
  98579. */
  98580. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98581. /**
  98582. * Gets a transform node with its auto-generated unique id
  98583. * @param uniqueId efines the unique id to search for
  98584. * @return the found transform node or null if not found at all.
  98585. */
  98586. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98587. /**
  98588. * Gets a list of transform nodes using their id
  98589. * @param id defines the id to search for
  98590. * @returns a list of transform nodes
  98591. */
  98592. getTransformNodesByID(id: string): Array<TransformNode>;
  98593. /**
  98594. * Gets a mesh with its auto-generated unique id
  98595. * @param uniqueId defines the unique id to search for
  98596. * @return the found mesh or null if not found at all.
  98597. */
  98598. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98599. /**
  98600. * Gets a the last added mesh using a given id
  98601. * @param id defines the id to search for
  98602. * @return the found mesh or null if not found at all.
  98603. */
  98604. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98605. /**
  98606. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98607. * @param id defines the id to search for
  98608. * @return the found node or null if not found at all
  98609. */
  98610. getLastEntryByID(id: string): Nullable<Node>;
  98611. /**
  98612. * Gets a node (Mesh, Camera, Light) using a given id
  98613. * @param id defines the id to search for
  98614. * @return the found node or null if not found at all
  98615. */
  98616. getNodeByID(id: string): Nullable<Node>;
  98617. /**
  98618. * Gets a node (Mesh, Camera, Light) using a given name
  98619. * @param name defines the name to search for
  98620. * @return the found node or null if not found at all.
  98621. */
  98622. getNodeByName(name: string): Nullable<Node>;
  98623. /**
  98624. * Gets a mesh using a given name
  98625. * @param name defines the name to search for
  98626. * @return the found mesh or null if not found at all.
  98627. */
  98628. getMeshByName(name: string): Nullable<AbstractMesh>;
  98629. /**
  98630. * Gets a transform node using a given name
  98631. * @param name defines the name to search for
  98632. * @return the found transform node or null if not found at all.
  98633. */
  98634. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98635. /**
  98636. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98637. * @param id defines the id to search for
  98638. * @return the found skeleton or null if not found at all.
  98639. */
  98640. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98641. /**
  98642. * Gets a skeleton using a given auto generated unique id
  98643. * @param uniqueId defines the unique id to search for
  98644. * @return the found skeleton or null if not found at all.
  98645. */
  98646. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98647. /**
  98648. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98649. * @param id defines the id to search for
  98650. * @return the found skeleton or null if not found at all.
  98651. */
  98652. getSkeletonById(id: string): Nullable<Skeleton>;
  98653. /**
  98654. * Gets a skeleton using a given name
  98655. * @param name defines the name to search for
  98656. * @return the found skeleton or null if not found at all.
  98657. */
  98658. getSkeletonByName(name: string): Nullable<Skeleton>;
  98659. /**
  98660. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98661. * @param id defines the id to search for
  98662. * @return the found morph target manager or null if not found at all.
  98663. */
  98664. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98665. /**
  98666. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98667. * @param id defines the id to search for
  98668. * @return the found morph target or null if not found at all.
  98669. */
  98670. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98671. /**
  98672. * Gets a boolean indicating if the given mesh is active
  98673. * @param mesh defines the mesh to look for
  98674. * @returns true if the mesh is in the active list
  98675. */
  98676. isActiveMesh(mesh: AbstractMesh): boolean;
  98677. /**
  98678. * Return a unique id as a string which can serve as an identifier for the scene
  98679. */
  98680. readonly uid: string;
  98681. /**
  98682. * Add an externaly attached data from its key.
  98683. * This method call will fail and return false, if such key already exists.
  98684. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98685. * @param key the unique key that identifies the data
  98686. * @param data the data object to associate to the key for this Engine instance
  98687. * @return true if no such key were already present and the data was added successfully, false otherwise
  98688. */
  98689. addExternalData<T>(key: string, data: T): boolean;
  98690. /**
  98691. * Get an externaly attached data from its key
  98692. * @param key the unique key that identifies the data
  98693. * @return the associated data, if present (can be null), or undefined if not present
  98694. */
  98695. getExternalData<T>(key: string): Nullable<T>;
  98696. /**
  98697. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98698. * @param key the unique key that identifies the data
  98699. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98700. * @return the associated data, can be null if the factory returned null.
  98701. */
  98702. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98703. /**
  98704. * Remove an externaly attached data from the Engine instance
  98705. * @param key the unique key that identifies the data
  98706. * @return true if the data was successfully removed, false if it doesn't exist
  98707. */
  98708. removeExternalData(key: string): boolean;
  98709. private _evaluateSubMesh;
  98710. /**
  98711. * Clear the processed materials smart array preventing retention point in material dispose.
  98712. */
  98713. freeProcessedMaterials(): void;
  98714. private _preventFreeActiveMeshesAndRenderingGroups;
  98715. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98716. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98717. * when disposing several meshes in a row or a hierarchy of meshes.
  98718. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98719. */
  98720. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98721. /**
  98722. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98723. */
  98724. freeActiveMeshes(): void;
  98725. /**
  98726. * Clear the info related to rendering groups preventing retention points during dispose.
  98727. */
  98728. freeRenderingGroups(): void;
  98729. /** @hidden */
  98730. _isInIntermediateRendering(): boolean;
  98731. /**
  98732. * Lambda returning the list of potentially active meshes.
  98733. */
  98734. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98735. /**
  98736. * Lambda returning the list of potentially active sub meshes.
  98737. */
  98738. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98739. /**
  98740. * Lambda returning the list of potentially intersecting sub meshes.
  98741. */
  98742. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98743. /**
  98744. * Lambda returning the list of potentially colliding sub meshes.
  98745. */
  98746. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98747. private _activeMeshesFrozen;
  98748. /**
  98749. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98750. * @returns the current scene
  98751. */
  98752. freezeActiveMeshes(): Scene;
  98753. /**
  98754. * Use this function to restart evaluating active meshes on every frame
  98755. * @returns the current scene
  98756. */
  98757. unfreezeActiveMeshes(): Scene;
  98758. private _evaluateActiveMeshes;
  98759. private _activeMesh;
  98760. /**
  98761. * Update the transform matrix to update from the current active camera
  98762. * @param force defines a boolean used to force the update even if cache is up to date
  98763. */
  98764. updateTransformMatrix(force?: boolean): void;
  98765. private _bindFrameBuffer;
  98766. /** @hidden */
  98767. _allowPostProcessClearColor: boolean;
  98768. /** @hidden */
  98769. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98770. private _processSubCameras;
  98771. private _checkIntersections;
  98772. /** @hidden */
  98773. _advancePhysicsEngineStep(step: number): void;
  98774. /**
  98775. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98776. */
  98777. getDeterministicFrameTime: () => number;
  98778. /** @hidden */
  98779. _animate(): void;
  98780. /** Execute all animations (for a frame) */
  98781. animate(): void;
  98782. /**
  98783. * Render the scene
  98784. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98785. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98786. */
  98787. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98788. /**
  98789. * Freeze all materials
  98790. * A frozen material will not be updatable but should be faster to render
  98791. */
  98792. freezeMaterials(): void;
  98793. /**
  98794. * Unfreeze all materials
  98795. * A frozen material will not be updatable but should be faster to render
  98796. */
  98797. unfreezeMaterials(): void;
  98798. /**
  98799. * Releases all held ressources
  98800. */
  98801. dispose(): void;
  98802. /**
  98803. * Gets if the scene is already disposed
  98804. */
  98805. readonly isDisposed: boolean;
  98806. /**
  98807. * Call this function to reduce memory footprint of the scene.
  98808. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98809. */
  98810. clearCachedVertexData(): void;
  98811. /**
  98812. * This function will remove the local cached buffer data from texture.
  98813. * It will save memory but will prevent the texture from being rebuilt
  98814. */
  98815. cleanCachedTextureBuffer(): void;
  98816. /**
  98817. * Get the world extend vectors with an optional filter
  98818. *
  98819. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98820. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98821. */
  98822. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98823. min: Vector3;
  98824. max: Vector3;
  98825. };
  98826. /**
  98827. * Creates a ray that can be used to pick in the scene
  98828. * @param x defines the x coordinate of the origin (on-screen)
  98829. * @param y defines the y coordinate of the origin (on-screen)
  98830. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98831. * @param camera defines the camera to use for the picking
  98832. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98833. * @returns a Ray
  98834. */
  98835. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98836. /**
  98837. * Creates a ray that can be used to pick in the scene
  98838. * @param x defines the x coordinate of the origin (on-screen)
  98839. * @param y defines the y coordinate of the origin (on-screen)
  98840. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98841. * @param result defines the ray where to store the picking ray
  98842. * @param camera defines the camera to use for the picking
  98843. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98844. * @returns the current scene
  98845. */
  98846. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98847. /**
  98848. * Creates a ray that can be used to pick in the scene
  98849. * @param x defines the x coordinate of the origin (on-screen)
  98850. * @param y defines the y coordinate of the origin (on-screen)
  98851. * @param camera defines the camera to use for the picking
  98852. * @returns a Ray
  98853. */
  98854. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98855. /**
  98856. * Creates a ray that can be used to pick in the scene
  98857. * @param x defines the x coordinate of the origin (on-screen)
  98858. * @param y defines the y coordinate of the origin (on-screen)
  98859. * @param result defines the ray where to store the picking ray
  98860. * @param camera defines the camera to use for the picking
  98861. * @returns the current scene
  98862. */
  98863. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98864. /** Launch a ray to try to pick a mesh in the scene
  98865. * @param x position on screen
  98866. * @param y position on screen
  98867. * @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
  98868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98869. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98871. * @returns a PickingInfo
  98872. */
  98873. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98874. /** Use the given ray to pick a mesh in the scene
  98875. * @param ray The ray to use to pick meshes
  98876. * @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
  98877. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98879. * @returns a PickingInfo
  98880. */
  98881. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98882. /**
  98883. * Launch a ray to try to pick a mesh in the scene
  98884. * @param x X position on screen
  98885. * @param y Y position on screen
  98886. * @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
  98887. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98889. * @returns an array of PickingInfo
  98890. */
  98891. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98892. /**
  98893. * Launch a ray to try to pick a mesh in the scene
  98894. * @param ray Ray to use
  98895. * @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
  98896. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98897. * @returns an array of PickingInfo
  98898. */
  98899. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98900. /**
  98901. * Force the value of meshUnderPointer
  98902. * @param mesh defines the mesh to use
  98903. */
  98904. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98905. /**
  98906. * Gets the mesh under the pointer
  98907. * @returns a Mesh or null if no mesh is under the pointer
  98908. */
  98909. getPointerOverMesh(): Nullable<AbstractMesh>;
  98910. /** @hidden */
  98911. _rebuildGeometries(): void;
  98912. /** @hidden */
  98913. _rebuildTextures(): void;
  98914. private _getByTags;
  98915. /**
  98916. * Get a list of meshes by tags
  98917. * @param tagsQuery defines the tags query to use
  98918. * @param forEach defines a predicate used to filter results
  98919. * @returns an array of Mesh
  98920. */
  98921. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98922. /**
  98923. * Get a list of cameras by tags
  98924. * @param tagsQuery defines the tags query to use
  98925. * @param forEach defines a predicate used to filter results
  98926. * @returns an array of Camera
  98927. */
  98928. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98929. /**
  98930. * Get a list of lights by tags
  98931. * @param tagsQuery defines the tags query to use
  98932. * @param forEach defines a predicate used to filter results
  98933. * @returns an array of Light
  98934. */
  98935. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98936. /**
  98937. * Get a list of materials by tags
  98938. * @param tagsQuery defines the tags query to use
  98939. * @param forEach defines a predicate used to filter results
  98940. * @returns an array of Material
  98941. */
  98942. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98943. /**
  98944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98945. * This allowed control for front to back rendering or reversly depending of the special needs.
  98946. *
  98947. * @param renderingGroupId The rendering group id corresponding to its index
  98948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98951. */
  98952. 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;
  98953. /**
  98954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98955. *
  98956. * @param renderingGroupId The rendering group id corresponding to its index
  98957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98960. */
  98961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98962. /**
  98963. * Gets the current auto clear configuration for one rendering group of the rendering
  98964. * manager.
  98965. * @param index the rendering group index to get the information for
  98966. * @returns The auto clear setup for the requested rendering group
  98967. */
  98968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98969. private _blockMaterialDirtyMechanism;
  98970. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98971. blockMaterialDirtyMechanism: boolean;
  98972. /**
  98973. * Will flag all materials as dirty to trigger new shader compilation
  98974. * @param flag defines the flag used to specify which material part must be marked as dirty
  98975. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98976. */
  98977. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98978. /** @hidden */
  98979. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  98980. /** @hidden */
  98981. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98982. }
  98983. }
  98984. declare module BABYLON {
  98985. /**
  98986. * Set of assets to keep when moving a scene into an asset container.
  98987. */
  98988. export class KeepAssets extends AbstractScene {
  98989. }
  98990. /**
  98991. * Container with a set of assets that can be added or removed from a scene.
  98992. */
  98993. export class AssetContainer extends AbstractScene {
  98994. /**
  98995. * The scene the AssetContainer belongs to.
  98996. */
  98997. scene: Scene;
  98998. /**
  98999. * Instantiates an AssetContainer.
  99000. * @param scene The scene the AssetContainer belongs to.
  99001. */
  99002. constructor(scene: Scene);
  99003. /**
  99004. * Adds all the assets from the container to the scene.
  99005. */
  99006. addAllToScene(): void;
  99007. /**
  99008. * Removes all the assets in the container from the scene
  99009. */
  99010. removeAllFromScene(): void;
  99011. /**
  99012. * Disposes all the assets in the container
  99013. */
  99014. dispose(): void;
  99015. private _moveAssets;
  99016. /**
  99017. * Removes all the assets contained in the scene and adds them to the container.
  99018. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99019. */
  99020. moveAllFromScene(keepAssets?: KeepAssets): void;
  99021. /**
  99022. * 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.
  99023. * @returns the root mesh
  99024. */
  99025. createRootMesh(): Mesh;
  99026. }
  99027. }
  99028. declare module BABYLON {
  99029. /**
  99030. * Defines how the parser contract is defined.
  99031. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99032. */
  99033. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99034. /**
  99035. * Defines how the individual parser contract is defined.
  99036. * These parser can parse an individual asset
  99037. */
  99038. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99039. /**
  99040. * Base class of the scene acting as a container for the different elements composing a scene.
  99041. * This class is dynamically extended by the different components of the scene increasing
  99042. * flexibility and reducing coupling
  99043. */
  99044. export abstract class AbstractScene {
  99045. /**
  99046. * Stores the list of available parsers in the application.
  99047. */
  99048. private static _BabylonFileParsers;
  99049. /**
  99050. * Stores the list of available individual parsers in the application.
  99051. */
  99052. private static _IndividualBabylonFileParsers;
  99053. /**
  99054. * Adds a parser in the list of available ones
  99055. * @param name Defines the name of the parser
  99056. * @param parser Defines the parser to add
  99057. */
  99058. static AddParser(name: string, parser: BabylonFileParser): void;
  99059. /**
  99060. * Gets a general parser from the list of avaialble ones
  99061. * @param name Defines the name of the parser
  99062. * @returns the requested parser or null
  99063. */
  99064. static GetParser(name: string): Nullable<BabylonFileParser>;
  99065. /**
  99066. * Adds n individual parser in the list of available ones
  99067. * @param name Defines the name of the parser
  99068. * @param parser Defines the parser to add
  99069. */
  99070. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99071. /**
  99072. * Gets an individual parser from the list of avaialble ones
  99073. * @param name Defines the name of the parser
  99074. * @returns the requested parser or null
  99075. */
  99076. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99077. /**
  99078. * Parser json data and populate both a scene and its associated container object
  99079. * @param jsonData Defines the data to parse
  99080. * @param scene Defines the scene to parse the data for
  99081. * @param container Defines the container attached to the parsing sequence
  99082. * @param rootUrl Defines the root url of the data
  99083. */
  99084. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99085. /**
  99086. * Gets the list of root nodes (ie. nodes with no parent)
  99087. */
  99088. rootNodes: Node[];
  99089. /** All of the cameras added to this scene
  99090. * @see http://doc.babylonjs.com/babylon101/cameras
  99091. */
  99092. cameras: Camera[];
  99093. /**
  99094. * All of the lights added to this scene
  99095. * @see http://doc.babylonjs.com/babylon101/lights
  99096. */
  99097. lights: Light[];
  99098. /**
  99099. * All of the (abstract) meshes added to this scene
  99100. */
  99101. meshes: AbstractMesh[];
  99102. /**
  99103. * The list of skeletons added to the scene
  99104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99105. */
  99106. skeletons: Skeleton[];
  99107. /**
  99108. * All of the particle systems added to this scene
  99109. * @see http://doc.babylonjs.com/babylon101/particles
  99110. */
  99111. particleSystems: IParticleSystem[];
  99112. /**
  99113. * Gets a list of Animations associated with the scene
  99114. */
  99115. animations: Animation[];
  99116. /**
  99117. * All of the animation groups added to this scene
  99118. * @see http://doc.babylonjs.com/how_to/group
  99119. */
  99120. animationGroups: AnimationGroup[];
  99121. /**
  99122. * All of the multi-materials added to this scene
  99123. * @see http://doc.babylonjs.com/how_to/multi_materials
  99124. */
  99125. multiMaterials: MultiMaterial[];
  99126. /**
  99127. * All of the materials added to this scene
  99128. * In the context of a Scene, it is not supposed to be modified manually.
  99129. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99130. * Note also that the order of the Material wihin the array is not significant and might change.
  99131. * @see http://doc.babylonjs.com/babylon101/materials
  99132. */
  99133. materials: Material[];
  99134. /**
  99135. * The list of morph target managers added to the scene
  99136. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99137. */
  99138. morphTargetManagers: MorphTargetManager[];
  99139. /**
  99140. * The list of geometries used in the scene.
  99141. */
  99142. geometries: Geometry[];
  99143. /**
  99144. * All of the tranform nodes added to this scene
  99145. * In the context of a Scene, it is not supposed to be modified manually.
  99146. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99147. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99148. * @see http://doc.babylonjs.com/how_to/transformnode
  99149. */
  99150. transformNodes: TransformNode[];
  99151. /**
  99152. * ActionManagers available on the scene.
  99153. */
  99154. actionManagers: AbstractActionManager[];
  99155. /**
  99156. * Textures to keep.
  99157. */
  99158. textures: BaseTexture[];
  99159. /**
  99160. * Environment texture for the scene
  99161. */
  99162. environmentTexture: Nullable<BaseTexture>;
  99163. }
  99164. }
  99165. declare module BABYLON {
  99166. /**
  99167. * Interface used to define options for Sound class
  99168. */
  99169. export interface ISoundOptions {
  99170. /**
  99171. * Does the sound autoplay once loaded.
  99172. */
  99173. autoplay?: boolean;
  99174. /**
  99175. * Does the sound loop after it finishes playing once.
  99176. */
  99177. loop?: boolean;
  99178. /**
  99179. * Sound's volume
  99180. */
  99181. volume?: number;
  99182. /**
  99183. * Is it a spatial sound?
  99184. */
  99185. spatialSound?: boolean;
  99186. /**
  99187. * Maximum distance to hear that sound
  99188. */
  99189. maxDistance?: number;
  99190. /**
  99191. * Uses user defined attenuation function
  99192. */
  99193. useCustomAttenuation?: boolean;
  99194. /**
  99195. * Define the roll off factor of spatial sounds.
  99196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99197. */
  99198. rolloffFactor?: number;
  99199. /**
  99200. * Define the reference distance the sound should be heard perfectly.
  99201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99202. */
  99203. refDistance?: number;
  99204. /**
  99205. * Define the distance attenuation model the sound will follow.
  99206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99207. */
  99208. distanceModel?: string;
  99209. /**
  99210. * Defines the playback speed (1 by default)
  99211. */
  99212. playbackRate?: number;
  99213. /**
  99214. * Defines if the sound is from a streaming source
  99215. */
  99216. streaming?: boolean;
  99217. /**
  99218. * Defines an optional length (in seconds) inside the sound file
  99219. */
  99220. length?: number;
  99221. /**
  99222. * Defines an optional offset (in seconds) inside the sound file
  99223. */
  99224. offset?: number;
  99225. /**
  99226. * If true, URLs will not be required to state the audio file codec to use.
  99227. */
  99228. skipCodecCheck?: boolean;
  99229. }
  99230. /**
  99231. * Defines a sound that can be played in the application.
  99232. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99234. */
  99235. export class Sound {
  99236. /**
  99237. * The name of the sound in the scene.
  99238. */
  99239. name: string;
  99240. /**
  99241. * Does the sound autoplay once loaded.
  99242. */
  99243. autoplay: boolean;
  99244. /**
  99245. * Does the sound loop after it finishes playing once.
  99246. */
  99247. loop: boolean;
  99248. /**
  99249. * Does the sound use a custom attenuation curve to simulate the falloff
  99250. * happening when the source gets further away from the camera.
  99251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99252. */
  99253. useCustomAttenuation: boolean;
  99254. /**
  99255. * The sound track id this sound belongs to.
  99256. */
  99257. soundTrackId: number;
  99258. /**
  99259. * Is this sound currently played.
  99260. */
  99261. isPlaying: boolean;
  99262. /**
  99263. * Is this sound currently paused.
  99264. */
  99265. isPaused: boolean;
  99266. /**
  99267. * Does this sound enables spatial sound.
  99268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99269. */
  99270. spatialSound: boolean;
  99271. /**
  99272. * Define the reference distance the sound should be heard perfectly.
  99273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99274. */
  99275. refDistance: number;
  99276. /**
  99277. * Define the roll off factor of spatial sounds.
  99278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99279. */
  99280. rolloffFactor: number;
  99281. /**
  99282. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99284. */
  99285. maxDistance: number;
  99286. /**
  99287. * Define the distance attenuation model the sound will follow.
  99288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99289. */
  99290. distanceModel: string;
  99291. /**
  99292. * @hidden
  99293. * Back Compat
  99294. **/
  99295. onended: () => any;
  99296. /**
  99297. * Observable event when the current playing sound finishes.
  99298. */
  99299. onEndedObservable: Observable<Sound>;
  99300. private _panningModel;
  99301. private _playbackRate;
  99302. private _streaming;
  99303. private _startTime;
  99304. private _startOffset;
  99305. private _position;
  99306. /** @hidden */
  99307. _positionInEmitterSpace: boolean;
  99308. private _localDirection;
  99309. private _volume;
  99310. private _isReadyToPlay;
  99311. private _isDirectional;
  99312. private _readyToPlayCallback;
  99313. private _audioBuffer;
  99314. private _soundSource;
  99315. private _streamingSource;
  99316. private _soundPanner;
  99317. private _soundGain;
  99318. private _inputAudioNode;
  99319. private _outputAudioNode;
  99320. private _coneInnerAngle;
  99321. private _coneOuterAngle;
  99322. private _coneOuterGain;
  99323. private _scene;
  99324. private _connectedTransformNode;
  99325. private _customAttenuationFunction;
  99326. private _registerFunc;
  99327. private _isOutputConnected;
  99328. private _htmlAudioElement;
  99329. private _urlType;
  99330. private _length?;
  99331. private _offset?;
  99332. /** @hidden */
  99333. static _SceneComponentInitialization: (scene: Scene) => void;
  99334. /**
  99335. * Create a sound and attach it to a scene
  99336. * @param name Name of your sound
  99337. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99338. * @param scene defines the scene the sound belongs to
  99339. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99340. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99341. */
  99342. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99343. /**
  99344. * Release the sound and its associated resources
  99345. */
  99346. dispose(): void;
  99347. /**
  99348. * Gets if the sounds is ready to be played or not.
  99349. * @returns true if ready, otherwise false
  99350. */
  99351. isReady(): boolean;
  99352. private _soundLoaded;
  99353. /**
  99354. * Sets the data of the sound from an audiobuffer
  99355. * @param audioBuffer The audioBuffer containing the data
  99356. */
  99357. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99358. /**
  99359. * Updates the current sounds options such as maxdistance, loop...
  99360. * @param options A JSON object containing values named as the object properties
  99361. */
  99362. updateOptions(options: ISoundOptions): void;
  99363. private _createSpatialParameters;
  99364. private _updateSpatialParameters;
  99365. /**
  99366. * Switch the panning model to HRTF:
  99367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99369. */
  99370. switchPanningModelToHRTF(): void;
  99371. /**
  99372. * Switch the panning model to Equal Power:
  99373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99375. */
  99376. switchPanningModelToEqualPower(): void;
  99377. private _switchPanningModel;
  99378. /**
  99379. * Connect this sound to a sound track audio node like gain...
  99380. * @param soundTrackAudioNode the sound track audio node to connect to
  99381. */
  99382. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99383. /**
  99384. * Transform this sound into a directional source
  99385. * @param coneInnerAngle Size of the inner cone in degree
  99386. * @param coneOuterAngle Size of the outer cone in degree
  99387. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99388. */
  99389. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99390. /**
  99391. * Gets or sets the inner angle for the directional cone.
  99392. */
  99393. /**
  99394. * Gets or sets the inner angle for the directional cone.
  99395. */
  99396. directionalConeInnerAngle: number;
  99397. /**
  99398. * Gets or sets the outer angle for the directional cone.
  99399. */
  99400. /**
  99401. * Gets or sets the outer angle for the directional cone.
  99402. */
  99403. directionalConeOuterAngle: number;
  99404. /**
  99405. * Sets the position of the emitter if spatial sound is enabled
  99406. * @param newPosition Defines the new posisiton
  99407. */
  99408. setPosition(newPosition: Vector3): void;
  99409. /**
  99410. * Sets the local direction of the emitter if spatial sound is enabled
  99411. * @param newLocalDirection Defines the new local direction
  99412. */
  99413. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99414. private _updateDirection;
  99415. /** @hidden */
  99416. updateDistanceFromListener(): void;
  99417. /**
  99418. * Sets a new custom attenuation function for the sound.
  99419. * @param callback Defines the function used for the attenuation
  99420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99421. */
  99422. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99423. /**
  99424. * Play the sound
  99425. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99426. * @param offset (optional) Start the sound at a specific time in seconds
  99427. * @param length (optional) Sound duration (in seconds)
  99428. */
  99429. play(time?: number, offset?: number, length?: number): void;
  99430. private _onended;
  99431. /**
  99432. * Stop the sound
  99433. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99434. */
  99435. stop(time?: number): void;
  99436. /**
  99437. * Put the sound in pause
  99438. */
  99439. pause(): void;
  99440. /**
  99441. * Sets a dedicated volume for this sounds
  99442. * @param newVolume Define the new volume of the sound
  99443. * @param time Define time for gradual change to new volume
  99444. */
  99445. setVolume(newVolume: number, time?: number): void;
  99446. /**
  99447. * Set the sound play back rate
  99448. * @param newPlaybackRate Define the playback rate the sound should be played at
  99449. */
  99450. setPlaybackRate(newPlaybackRate: number): void;
  99451. /**
  99452. * Gets the volume of the sound.
  99453. * @returns the volume of the sound
  99454. */
  99455. getVolume(): number;
  99456. /**
  99457. * Attach the sound to a dedicated mesh
  99458. * @param transformNode The transform node to connect the sound with
  99459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99460. */
  99461. attachToMesh(transformNode: TransformNode): void;
  99462. /**
  99463. * Detach the sound from the previously attached mesh
  99464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99465. */
  99466. detachFromMesh(): void;
  99467. private _onRegisterAfterWorldMatrixUpdate;
  99468. /**
  99469. * Clone the current sound in the scene.
  99470. * @returns the new sound clone
  99471. */
  99472. clone(): Nullable<Sound>;
  99473. /**
  99474. * Gets the current underlying audio buffer containing the data
  99475. * @returns the audio buffer
  99476. */
  99477. getAudioBuffer(): Nullable<AudioBuffer>;
  99478. /**
  99479. * Serializes the Sound in a JSON representation
  99480. * @returns the JSON representation of the sound
  99481. */
  99482. serialize(): any;
  99483. /**
  99484. * Parse a JSON representation of a sound to innstantiate in a given scene
  99485. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99486. * @param scene Define the scene the new parsed sound should be created in
  99487. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99488. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99489. * @returns the newly parsed sound
  99490. */
  99491. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99492. }
  99493. }
  99494. declare module BABYLON {
  99495. /**
  99496. * This defines an action helpful to play a defined sound on a triggered action.
  99497. */
  99498. export class PlaySoundAction extends Action {
  99499. private _sound;
  99500. /**
  99501. * Instantiate the action
  99502. * @param triggerOptions defines the trigger options
  99503. * @param sound defines the sound to play
  99504. * @param condition defines the trigger related conditions
  99505. */
  99506. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99507. /** @hidden */
  99508. _prepare(): void;
  99509. /**
  99510. * Execute the action and play the sound.
  99511. */
  99512. execute(): void;
  99513. /**
  99514. * Serializes the actions and its related information.
  99515. * @param parent defines the object to serialize in
  99516. * @returns the serialized object
  99517. */
  99518. serialize(parent: any): any;
  99519. }
  99520. /**
  99521. * This defines an action helpful to stop a defined sound on a triggered action.
  99522. */
  99523. export class StopSoundAction extends Action {
  99524. private _sound;
  99525. /**
  99526. * Instantiate the action
  99527. * @param triggerOptions defines the trigger options
  99528. * @param sound defines the sound to stop
  99529. * @param condition defines the trigger related conditions
  99530. */
  99531. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99532. /** @hidden */
  99533. _prepare(): void;
  99534. /**
  99535. * Execute the action and stop the sound.
  99536. */
  99537. execute(): void;
  99538. /**
  99539. * Serializes the actions and its related information.
  99540. * @param parent defines the object to serialize in
  99541. * @returns the serialized object
  99542. */
  99543. serialize(parent: any): any;
  99544. }
  99545. }
  99546. declare module BABYLON {
  99547. /**
  99548. * This defines an action responsible to change the value of a property
  99549. * by interpolating between its current value and the newly set one once triggered.
  99550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99551. */
  99552. export class InterpolateValueAction extends Action {
  99553. /**
  99554. * Defines the path of the property where the value should be interpolated
  99555. */
  99556. propertyPath: string;
  99557. /**
  99558. * Defines the target value at the end of the interpolation.
  99559. */
  99560. value: any;
  99561. /**
  99562. * Defines the time it will take for the property to interpolate to the value.
  99563. */
  99564. duration: number;
  99565. /**
  99566. * Defines if the other scene animations should be stopped when the action has been triggered
  99567. */
  99568. stopOtherAnimations?: boolean;
  99569. /**
  99570. * Defines a callback raised once the interpolation animation has been done.
  99571. */
  99572. onInterpolationDone?: () => void;
  99573. /**
  99574. * Observable triggered once the interpolation animation has been done.
  99575. */
  99576. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99577. private _target;
  99578. private _effectiveTarget;
  99579. private _property;
  99580. /**
  99581. * Instantiate the action
  99582. * @param triggerOptions defines the trigger options
  99583. * @param target defines the object containing the value to interpolate
  99584. * @param propertyPath defines the path to the property in the target object
  99585. * @param value defines the target value at the end of the interpolation
  99586. * @param duration deines the time it will take for the property to interpolate to the value.
  99587. * @param condition defines the trigger related conditions
  99588. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99589. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99590. */
  99591. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99592. /** @hidden */
  99593. _prepare(): void;
  99594. /**
  99595. * Execute the action starts the value interpolation.
  99596. */
  99597. execute(): void;
  99598. /**
  99599. * Serializes the actions and its related information.
  99600. * @param parent defines the object to serialize in
  99601. * @returns the serialized object
  99602. */
  99603. serialize(parent: any): any;
  99604. }
  99605. }
  99606. declare module BABYLON {
  99607. /**
  99608. * Options allowed during the creation of a sound track.
  99609. */
  99610. export interface ISoundTrackOptions {
  99611. /**
  99612. * The volume the sound track should take during creation
  99613. */
  99614. volume?: number;
  99615. /**
  99616. * Define if the sound track is the main sound track of the scene
  99617. */
  99618. mainTrack?: boolean;
  99619. }
  99620. /**
  99621. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99622. * It will be also used in a future release to apply effects on a specific track.
  99623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99624. */
  99625. export class SoundTrack {
  99626. /**
  99627. * The unique identifier of the sound track in the scene.
  99628. */
  99629. id: number;
  99630. /**
  99631. * The list of sounds included in the sound track.
  99632. */
  99633. soundCollection: Array<Sound>;
  99634. private _outputAudioNode;
  99635. private _scene;
  99636. private _isMainTrack;
  99637. private _connectedAnalyser;
  99638. private _options;
  99639. private _isInitialized;
  99640. /**
  99641. * Creates a new sound track.
  99642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99643. * @param scene Define the scene the sound track belongs to
  99644. * @param options
  99645. */
  99646. constructor(scene: Scene, options?: ISoundTrackOptions);
  99647. private _initializeSoundTrackAudioGraph;
  99648. /**
  99649. * Release the sound track and its associated resources
  99650. */
  99651. dispose(): void;
  99652. /**
  99653. * Adds a sound to this sound track
  99654. * @param sound define the cound to add
  99655. * @ignoreNaming
  99656. */
  99657. AddSound(sound: Sound): void;
  99658. /**
  99659. * Removes a sound to this sound track
  99660. * @param sound define the cound to remove
  99661. * @ignoreNaming
  99662. */
  99663. RemoveSound(sound: Sound): void;
  99664. /**
  99665. * Set a global volume for the full sound track.
  99666. * @param newVolume Define the new volume of the sound track
  99667. */
  99668. setVolume(newVolume: number): void;
  99669. /**
  99670. * Switch the panning model to HRTF:
  99671. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99673. */
  99674. switchPanningModelToHRTF(): void;
  99675. /**
  99676. * Switch the panning model to Equal Power:
  99677. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99679. */
  99680. switchPanningModelToEqualPower(): void;
  99681. /**
  99682. * Connect the sound track to an audio analyser allowing some amazing
  99683. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99685. * @param analyser The analyser to connect to the engine
  99686. */
  99687. connectToAnalyser(analyser: Analyser): void;
  99688. }
  99689. }
  99690. declare module BABYLON {
  99691. interface AbstractScene {
  99692. /**
  99693. * The list of sounds used in the scene.
  99694. */
  99695. sounds: Nullable<Array<Sound>>;
  99696. }
  99697. interface Scene {
  99698. /**
  99699. * @hidden
  99700. * Backing field
  99701. */
  99702. _mainSoundTrack: SoundTrack;
  99703. /**
  99704. * The main sound track played by the scene.
  99705. * It cotains your primary collection of sounds.
  99706. */
  99707. mainSoundTrack: SoundTrack;
  99708. /**
  99709. * The list of sound tracks added to the scene
  99710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99711. */
  99712. soundTracks: Nullable<Array<SoundTrack>>;
  99713. /**
  99714. * Gets a sound using a given name
  99715. * @param name defines the name to search for
  99716. * @return the found sound or null if not found at all.
  99717. */
  99718. getSoundByName(name: string): Nullable<Sound>;
  99719. /**
  99720. * Gets or sets if audio support is enabled
  99721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99722. */
  99723. audioEnabled: boolean;
  99724. /**
  99725. * Gets or sets if audio will be output to headphones
  99726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99727. */
  99728. headphone: boolean;
  99729. }
  99730. /**
  99731. * Defines the sound scene component responsible to manage any sounds
  99732. * in a given scene.
  99733. */
  99734. export class AudioSceneComponent implements ISceneSerializableComponent {
  99735. /**
  99736. * The component name helpfull to identify the component in the list of scene components.
  99737. */
  99738. readonly name: string;
  99739. /**
  99740. * The scene the component belongs to.
  99741. */
  99742. scene: Scene;
  99743. private _audioEnabled;
  99744. /**
  99745. * Gets whether audio is enabled or not.
  99746. * Please use related enable/disable method to switch state.
  99747. */
  99748. readonly audioEnabled: boolean;
  99749. private _headphone;
  99750. /**
  99751. * Gets whether audio is outputing to headphone or not.
  99752. * Please use the according Switch methods to change output.
  99753. */
  99754. readonly headphone: boolean;
  99755. /**
  99756. * Creates a new instance of the component for the given scene
  99757. * @param scene Defines the scene to register the component in
  99758. */
  99759. constructor(scene: Scene);
  99760. /**
  99761. * Registers the component in a given scene
  99762. */
  99763. register(): void;
  99764. /**
  99765. * Rebuilds the elements related to this component in case of
  99766. * context lost for instance.
  99767. */
  99768. rebuild(): void;
  99769. /**
  99770. * Serializes the component data to the specified json object
  99771. * @param serializationObject The object to serialize to
  99772. */
  99773. serialize(serializationObject: any): void;
  99774. /**
  99775. * Adds all the elements from the container to the scene
  99776. * @param container the container holding the elements
  99777. */
  99778. addFromContainer(container: AbstractScene): void;
  99779. /**
  99780. * Removes all the elements in the container from the scene
  99781. * @param container contains the elements to remove
  99782. * @param dispose if the removed element should be disposed (default: false)
  99783. */
  99784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99785. /**
  99786. * Disposes the component and the associated ressources.
  99787. */
  99788. dispose(): void;
  99789. /**
  99790. * Disables audio in the associated scene.
  99791. */
  99792. disableAudio(): void;
  99793. /**
  99794. * Enables audio in the associated scene.
  99795. */
  99796. enableAudio(): void;
  99797. /**
  99798. * Switch audio to headphone output.
  99799. */
  99800. switchAudioModeForHeadphones(): void;
  99801. /**
  99802. * Switch audio to normal speakers.
  99803. */
  99804. switchAudioModeForNormalSpeakers(): void;
  99805. private _afterRender;
  99806. }
  99807. }
  99808. declare module BABYLON {
  99809. /**
  99810. * Wraps one or more Sound objects and selects one with random weight for playback.
  99811. */
  99812. export class WeightedSound {
  99813. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99814. loop: boolean;
  99815. private _coneInnerAngle;
  99816. private _coneOuterAngle;
  99817. private _volume;
  99818. /** A Sound is currently playing. */
  99819. isPlaying: boolean;
  99820. /** A Sound is currently paused. */
  99821. isPaused: boolean;
  99822. private _sounds;
  99823. private _weights;
  99824. private _currentIndex?;
  99825. /**
  99826. * Creates a new WeightedSound from the list of sounds given.
  99827. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99828. * @param sounds Array of Sounds that will be selected from.
  99829. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99830. */
  99831. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99832. /**
  99833. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99834. */
  99835. /**
  99836. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99837. */
  99838. directionalConeInnerAngle: number;
  99839. /**
  99840. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99841. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99842. */
  99843. /**
  99844. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99845. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99846. */
  99847. directionalConeOuterAngle: number;
  99848. /**
  99849. * Playback volume.
  99850. */
  99851. /**
  99852. * Playback volume.
  99853. */
  99854. volume: number;
  99855. private _onended;
  99856. /**
  99857. * Suspend playback
  99858. */
  99859. pause(): void;
  99860. /**
  99861. * Stop playback
  99862. */
  99863. stop(): void;
  99864. /**
  99865. * Start playback.
  99866. * @param startOffset Position the clip head at a specific time in seconds.
  99867. */
  99868. play(startOffset?: number): void;
  99869. }
  99870. }
  99871. declare module BABYLON {
  99872. /**
  99873. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99875. */
  99876. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99877. /**
  99878. * Gets the name of the behavior.
  99879. */
  99880. readonly name: string;
  99881. /**
  99882. * The easing function used by animations
  99883. */
  99884. static EasingFunction: BackEase;
  99885. /**
  99886. * The easing mode used by animations
  99887. */
  99888. static EasingMode: number;
  99889. /**
  99890. * The duration of the animation, in milliseconds
  99891. */
  99892. transitionDuration: number;
  99893. /**
  99894. * Length of the distance animated by the transition when lower radius is reached
  99895. */
  99896. lowerRadiusTransitionRange: number;
  99897. /**
  99898. * Length of the distance animated by the transition when upper radius is reached
  99899. */
  99900. upperRadiusTransitionRange: number;
  99901. private _autoTransitionRange;
  99902. /**
  99903. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99904. */
  99905. /**
  99906. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99907. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99908. */
  99909. autoTransitionRange: boolean;
  99910. private _attachedCamera;
  99911. private _onAfterCheckInputsObserver;
  99912. private _onMeshTargetChangedObserver;
  99913. /**
  99914. * Initializes the behavior.
  99915. */
  99916. init(): void;
  99917. /**
  99918. * Attaches the behavior to its arc rotate camera.
  99919. * @param camera Defines the camera to attach the behavior to
  99920. */
  99921. attach(camera: ArcRotateCamera): void;
  99922. /**
  99923. * Detaches the behavior from its current arc rotate camera.
  99924. */
  99925. detach(): void;
  99926. private _radiusIsAnimating;
  99927. private _radiusBounceTransition;
  99928. private _animatables;
  99929. private _cachedWheelPrecision;
  99930. /**
  99931. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99932. * @param radiusLimit The limit to check against.
  99933. * @return Bool to indicate if at limit.
  99934. */
  99935. private _isRadiusAtLimit;
  99936. /**
  99937. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99938. * @param radiusDelta The delta by which to animate to. Can be negative.
  99939. */
  99940. private _applyBoundRadiusAnimation;
  99941. /**
  99942. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99943. */
  99944. protected _clearAnimationLocks(): void;
  99945. /**
  99946. * Stops and removes all animations that have been applied to the camera
  99947. */
  99948. stopAllAnimations(): void;
  99949. }
  99950. }
  99951. declare module BABYLON {
  99952. /**
  99953. * 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.
  99954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99955. */
  99956. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99957. /**
  99958. * Gets the name of the behavior.
  99959. */
  99960. readonly name: string;
  99961. private _mode;
  99962. private _radiusScale;
  99963. private _positionScale;
  99964. private _defaultElevation;
  99965. private _elevationReturnTime;
  99966. private _elevationReturnWaitTime;
  99967. private _zoomStopsAnimation;
  99968. private _framingTime;
  99969. /**
  99970. * The easing function used by animations
  99971. */
  99972. static EasingFunction: ExponentialEase;
  99973. /**
  99974. * The easing mode used by animations
  99975. */
  99976. static EasingMode: number;
  99977. /**
  99978. * Sets the current mode used by the behavior
  99979. */
  99980. /**
  99981. * Gets current mode used by the behavior.
  99982. */
  99983. mode: number;
  99984. /**
  99985. * Sets the scale applied to the radius (1 by default)
  99986. */
  99987. /**
  99988. * Gets the scale applied to the radius
  99989. */
  99990. radiusScale: number;
  99991. /**
  99992. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99993. */
  99994. /**
  99995. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99996. */
  99997. positionScale: number;
  99998. /**
  99999. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100000. * behaviour is triggered, in radians.
  100001. */
  100002. /**
  100003. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100004. * behaviour is triggered, in radians.
  100005. */
  100006. defaultElevation: number;
  100007. /**
  100008. * Sets the time (in milliseconds) taken to return to the default beta position.
  100009. * Negative value indicates camera should not return to default.
  100010. */
  100011. /**
  100012. * Gets the time (in milliseconds) taken to return to the default beta position.
  100013. * Negative value indicates camera should not return to default.
  100014. */
  100015. elevationReturnTime: number;
  100016. /**
  100017. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100018. */
  100019. /**
  100020. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100021. */
  100022. elevationReturnWaitTime: number;
  100023. /**
  100024. * Sets the flag that indicates if user zooming should stop animation.
  100025. */
  100026. /**
  100027. * Gets the flag that indicates if user zooming should stop animation.
  100028. */
  100029. zoomStopsAnimation: boolean;
  100030. /**
  100031. * Sets the transition time when framing the mesh, in milliseconds
  100032. */
  100033. /**
  100034. * Gets the transition time when framing the mesh, in milliseconds
  100035. */
  100036. framingTime: number;
  100037. /**
  100038. * Define if the behavior should automatically change the configured
  100039. * camera limits and sensibilities.
  100040. */
  100041. autoCorrectCameraLimitsAndSensibility: boolean;
  100042. private _onPrePointerObservableObserver;
  100043. private _onAfterCheckInputsObserver;
  100044. private _onMeshTargetChangedObserver;
  100045. private _attachedCamera;
  100046. private _isPointerDown;
  100047. private _lastInteractionTime;
  100048. /**
  100049. * Initializes the behavior.
  100050. */
  100051. init(): void;
  100052. /**
  100053. * Attaches the behavior to its arc rotate camera.
  100054. * @param camera Defines the camera to attach the behavior to
  100055. */
  100056. attach(camera: ArcRotateCamera): void;
  100057. /**
  100058. * Detaches the behavior from its current arc rotate camera.
  100059. */
  100060. detach(): void;
  100061. private _animatables;
  100062. private _betaIsAnimating;
  100063. private _betaTransition;
  100064. private _radiusTransition;
  100065. private _vectorTransition;
  100066. /**
  100067. * Targets the given mesh and updates zoom level accordingly.
  100068. * @param mesh The mesh to target.
  100069. * @param radius Optional. If a cached radius position already exists, overrides default.
  100070. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100073. */
  100074. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100075. /**
  100076. * Targets the given mesh with its children and updates zoom level accordingly.
  100077. * @param mesh The mesh to target.
  100078. * @param radius Optional. If a cached radius position already exists, overrides default.
  100079. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100080. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100081. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100082. */
  100083. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100084. /**
  100085. * Targets the given meshes with their children and updates zoom level accordingly.
  100086. * @param meshes The mesh to target.
  100087. * @param radius Optional. If a cached radius position already exists, overrides default.
  100088. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100089. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100090. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100091. */
  100092. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100093. /**
  100094. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100095. * @param minimumWorld Determines the smaller position of the bounding box extend
  100096. * @param maximumWorld Determines the bigger position of the bounding box extend
  100097. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100098. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100099. */
  100100. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100101. /**
  100102. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100103. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100104. * frustum width.
  100105. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100106. * to fully enclose the mesh in the viewing frustum.
  100107. */
  100108. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100109. /**
  100110. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100111. * is automatically returned to its default position (expected to be above ground plane).
  100112. */
  100113. private _maintainCameraAboveGround;
  100114. /**
  100115. * Returns the frustum slope based on the canvas ratio and camera FOV
  100116. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100117. */
  100118. private _getFrustumSlope;
  100119. /**
  100120. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100121. */
  100122. private _clearAnimationLocks;
  100123. /**
  100124. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100125. */
  100126. private _applyUserInteraction;
  100127. /**
  100128. * Stops and removes all animations that have been applied to the camera
  100129. */
  100130. stopAllAnimations(): void;
  100131. /**
  100132. * Gets a value indicating if the user is moving the camera
  100133. */
  100134. readonly isUserIsMoving: boolean;
  100135. /**
  100136. * The camera can move all the way towards the mesh.
  100137. */
  100138. static IgnoreBoundsSizeMode: number;
  100139. /**
  100140. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100141. */
  100142. static FitFrustumSidesMode: number;
  100143. }
  100144. }
  100145. declare module BABYLON {
  100146. /**
  100147. * Base class for Camera Pointer Inputs.
  100148. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100149. * for example usage.
  100150. */
  100151. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100152. /**
  100153. * Defines the camera the input is attached to.
  100154. */
  100155. abstract camera: Camera;
  100156. /**
  100157. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100158. */
  100159. protected _altKey: boolean;
  100160. protected _ctrlKey: boolean;
  100161. protected _metaKey: boolean;
  100162. protected _shiftKey: boolean;
  100163. /**
  100164. * Which mouse buttons were pressed at time of last mouse event.
  100165. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100166. */
  100167. protected _buttonsPressed: number;
  100168. /**
  100169. * Defines the buttons associated with the input to handle camera move.
  100170. */
  100171. buttons: number[];
  100172. /**
  100173. * Attach the input controls to a specific dom element to get the input from.
  100174. * @param element Defines the element the controls should be listened from
  100175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100176. */
  100177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100178. /**
  100179. * Detach the current controls from the specified dom element.
  100180. * @param element Defines the element to stop listening the inputs from
  100181. */
  100182. detachControl(element: Nullable<HTMLElement>): void;
  100183. /**
  100184. * Gets the class name of the current input.
  100185. * @returns the class name
  100186. */
  100187. getClassName(): string;
  100188. /**
  100189. * Get the friendly name associated with the input class.
  100190. * @returns the input friendly name
  100191. */
  100192. getSimpleName(): string;
  100193. /**
  100194. * Called on pointer POINTERDOUBLETAP event.
  100195. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100196. */
  100197. protected onDoubleTap(type: string): void;
  100198. /**
  100199. * Called on pointer POINTERMOVE event if only a single touch is active.
  100200. * Override this method to provide functionality.
  100201. */
  100202. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100203. /**
  100204. * Called on pointer POINTERMOVE event if multiple touches are active.
  100205. * Override this method to provide functionality.
  100206. */
  100207. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100208. /**
  100209. * Called on JS contextmenu event.
  100210. * Override this method to provide functionality.
  100211. */
  100212. protected onContextMenu(evt: PointerEvent): void;
  100213. /**
  100214. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100215. * press.
  100216. * Override this method to provide functionality.
  100217. */
  100218. protected onButtonDown(evt: PointerEvent): void;
  100219. /**
  100220. * Called each time a new POINTERUP event occurs. Ie, for each button
  100221. * release.
  100222. * Override this method to provide functionality.
  100223. */
  100224. protected onButtonUp(evt: PointerEvent): void;
  100225. /**
  100226. * Called when window becomes inactive.
  100227. * Override this method to provide functionality.
  100228. */
  100229. protected onLostFocus(): void;
  100230. private _pointerInput;
  100231. private _observer;
  100232. private _onLostFocus;
  100233. private pointA;
  100234. private pointB;
  100235. }
  100236. }
  100237. declare module BABYLON {
  100238. /**
  100239. * Manage the pointers inputs to control an arc rotate camera.
  100240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100241. */
  100242. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100243. /**
  100244. * Defines the camera the input is attached to.
  100245. */
  100246. camera: ArcRotateCamera;
  100247. /**
  100248. * Gets the class name of the current input.
  100249. * @returns the class name
  100250. */
  100251. getClassName(): string;
  100252. /**
  100253. * Defines the buttons associated with the input to handle camera move.
  100254. */
  100255. buttons: number[];
  100256. /**
  100257. * Defines the pointer angular sensibility along the X axis or how fast is
  100258. * the camera rotating.
  100259. */
  100260. angularSensibilityX: number;
  100261. /**
  100262. * Defines the pointer angular sensibility along the Y axis or how fast is
  100263. * the camera rotating.
  100264. */
  100265. angularSensibilityY: number;
  100266. /**
  100267. * Defines the pointer pinch precision or how fast is the camera zooming.
  100268. */
  100269. pinchPrecision: number;
  100270. /**
  100271. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100272. * from 0.
  100273. * It defines the percentage of current camera.radius to use as delta when
  100274. * pinch zoom is used.
  100275. */
  100276. pinchDeltaPercentage: number;
  100277. /**
  100278. * Defines the pointer panning sensibility or how fast is the camera moving.
  100279. */
  100280. panningSensibility: number;
  100281. /**
  100282. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100283. */
  100284. multiTouchPanning: boolean;
  100285. /**
  100286. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100287. * zoom (pinch) through multitouch.
  100288. */
  100289. multiTouchPanAndZoom: boolean;
  100290. /**
  100291. * Revers pinch action direction.
  100292. */
  100293. pinchInwards: boolean;
  100294. private _isPanClick;
  100295. private _twoFingerActivityCount;
  100296. private _isPinching;
  100297. /**
  100298. * Called on pointer POINTERMOVE event if only a single touch is active.
  100299. */
  100300. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100301. /**
  100302. * Called on pointer POINTERDOUBLETAP event.
  100303. */
  100304. protected onDoubleTap(type: string): void;
  100305. /**
  100306. * Called on pointer POINTERMOVE event if multiple touches are active.
  100307. */
  100308. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100309. /**
  100310. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100311. * press.
  100312. */
  100313. protected onButtonDown(evt: PointerEvent): void;
  100314. /**
  100315. * Called each time a new POINTERUP event occurs. Ie, for each button
  100316. * release.
  100317. */
  100318. protected onButtonUp(evt: PointerEvent): void;
  100319. /**
  100320. * Called when window becomes inactive.
  100321. */
  100322. protected onLostFocus(): void;
  100323. }
  100324. }
  100325. declare module BABYLON {
  100326. /**
  100327. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100329. */
  100330. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100331. /**
  100332. * Defines the camera the input is attached to.
  100333. */
  100334. camera: ArcRotateCamera;
  100335. /**
  100336. * Defines the list of key codes associated with the up action (increase alpha)
  100337. */
  100338. keysUp: number[];
  100339. /**
  100340. * Defines the list of key codes associated with the down action (decrease alpha)
  100341. */
  100342. keysDown: number[];
  100343. /**
  100344. * Defines the list of key codes associated with the left action (increase beta)
  100345. */
  100346. keysLeft: number[];
  100347. /**
  100348. * Defines the list of key codes associated with the right action (decrease beta)
  100349. */
  100350. keysRight: number[];
  100351. /**
  100352. * Defines the list of key codes associated with the reset action.
  100353. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100354. */
  100355. keysReset: number[];
  100356. /**
  100357. * Defines the panning sensibility of the inputs.
  100358. * (How fast is the camera paning)
  100359. */
  100360. panningSensibility: number;
  100361. /**
  100362. * Defines the zooming sensibility of the inputs.
  100363. * (How fast is the camera zooming)
  100364. */
  100365. zoomingSensibility: number;
  100366. /**
  100367. * Defines wether maintaining the alt key down switch the movement mode from
  100368. * orientation to zoom.
  100369. */
  100370. useAltToZoom: boolean;
  100371. /**
  100372. * Rotation speed of the camera
  100373. */
  100374. angularSpeed: number;
  100375. private _keys;
  100376. private _ctrlPressed;
  100377. private _altPressed;
  100378. private _onCanvasBlurObserver;
  100379. private _onKeyboardObserver;
  100380. private _engine;
  100381. private _scene;
  100382. /**
  100383. * Attach the input controls to a specific dom element to get the input from.
  100384. * @param element Defines the element the controls should be listened from
  100385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100386. */
  100387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100388. /**
  100389. * Detach the current controls from the specified dom element.
  100390. * @param element Defines the element to stop listening the inputs from
  100391. */
  100392. detachControl(element: Nullable<HTMLElement>): void;
  100393. /**
  100394. * Update the current camera state depending on the inputs that have been used this frame.
  100395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100396. */
  100397. checkInputs(): void;
  100398. /**
  100399. * Gets the class name of the current intput.
  100400. * @returns the class name
  100401. */
  100402. getClassName(): string;
  100403. /**
  100404. * Get the friendly name associated with the input class.
  100405. * @returns the input friendly name
  100406. */
  100407. getSimpleName(): string;
  100408. }
  100409. }
  100410. declare module BABYLON {
  100411. /**
  100412. * Manage the mouse wheel inputs to control an arc rotate camera.
  100413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100414. */
  100415. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100416. /**
  100417. * Defines the camera the input is attached to.
  100418. */
  100419. camera: ArcRotateCamera;
  100420. /**
  100421. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100422. */
  100423. wheelPrecision: number;
  100424. /**
  100425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100427. */
  100428. wheelDeltaPercentage: number;
  100429. private _wheel;
  100430. private _observer;
  100431. private computeDeltaFromMouseWheelLegacyEvent;
  100432. /**
  100433. * Attach the input controls to a specific dom element to get the input from.
  100434. * @param element Defines the element the controls should be listened from
  100435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100436. */
  100437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100438. /**
  100439. * Detach the current controls from the specified dom element.
  100440. * @param element Defines the element to stop listening the inputs from
  100441. */
  100442. detachControl(element: Nullable<HTMLElement>): void;
  100443. /**
  100444. * Gets the class name of the current intput.
  100445. * @returns the class name
  100446. */
  100447. getClassName(): string;
  100448. /**
  100449. * Get the friendly name associated with the input class.
  100450. * @returns the input friendly name
  100451. */
  100452. getSimpleName(): string;
  100453. }
  100454. }
  100455. declare module BABYLON {
  100456. /**
  100457. * Default Inputs manager for the ArcRotateCamera.
  100458. * It groups all the default supported inputs for ease of use.
  100459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100460. */
  100461. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100462. /**
  100463. * Instantiates a new ArcRotateCameraInputsManager.
  100464. * @param camera Defines the camera the inputs belong to
  100465. */
  100466. constructor(camera: ArcRotateCamera);
  100467. /**
  100468. * Add mouse wheel input support to the input manager.
  100469. * @returns the current input manager
  100470. */
  100471. addMouseWheel(): ArcRotateCameraInputsManager;
  100472. /**
  100473. * Add pointers input support to the input manager.
  100474. * @returns the current input manager
  100475. */
  100476. addPointers(): ArcRotateCameraInputsManager;
  100477. /**
  100478. * Add keyboard input support to the input manager.
  100479. * @returns the current input manager
  100480. */
  100481. addKeyboard(): ArcRotateCameraInputsManager;
  100482. }
  100483. }
  100484. declare module BABYLON {
  100485. /**
  100486. * This represents an orbital type of camera.
  100487. *
  100488. * 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.
  100489. * 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.
  100490. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100491. */
  100492. export class ArcRotateCamera extends TargetCamera {
  100493. /**
  100494. * Defines the rotation angle of the camera along the longitudinal axis.
  100495. */
  100496. alpha: number;
  100497. /**
  100498. * Defines the rotation angle of the camera along the latitudinal axis.
  100499. */
  100500. beta: number;
  100501. /**
  100502. * Defines the radius of the camera from it s target point.
  100503. */
  100504. radius: number;
  100505. protected _target: Vector3;
  100506. protected _targetHost: Nullable<AbstractMesh>;
  100507. /**
  100508. * Defines the target point of the camera.
  100509. * The camera looks towards it form the radius distance.
  100510. */
  100511. target: Vector3;
  100512. /**
  100513. * Define the current local position of the camera in the scene
  100514. */
  100515. position: Vector3;
  100516. protected _upVector: Vector3;
  100517. protected _upToYMatrix: Matrix;
  100518. protected _YToUpMatrix: Matrix;
  100519. /**
  100520. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100521. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100522. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100523. */
  100524. upVector: Vector3;
  100525. /**
  100526. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100527. */
  100528. setMatUp(): void;
  100529. /**
  100530. * Current inertia value on the longitudinal axis.
  100531. * The bigger this number the longer it will take for the camera to stop.
  100532. */
  100533. inertialAlphaOffset: number;
  100534. /**
  100535. * Current inertia value on the latitudinal axis.
  100536. * The bigger this number the longer it will take for the camera to stop.
  100537. */
  100538. inertialBetaOffset: number;
  100539. /**
  100540. * Current inertia value on the radius axis.
  100541. * The bigger this number the longer it will take for the camera to stop.
  100542. */
  100543. inertialRadiusOffset: number;
  100544. /**
  100545. * Minimum allowed angle on the longitudinal axis.
  100546. * This can help limiting how the Camera is able to move in the scene.
  100547. */
  100548. lowerAlphaLimit: Nullable<number>;
  100549. /**
  100550. * Maximum allowed angle on the longitudinal axis.
  100551. * This can help limiting how the Camera is able to move in the scene.
  100552. */
  100553. upperAlphaLimit: Nullable<number>;
  100554. /**
  100555. * Minimum allowed angle on the latitudinal axis.
  100556. * This can help limiting how the Camera is able to move in the scene.
  100557. */
  100558. lowerBetaLimit: number;
  100559. /**
  100560. * Maximum allowed angle on the latitudinal axis.
  100561. * This can help limiting how the Camera is able to move in the scene.
  100562. */
  100563. upperBetaLimit: number;
  100564. /**
  100565. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100566. * This can help limiting how the Camera is able to move in the scene.
  100567. */
  100568. lowerRadiusLimit: Nullable<number>;
  100569. /**
  100570. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100571. * This can help limiting how the Camera is able to move in the scene.
  100572. */
  100573. upperRadiusLimit: Nullable<number>;
  100574. /**
  100575. * Defines the current inertia value used during panning of the camera along the X axis.
  100576. */
  100577. inertialPanningX: number;
  100578. /**
  100579. * Defines the current inertia value used during panning of the camera along the Y axis.
  100580. */
  100581. inertialPanningY: number;
  100582. /**
  100583. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100584. * Basically if your fingers moves away from more than this distance you will be considered
  100585. * in pinch mode.
  100586. */
  100587. pinchToPanMaxDistance: number;
  100588. /**
  100589. * Defines the maximum distance the camera can pan.
  100590. * This could help keeping the cammera always in your scene.
  100591. */
  100592. panningDistanceLimit: Nullable<number>;
  100593. /**
  100594. * Defines the target of the camera before paning.
  100595. */
  100596. panningOriginTarget: Vector3;
  100597. /**
  100598. * Defines the value of the inertia used during panning.
  100599. * 0 would mean stop inertia and one would mean no decelleration at all.
  100600. */
  100601. panningInertia: number;
  100602. /**
  100603. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100604. */
  100605. angularSensibilityX: number;
  100606. /**
  100607. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100608. */
  100609. angularSensibilityY: number;
  100610. /**
  100611. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100612. */
  100613. pinchPrecision: number;
  100614. /**
  100615. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100616. * It will be used instead of pinchDeltaPrecision if different from 0.
  100617. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100618. */
  100619. pinchDeltaPercentage: number;
  100620. /**
  100621. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100622. */
  100623. panningSensibility: number;
  100624. /**
  100625. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100626. */
  100627. keysUp: number[];
  100628. /**
  100629. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100630. */
  100631. keysDown: number[];
  100632. /**
  100633. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100634. */
  100635. keysLeft: number[];
  100636. /**
  100637. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100638. */
  100639. keysRight: number[];
  100640. /**
  100641. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100642. */
  100643. wheelPrecision: number;
  100644. /**
  100645. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100646. * It will be used instead of pinchDeltaPrecision if different from 0.
  100647. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100648. */
  100649. wheelDeltaPercentage: number;
  100650. /**
  100651. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100652. */
  100653. zoomOnFactor: number;
  100654. /**
  100655. * Defines a screen offset for the camera position.
  100656. */
  100657. targetScreenOffset: Vector2;
  100658. /**
  100659. * Allows the camera to be completely reversed.
  100660. * If false the camera can not arrive upside down.
  100661. */
  100662. allowUpsideDown: boolean;
  100663. /**
  100664. * Define if double tap/click is used to restore the previously saved state of the camera.
  100665. */
  100666. useInputToRestoreState: boolean;
  100667. /** @hidden */
  100668. _viewMatrix: Matrix;
  100669. /** @hidden */
  100670. _useCtrlForPanning: boolean;
  100671. /** @hidden */
  100672. _panningMouseButton: number;
  100673. /**
  100674. * Defines the input associated to the camera.
  100675. */
  100676. inputs: ArcRotateCameraInputsManager;
  100677. /** @hidden */
  100678. _reset: () => void;
  100679. /**
  100680. * Defines the allowed panning axis.
  100681. */
  100682. panningAxis: Vector3;
  100683. protected _localDirection: Vector3;
  100684. protected _transformedDirection: Vector3;
  100685. private _bouncingBehavior;
  100686. /**
  100687. * Gets the bouncing behavior of the camera if it has been enabled.
  100688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100689. */
  100690. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100691. /**
  100692. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100694. */
  100695. useBouncingBehavior: boolean;
  100696. private _framingBehavior;
  100697. /**
  100698. * Gets the framing behavior of the camera if it has been enabled.
  100699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100700. */
  100701. readonly framingBehavior: Nullable<FramingBehavior>;
  100702. /**
  100703. * Defines if the framing behavior of the camera is enabled on the camera.
  100704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100705. */
  100706. useFramingBehavior: boolean;
  100707. private _autoRotationBehavior;
  100708. /**
  100709. * Gets the auto rotation behavior of the camera if it has been enabled.
  100710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100711. */
  100712. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100713. /**
  100714. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100716. */
  100717. useAutoRotationBehavior: boolean;
  100718. /**
  100719. * Observable triggered when the mesh target has been changed on the camera.
  100720. */
  100721. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100722. /**
  100723. * Event raised when the camera is colliding with a mesh.
  100724. */
  100725. onCollide: (collidedMesh: AbstractMesh) => void;
  100726. /**
  100727. * Defines whether the camera should check collision with the objects oh the scene.
  100728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100729. */
  100730. checkCollisions: boolean;
  100731. /**
  100732. * Defines the collision radius of the camera.
  100733. * This simulates a sphere around the camera.
  100734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100735. */
  100736. collisionRadius: Vector3;
  100737. protected _collider: Collider;
  100738. protected _previousPosition: Vector3;
  100739. protected _collisionVelocity: Vector3;
  100740. protected _newPosition: Vector3;
  100741. protected _previousAlpha: number;
  100742. protected _previousBeta: number;
  100743. protected _previousRadius: number;
  100744. protected _collisionTriggered: boolean;
  100745. protected _targetBoundingCenter: Nullable<Vector3>;
  100746. private _computationVector;
  100747. /**
  100748. * Instantiates a new ArcRotateCamera in a given scene
  100749. * @param name Defines the name of the camera
  100750. * @param alpha Defines the camera rotation along the logitudinal axis
  100751. * @param beta Defines the camera rotation along the latitudinal axis
  100752. * @param radius Defines the camera distance from its target
  100753. * @param target Defines the camera target
  100754. * @param scene Defines the scene the camera belongs to
  100755. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100756. */
  100757. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100758. /** @hidden */
  100759. _initCache(): void;
  100760. /** @hidden */
  100761. _updateCache(ignoreParentClass?: boolean): void;
  100762. protected _getTargetPosition(): Vector3;
  100763. private _storedAlpha;
  100764. private _storedBeta;
  100765. private _storedRadius;
  100766. private _storedTarget;
  100767. /**
  100768. * Stores the current state of the camera (alpha, beta, radius and target)
  100769. * @returns the camera itself
  100770. */
  100771. storeState(): Camera;
  100772. /**
  100773. * @hidden
  100774. * Restored camera state. You must call storeState() first
  100775. */
  100776. _restoreStateValues(): boolean;
  100777. /** @hidden */
  100778. _isSynchronizedViewMatrix(): boolean;
  100779. /**
  100780. * Attached controls to the current camera.
  100781. * @param element Defines the element the controls should be listened from
  100782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100783. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100784. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100785. */
  100786. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100787. /**
  100788. * Detach the current controls from the camera.
  100789. * The camera will stop reacting to inputs.
  100790. * @param element Defines the element to stop listening the inputs from
  100791. */
  100792. detachControl(element: HTMLElement): void;
  100793. /** @hidden */
  100794. _checkInputs(): void;
  100795. protected _checkLimits(): void;
  100796. /**
  100797. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100798. */
  100799. rebuildAnglesAndRadius(): void;
  100800. /**
  100801. * Use a position to define the current camera related information like aplha, beta and radius
  100802. * @param position Defines the position to set the camera at
  100803. */
  100804. setPosition(position: Vector3): void;
  100805. /**
  100806. * Defines the target the camera should look at.
  100807. * This will automatically adapt alpha beta and radius to fit within the new target.
  100808. * @param target Defines the new target as a Vector or a mesh
  100809. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100810. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100811. */
  100812. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100813. /** @hidden */
  100814. _getViewMatrix(): Matrix;
  100815. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100816. /**
  100817. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100818. * @param meshes Defines the mesh to zoom on
  100819. * @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)
  100820. */
  100821. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100822. /**
  100823. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100824. * The target will be changed but the radius
  100825. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100826. * @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)
  100827. */
  100828. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100829. min: Vector3;
  100830. max: Vector3;
  100831. distance: number;
  100832. }, doNotUpdateMaxZ?: boolean): void;
  100833. /**
  100834. * @override
  100835. * Override Camera.createRigCamera
  100836. */
  100837. createRigCamera(name: string, cameraIndex: number): Camera;
  100838. /**
  100839. * @hidden
  100840. * @override
  100841. * Override Camera._updateRigCameras
  100842. */
  100843. _updateRigCameras(): void;
  100844. /**
  100845. * Destroy the camera and release the current resources hold by it.
  100846. */
  100847. dispose(): void;
  100848. /**
  100849. * Gets the current object class name.
  100850. * @return the class name
  100851. */
  100852. getClassName(): string;
  100853. }
  100854. }
  100855. declare module BABYLON {
  100856. /**
  100857. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100858. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100859. */
  100860. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100861. /**
  100862. * Gets the name of the behavior.
  100863. */
  100864. readonly name: string;
  100865. private _zoomStopsAnimation;
  100866. private _idleRotationSpeed;
  100867. private _idleRotationWaitTime;
  100868. private _idleRotationSpinupTime;
  100869. /**
  100870. * Sets the flag that indicates if user zooming should stop animation.
  100871. */
  100872. /**
  100873. * Gets the flag that indicates if user zooming should stop animation.
  100874. */
  100875. zoomStopsAnimation: boolean;
  100876. /**
  100877. * Sets the default speed at which the camera rotates around the model.
  100878. */
  100879. /**
  100880. * Gets the default speed at which the camera rotates around the model.
  100881. */
  100882. idleRotationSpeed: number;
  100883. /**
  100884. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100885. */
  100886. /**
  100887. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100888. */
  100889. idleRotationWaitTime: number;
  100890. /**
  100891. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100892. */
  100893. /**
  100894. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100895. */
  100896. idleRotationSpinupTime: number;
  100897. /**
  100898. * Gets a value indicating if the camera is currently rotating because of this behavior
  100899. */
  100900. readonly rotationInProgress: boolean;
  100901. private _onPrePointerObservableObserver;
  100902. private _onAfterCheckInputsObserver;
  100903. private _attachedCamera;
  100904. private _isPointerDown;
  100905. private _lastFrameTime;
  100906. private _lastInteractionTime;
  100907. private _cameraRotationSpeed;
  100908. /**
  100909. * Initializes the behavior.
  100910. */
  100911. init(): void;
  100912. /**
  100913. * Attaches the behavior to its arc rotate camera.
  100914. * @param camera Defines the camera to attach the behavior to
  100915. */
  100916. attach(camera: ArcRotateCamera): void;
  100917. /**
  100918. * Detaches the behavior from its current arc rotate camera.
  100919. */
  100920. detach(): void;
  100921. /**
  100922. * Returns true if user is scrolling.
  100923. * @return true if user is scrolling.
  100924. */
  100925. private _userIsZooming;
  100926. private _lastFrameRadius;
  100927. private _shouldAnimationStopForInteraction;
  100928. /**
  100929. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100930. */
  100931. private _applyUserInteraction;
  100932. private _userIsMoving;
  100933. }
  100934. }
  100935. declare module BABYLON {
  100936. /**
  100937. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100938. */
  100939. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100940. private ui;
  100941. /**
  100942. * The name of the behavior
  100943. */
  100944. name: string;
  100945. /**
  100946. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100947. */
  100948. distanceAwayFromFace: number;
  100949. /**
  100950. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100951. */
  100952. distanceAwayFromBottomOfFace: number;
  100953. private _faceVectors;
  100954. private _target;
  100955. private _scene;
  100956. private _onRenderObserver;
  100957. private _tmpMatrix;
  100958. private _tmpVector;
  100959. /**
  100960. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100961. * @param ui The transform node that should be attched to the mesh
  100962. */
  100963. constructor(ui: TransformNode);
  100964. /**
  100965. * Initializes the behavior
  100966. */
  100967. init(): void;
  100968. private _closestFace;
  100969. private _zeroVector;
  100970. private _lookAtTmpMatrix;
  100971. private _lookAtToRef;
  100972. /**
  100973. * Attaches the AttachToBoxBehavior to the passed in mesh
  100974. * @param target The mesh that the specified node will be attached to
  100975. */
  100976. attach(target: Mesh): void;
  100977. /**
  100978. * Detaches the behavior from the mesh
  100979. */
  100980. detach(): void;
  100981. }
  100982. }
  100983. declare module BABYLON {
  100984. /**
  100985. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100986. */
  100987. export class FadeInOutBehavior implements Behavior<Mesh> {
  100988. /**
  100989. * Time in milliseconds to delay before fading in (Default: 0)
  100990. */
  100991. delay: number;
  100992. /**
  100993. * Time in milliseconds for the mesh to fade in (Default: 300)
  100994. */
  100995. fadeInTime: number;
  100996. private _millisecondsPerFrame;
  100997. private _hovered;
  100998. private _hoverValue;
  100999. private _ownerNode;
  101000. /**
  101001. * Instatiates the FadeInOutBehavior
  101002. */
  101003. constructor();
  101004. /**
  101005. * The name of the behavior
  101006. */
  101007. readonly name: string;
  101008. /**
  101009. * Initializes the behavior
  101010. */
  101011. init(): void;
  101012. /**
  101013. * Attaches the fade behavior on the passed in mesh
  101014. * @param ownerNode The mesh that will be faded in/out once attached
  101015. */
  101016. attach(ownerNode: Mesh): void;
  101017. /**
  101018. * Detaches the behavior from the mesh
  101019. */
  101020. detach(): void;
  101021. /**
  101022. * Triggers the mesh to begin fading in or out
  101023. * @param value if the object should fade in or out (true to fade in)
  101024. */
  101025. fadeIn(value: boolean): void;
  101026. private _update;
  101027. private _setAllVisibility;
  101028. }
  101029. }
  101030. declare module BABYLON {
  101031. /**
  101032. * Class containing a set of static utilities functions for managing Pivots
  101033. * @hidden
  101034. */
  101035. export class PivotTools {
  101036. private static _PivotCached;
  101037. private static _OldPivotPoint;
  101038. private static _PivotTranslation;
  101039. private static _PivotTmpVector;
  101040. /** @hidden */
  101041. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101042. /** @hidden */
  101043. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101044. }
  101045. }
  101046. declare module BABYLON {
  101047. /**
  101048. * Class containing static functions to help procedurally build meshes
  101049. */
  101050. export class PlaneBuilder {
  101051. /**
  101052. * Creates a plane mesh
  101053. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101054. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101055. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101059. * @param name defines the name of the mesh
  101060. * @param options defines the options used to create the mesh
  101061. * @param scene defines the hosting scene
  101062. * @returns the plane mesh
  101063. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101064. */
  101065. static CreatePlane(name: string, options: {
  101066. size?: number;
  101067. width?: number;
  101068. height?: number;
  101069. sideOrientation?: number;
  101070. frontUVs?: Vector4;
  101071. backUVs?: Vector4;
  101072. updatable?: boolean;
  101073. sourcePlane?: Plane;
  101074. }, scene?: Nullable<Scene>): Mesh;
  101075. }
  101076. }
  101077. declare module BABYLON {
  101078. /**
  101079. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101080. */
  101081. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101082. private static _AnyMouseID;
  101083. /**
  101084. * Abstract mesh the behavior is set on
  101085. */
  101086. attachedNode: AbstractMesh;
  101087. private _dragPlane;
  101088. private _scene;
  101089. private _pointerObserver;
  101090. private _beforeRenderObserver;
  101091. private static _planeScene;
  101092. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101093. /**
  101094. * 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)
  101095. */
  101096. maxDragAngle: number;
  101097. /**
  101098. * @hidden
  101099. */
  101100. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101101. /**
  101102. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101103. */
  101104. currentDraggingPointerID: number;
  101105. /**
  101106. * The last position where the pointer hit the drag plane in world space
  101107. */
  101108. lastDragPosition: Vector3;
  101109. /**
  101110. * If the behavior is currently in a dragging state
  101111. */
  101112. dragging: boolean;
  101113. /**
  101114. * 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)
  101115. */
  101116. dragDeltaRatio: number;
  101117. /**
  101118. * If the drag plane orientation should be updated during the dragging (Default: true)
  101119. */
  101120. updateDragPlane: boolean;
  101121. private _debugMode;
  101122. private _moving;
  101123. /**
  101124. * Fires each time the attached mesh is dragged with the pointer
  101125. * * delta between last drag position and current drag position in world space
  101126. * * dragDistance along the drag axis
  101127. * * dragPlaneNormal normal of the current drag plane used during the drag
  101128. * * dragPlanePoint in world space where the drag intersects the drag plane
  101129. */
  101130. onDragObservable: Observable<{
  101131. delta: Vector3;
  101132. dragPlanePoint: Vector3;
  101133. dragPlaneNormal: Vector3;
  101134. dragDistance: number;
  101135. pointerId: number;
  101136. }>;
  101137. /**
  101138. * Fires each time a drag begins (eg. mouse down on mesh)
  101139. */
  101140. onDragStartObservable: Observable<{
  101141. dragPlanePoint: Vector3;
  101142. pointerId: number;
  101143. }>;
  101144. /**
  101145. * Fires each time a drag ends (eg. mouse release after drag)
  101146. */
  101147. onDragEndObservable: Observable<{
  101148. dragPlanePoint: Vector3;
  101149. pointerId: number;
  101150. }>;
  101151. /**
  101152. * If the attached mesh should be moved when dragged
  101153. */
  101154. moveAttached: boolean;
  101155. /**
  101156. * If the drag behavior will react to drag events (Default: true)
  101157. */
  101158. enabled: boolean;
  101159. /**
  101160. * If pointer events should start and release the drag (Default: true)
  101161. */
  101162. startAndReleaseDragOnPointerEvents: boolean;
  101163. /**
  101164. * If camera controls should be detached during the drag
  101165. */
  101166. detachCameraControls: boolean;
  101167. /**
  101168. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101169. */
  101170. useObjectOrienationForDragging: boolean;
  101171. private _options;
  101172. /**
  101173. * Creates a pointer drag behavior that can be attached to a mesh
  101174. * @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)
  101175. */
  101176. constructor(options?: {
  101177. dragAxis?: Vector3;
  101178. dragPlaneNormal?: Vector3;
  101179. });
  101180. /**
  101181. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101182. */
  101183. validateDrag: (targetPosition: Vector3) => boolean;
  101184. /**
  101185. * The name of the behavior
  101186. */
  101187. readonly name: string;
  101188. /**
  101189. * Initializes the behavior
  101190. */
  101191. init(): void;
  101192. private _tmpVector;
  101193. private _alternatePickedPoint;
  101194. private _worldDragAxis;
  101195. private _targetPosition;
  101196. private _attachedElement;
  101197. /**
  101198. * Attaches the drag behavior the passed in mesh
  101199. * @param ownerNode The mesh that will be dragged around once attached
  101200. */
  101201. attach(ownerNode: AbstractMesh): void;
  101202. /**
  101203. * Force relase the drag action by code.
  101204. */
  101205. releaseDrag(): void;
  101206. private _startDragRay;
  101207. private _lastPointerRay;
  101208. /**
  101209. * Simulates the start of a pointer drag event on the behavior
  101210. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101211. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101212. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101213. */
  101214. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101215. private _startDrag;
  101216. private _dragDelta;
  101217. private _moveDrag;
  101218. private _pickWithRayOnDragPlane;
  101219. private _pointA;
  101220. private _pointB;
  101221. private _pointC;
  101222. private _lineA;
  101223. private _lineB;
  101224. private _localAxis;
  101225. private _lookAt;
  101226. private _updateDragPlanePosition;
  101227. /**
  101228. * Detaches the behavior from the mesh
  101229. */
  101230. detach(): void;
  101231. }
  101232. }
  101233. declare module BABYLON {
  101234. /**
  101235. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101236. */
  101237. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101238. private _dragBehaviorA;
  101239. private _dragBehaviorB;
  101240. private _startDistance;
  101241. private _initialScale;
  101242. private _targetScale;
  101243. private _ownerNode;
  101244. private _sceneRenderObserver;
  101245. /**
  101246. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101247. */
  101248. constructor();
  101249. /**
  101250. * The name of the behavior
  101251. */
  101252. readonly name: string;
  101253. /**
  101254. * Initializes the behavior
  101255. */
  101256. init(): void;
  101257. private _getCurrentDistance;
  101258. /**
  101259. * Attaches the scale behavior the passed in mesh
  101260. * @param ownerNode The mesh that will be scaled around once attached
  101261. */
  101262. attach(ownerNode: Mesh): void;
  101263. /**
  101264. * Detaches the behavior from the mesh
  101265. */
  101266. detach(): void;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. /**
  101271. * 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
  101272. */
  101273. export class SixDofDragBehavior implements Behavior<Mesh> {
  101274. private static _virtualScene;
  101275. private _ownerNode;
  101276. private _sceneRenderObserver;
  101277. private _scene;
  101278. private _targetPosition;
  101279. private _virtualOriginMesh;
  101280. private _virtualDragMesh;
  101281. private _pointerObserver;
  101282. private _moving;
  101283. private _startingOrientation;
  101284. /**
  101285. * 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)
  101286. */
  101287. private zDragFactor;
  101288. /**
  101289. * If the object should rotate to face the drag origin
  101290. */
  101291. rotateDraggedObject: boolean;
  101292. /**
  101293. * If the behavior is currently in a dragging state
  101294. */
  101295. dragging: boolean;
  101296. /**
  101297. * 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)
  101298. */
  101299. dragDeltaRatio: number;
  101300. /**
  101301. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101302. */
  101303. currentDraggingPointerID: number;
  101304. /**
  101305. * If camera controls should be detached during the drag
  101306. */
  101307. detachCameraControls: boolean;
  101308. /**
  101309. * Fires each time a drag starts
  101310. */
  101311. onDragStartObservable: Observable<{}>;
  101312. /**
  101313. * Fires each time a drag ends (eg. mouse release after drag)
  101314. */
  101315. onDragEndObservable: Observable<{}>;
  101316. /**
  101317. * 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
  101318. */
  101319. constructor();
  101320. /**
  101321. * The name of the behavior
  101322. */
  101323. readonly name: string;
  101324. /**
  101325. * Initializes the behavior
  101326. */
  101327. init(): void;
  101328. /**
  101329. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101330. */
  101331. private readonly _pointerCamera;
  101332. /**
  101333. * Attaches the scale behavior the passed in mesh
  101334. * @param ownerNode The mesh that will be scaled around once attached
  101335. */
  101336. attach(ownerNode: Mesh): void;
  101337. /**
  101338. * Detaches the behavior from the mesh
  101339. */
  101340. detach(): void;
  101341. }
  101342. }
  101343. declare module BABYLON {
  101344. /**
  101345. * Class used to apply inverse kinematics to bones
  101346. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101347. */
  101348. export class BoneIKController {
  101349. private static _tmpVecs;
  101350. private static _tmpQuat;
  101351. private static _tmpMats;
  101352. /**
  101353. * Gets or sets the target mesh
  101354. */
  101355. targetMesh: AbstractMesh;
  101356. /** Gets or sets the mesh used as pole */
  101357. poleTargetMesh: AbstractMesh;
  101358. /**
  101359. * Gets or sets the bone used as pole
  101360. */
  101361. poleTargetBone: Nullable<Bone>;
  101362. /**
  101363. * Gets or sets the target position
  101364. */
  101365. targetPosition: Vector3;
  101366. /**
  101367. * Gets or sets the pole target position
  101368. */
  101369. poleTargetPosition: Vector3;
  101370. /**
  101371. * Gets or sets the pole target local offset
  101372. */
  101373. poleTargetLocalOffset: Vector3;
  101374. /**
  101375. * Gets or sets the pole angle
  101376. */
  101377. poleAngle: number;
  101378. /**
  101379. * Gets or sets the mesh associated with the controller
  101380. */
  101381. mesh: AbstractMesh;
  101382. /**
  101383. * 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)
  101384. */
  101385. slerpAmount: number;
  101386. private _bone1Quat;
  101387. private _bone1Mat;
  101388. private _bone2Ang;
  101389. private _bone1;
  101390. private _bone2;
  101391. private _bone1Length;
  101392. private _bone2Length;
  101393. private _maxAngle;
  101394. private _maxReach;
  101395. private _rightHandedSystem;
  101396. private _bendAxis;
  101397. private _slerping;
  101398. private _adjustRoll;
  101399. /**
  101400. * Gets or sets maximum allowed angle
  101401. */
  101402. maxAngle: number;
  101403. /**
  101404. * Creates a new BoneIKController
  101405. * @param mesh defines the mesh to control
  101406. * @param bone defines the bone to control
  101407. * @param options defines options to set up the controller
  101408. */
  101409. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101410. targetMesh?: AbstractMesh;
  101411. poleTargetMesh?: AbstractMesh;
  101412. poleTargetBone?: Bone;
  101413. poleTargetLocalOffset?: Vector3;
  101414. poleAngle?: number;
  101415. bendAxis?: Vector3;
  101416. maxAngle?: number;
  101417. slerpAmount?: number;
  101418. });
  101419. private _setMaxAngle;
  101420. /**
  101421. * Force the controller to update the bones
  101422. */
  101423. update(): void;
  101424. }
  101425. }
  101426. declare module BABYLON {
  101427. /**
  101428. * Class used to make a bone look toward a point in space
  101429. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101430. */
  101431. export class BoneLookController {
  101432. private static _tmpVecs;
  101433. private static _tmpQuat;
  101434. private static _tmpMats;
  101435. /**
  101436. * The target Vector3 that the bone will look at
  101437. */
  101438. target: Vector3;
  101439. /**
  101440. * The mesh that the bone is attached to
  101441. */
  101442. mesh: AbstractMesh;
  101443. /**
  101444. * The bone that will be looking to the target
  101445. */
  101446. bone: Bone;
  101447. /**
  101448. * The up axis of the coordinate system that is used when the bone is rotated
  101449. */
  101450. upAxis: Vector3;
  101451. /**
  101452. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101453. */
  101454. upAxisSpace: Space;
  101455. /**
  101456. * Used to make an adjustment to the yaw of the bone
  101457. */
  101458. adjustYaw: number;
  101459. /**
  101460. * Used to make an adjustment to the pitch of the bone
  101461. */
  101462. adjustPitch: number;
  101463. /**
  101464. * Used to make an adjustment to the roll of the bone
  101465. */
  101466. adjustRoll: number;
  101467. /**
  101468. * 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)
  101469. */
  101470. slerpAmount: number;
  101471. private _minYaw;
  101472. private _maxYaw;
  101473. private _minPitch;
  101474. private _maxPitch;
  101475. private _minYawSin;
  101476. private _minYawCos;
  101477. private _maxYawSin;
  101478. private _maxYawCos;
  101479. private _midYawConstraint;
  101480. private _minPitchTan;
  101481. private _maxPitchTan;
  101482. private _boneQuat;
  101483. private _slerping;
  101484. private _transformYawPitch;
  101485. private _transformYawPitchInv;
  101486. private _firstFrameSkipped;
  101487. private _yawRange;
  101488. private _fowardAxis;
  101489. /**
  101490. * Gets or sets the minimum yaw angle that the bone can look to
  101491. */
  101492. minYaw: number;
  101493. /**
  101494. * Gets or sets the maximum yaw angle that the bone can look to
  101495. */
  101496. maxYaw: number;
  101497. /**
  101498. * Gets or sets the minimum pitch angle that the bone can look to
  101499. */
  101500. minPitch: number;
  101501. /**
  101502. * Gets or sets the maximum pitch angle that the bone can look to
  101503. */
  101504. maxPitch: number;
  101505. /**
  101506. * Create a BoneLookController
  101507. * @param mesh the mesh that the bone belongs to
  101508. * @param bone the bone that will be looking to the target
  101509. * @param target the target Vector3 to look at
  101510. * @param options optional settings:
  101511. * * maxYaw: the maximum angle the bone will yaw to
  101512. * * minYaw: the minimum angle the bone will yaw to
  101513. * * maxPitch: the maximum angle the bone will pitch to
  101514. * * minPitch: the minimum angle the bone will yaw to
  101515. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101516. * * upAxis: the up axis of the coordinate system
  101517. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101518. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101519. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101520. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101521. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101522. * * adjustRoll: used to make an adjustment to the roll of the bone
  101523. **/
  101524. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101525. maxYaw?: number;
  101526. minYaw?: number;
  101527. maxPitch?: number;
  101528. minPitch?: number;
  101529. slerpAmount?: number;
  101530. upAxis?: Vector3;
  101531. upAxisSpace?: Space;
  101532. yawAxis?: Vector3;
  101533. pitchAxis?: Vector3;
  101534. adjustYaw?: number;
  101535. adjustPitch?: number;
  101536. adjustRoll?: number;
  101537. });
  101538. /**
  101539. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101540. */
  101541. update(): void;
  101542. private _getAngleDiff;
  101543. private _getAngleBetween;
  101544. private _isAngleBetween;
  101545. }
  101546. }
  101547. declare module BABYLON {
  101548. /**
  101549. * Manage the gamepad inputs to control an arc rotate camera.
  101550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101551. */
  101552. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101553. /**
  101554. * Defines the camera the input is attached to.
  101555. */
  101556. camera: ArcRotateCamera;
  101557. /**
  101558. * Defines the gamepad the input is gathering event from.
  101559. */
  101560. gamepad: Nullable<Gamepad>;
  101561. /**
  101562. * Defines the gamepad rotation sensiblity.
  101563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101564. */
  101565. gamepadRotationSensibility: number;
  101566. /**
  101567. * Defines the gamepad move sensiblity.
  101568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101569. */
  101570. gamepadMoveSensibility: number;
  101571. private _onGamepadConnectedObserver;
  101572. private _onGamepadDisconnectedObserver;
  101573. /**
  101574. * Attach the input controls to a specific dom element to get the input from.
  101575. * @param element Defines the element the controls should be listened from
  101576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101577. */
  101578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101579. /**
  101580. * Detach the current controls from the specified dom element.
  101581. * @param element Defines the element to stop listening the inputs from
  101582. */
  101583. detachControl(element: Nullable<HTMLElement>): void;
  101584. /**
  101585. * Update the current camera state depending on the inputs that have been used this frame.
  101586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101587. */
  101588. checkInputs(): void;
  101589. /**
  101590. * Gets the class name of the current intput.
  101591. * @returns the class name
  101592. */
  101593. getClassName(): string;
  101594. /**
  101595. * Get the friendly name associated with the input class.
  101596. * @returns the input friendly name
  101597. */
  101598. getSimpleName(): string;
  101599. }
  101600. }
  101601. declare module BABYLON {
  101602. interface ArcRotateCameraInputsManager {
  101603. /**
  101604. * Add orientation input support to the input manager.
  101605. * @returns the current input manager
  101606. */
  101607. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101608. }
  101609. /**
  101610. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101612. */
  101613. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101614. /**
  101615. * Defines the camera the input is attached to.
  101616. */
  101617. camera: ArcRotateCamera;
  101618. /**
  101619. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101620. */
  101621. alphaCorrection: number;
  101622. /**
  101623. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101624. */
  101625. gammaCorrection: number;
  101626. private _alpha;
  101627. private _gamma;
  101628. private _dirty;
  101629. private _deviceOrientationHandler;
  101630. /**
  101631. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101632. */
  101633. constructor();
  101634. /**
  101635. * Attach the input controls to a specific dom element to get the input from.
  101636. * @param element Defines the element the controls should be listened from
  101637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101638. */
  101639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101640. /** @hidden */
  101641. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101642. /**
  101643. * Update the current camera state depending on the inputs that have been used this frame.
  101644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101645. */
  101646. checkInputs(): void;
  101647. /**
  101648. * Detach the current controls from the specified dom element.
  101649. * @param element Defines the element to stop listening the inputs from
  101650. */
  101651. detachControl(element: Nullable<HTMLElement>): void;
  101652. /**
  101653. * Gets the class name of the current intput.
  101654. * @returns the class name
  101655. */
  101656. getClassName(): string;
  101657. /**
  101658. * Get the friendly name associated with the input class.
  101659. * @returns the input friendly name
  101660. */
  101661. getSimpleName(): string;
  101662. }
  101663. }
  101664. declare module BABYLON {
  101665. /**
  101666. * Listen to mouse events to control the camera.
  101667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101668. */
  101669. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101670. /**
  101671. * Defines the camera the input is attached to.
  101672. */
  101673. camera: FlyCamera;
  101674. /**
  101675. * Defines if touch is enabled. (Default is true.)
  101676. */
  101677. touchEnabled: boolean;
  101678. /**
  101679. * Defines the buttons associated with the input to handle camera rotation.
  101680. */
  101681. buttons: number[];
  101682. /**
  101683. * Assign buttons for Yaw control.
  101684. */
  101685. buttonsYaw: number[];
  101686. /**
  101687. * Assign buttons for Pitch control.
  101688. */
  101689. buttonsPitch: number[];
  101690. /**
  101691. * Assign buttons for Roll control.
  101692. */
  101693. buttonsRoll: number[];
  101694. /**
  101695. * Detect if any button is being pressed while mouse is moved.
  101696. * -1 = Mouse locked.
  101697. * 0 = Left button.
  101698. * 1 = Middle Button.
  101699. * 2 = Right Button.
  101700. */
  101701. activeButton: number;
  101702. /**
  101703. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101704. * Higher values reduce its sensitivity.
  101705. */
  101706. angularSensibility: number;
  101707. private _mousemoveCallback;
  101708. private _observer;
  101709. private _rollObserver;
  101710. private previousPosition;
  101711. private noPreventDefault;
  101712. private element;
  101713. /**
  101714. * Listen to mouse events to control the camera.
  101715. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101717. */
  101718. constructor(touchEnabled?: boolean);
  101719. /**
  101720. * Attach the mouse control to the HTML DOM element.
  101721. * @param element Defines the element that listens to the input events.
  101722. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101723. */
  101724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101725. /**
  101726. * Detach the current controls from the specified dom element.
  101727. * @param element Defines the element to stop listening the inputs from
  101728. */
  101729. detachControl(element: Nullable<HTMLElement>): void;
  101730. /**
  101731. * Gets the class name of the current input.
  101732. * @returns the class name.
  101733. */
  101734. getClassName(): string;
  101735. /**
  101736. * Get the friendly name associated with the input class.
  101737. * @returns the input's friendly name.
  101738. */
  101739. getSimpleName(): string;
  101740. private _pointerInput;
  101741. private _onMouseMove;
  101742. /**
  101743. * Rotate camera by mouse offset.
  101744. */
  101745. private rotateCamera;
  101746. }
  101747. }
  101748. declare module BABYLON {
  101749. /**
  101750. * Default Inputs manager for the FlyCamera.
  101751. * It groups all the default supported inputs for ease of use.
  101752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101753. */
  101754. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101755. /**
  101756. * Instantiates a new FlyCameraInputsManager.
  101757. * @param camera Defines the camera the inputs belong to.
  101758. */
  101759. constructor(camera: FlyCamera);
  101760. /**
  101761. * Add keyboard input support to the input manager.
  101762. * @returns the new FlyCameraKeyboardMoveInput().
  101763. */
  101764. addKeyboard(): FlyCameraInputsManager;
  101765. /**
  101766. * Add mouse input support to the input manager.
  101767. * @param touchEnabled Enable touch screen support.
  101768. * @returns the new FlyCameraMouseInput().
  101769. */
  101770. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101771. }
  101772. }
  101773. declare module BABYLON {
  101774. /**
  101775. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101776. * such as in a 3D Space Shooter or a Flight Simulator.
  101777. */
  101778. export class FlyCamera extends TargetCamera {
  101779. /**
  101780. * Define the collision ellipsoid of the camera.
  101781. * This is helpful for simulating a camera body, like a player's body.
  101782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101783. */
  101784. ellipsoid: Vector3;
  101785. /**
  101786. * Define an offset for the position of the ellipsoid around the camera.
  101787. * This can be helpful if the camera is attached away from the player's body center,
  101788. * such as at its head.
  101789. */
  101790. ellipsoidOffset: Vector3;
  101791. /**
  101792. * Enable or disable collisions of the camera with the rest of the scene objects.
  101793. */
  101794. checkCollisions: boolean;
  101795. /**
  101796. * Enable or disable gravity on the camera.
  101797. */
  101798. applyGravity: boolean;
  101799. /**
  101800. * Define the current direction the camera is moving to.
  101801. */
  101802. cameraDirection: Vector3;
  101803. /**
  101804. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101805. * This overrides and empties cameraRotation.
  101806. */
  101807. rotationQuaternion: Quaternion;
  101808. /**
  101809. * Track Roll to maintain the wanted Rolling when looking around.
  101810. */
  101811. _trackRoll: number;
  101812. /**
  101813. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101814. */
  101815. rollCorrect: number;
  101816. /**
  101817. * Mimic a banked turn, Rolling the camera when Yawing.
  101818. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101819. */
  101820. bankedTurn: boolean;
  101821. /**
  101822. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101823. */
  101824. bankedTurnLimit: number;
  101825. /**
  101826. * Value of 0 disables the banked Roll.
  101827. * Value of 1 is equal to the Yaw angle in radians.
  101828. */
  101829. bankedTurnMultiplier: number;
  101830. /**
  101831. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101832. */
  101833. inputs: FlyCameraInputsManager;
  101834. /**
  101835. * Gets the input sensibility for mouse input.
  101836. * Higher values reduce sensitivity.
  101837. */
  101838. /**
  101839. * Sets the input sensibility for a mouse input.
  101840. * Higher values reduce sensitivity.
  101841. */
  101842. angularSensibility: number;
  101843. /**
  101844. * Get the keys for camera movement forward.
  101845. */
  101846. /**
  101847. * Set the keys for camera movement forward.
  101848. */
  101849. keysForward: number[];
  101850. /**
  101851. * Get the keys for camera movement backward.
  101852. */
  101853. keysBackward: number[];
  101854. /**
  101855. * Get the keys for camera movement up.
  101856. */
  101857. /**
  101858. * Set the keys for camera movement up.
  101859. */
  101860. keysUp: number[];
  101861. /**
  101862. * Get the keys for camera movement down.
  101863. */
  101864. /**
  101865. * Set the keys for camera movement down.
  101866. */
  101867. keysDown: number[];
  101868. /**
  101869. * Get the keys for camera movement left.
  101870. */
  101871. /**
  101872. * Set the keys for camera movement left.
  101873. */
  101874. keysLeft: number[];
  101875. /**
  101876. * Set the keys for camera movement right.
  101877. */
  101878. /**
  101879. * Set the keys for camera movement right.
  101880. */
  101881. keysRight: number[];
  101882. /**
  101883. * Event raised when the camera collides with a mesh in the scene.
  101884. */
  101885. onCollide: (collidedMesh: AbstractMesh) => void;
  101886. private _collider;
  101887. private _needMoveForGravity;
  101888. private _oldPosition;
  101889. private _diffPosition;
  101890. private _newPosition;
  101891. /** @hidden */
  101892. _localDirection: Vector3;
  101893. /** @hidden */
  101894. _transformedDirection: Vector3;
  101895. /**
  101896. * Instantiates a FlyCamera.
  101897. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101898. * such as in a 3D Space Shooter or a Flight Simulator.
  101899. * @param name Define the name of the camera in the scene.
  101900. * @param position Define the starting position of the camera in the scene.
  101901. * @param scene Define the scene the camera belongs to.
  101902. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101903. */
  101904. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101905. /**
  101906. * Attach a control to the HTML DOM element.
  101907. * @param element Defines the element that listens to the input events.
  101908. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101909. */
  101910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101911. /**
  101912. * Detach a control from the HTML DOM element.
  101913. * The camera will stop reacting to that input.
  101914. * @param element Defines the element that listens to the input events.
  101915. */
  101916. detachControl(element: HTMLElement): void;
  101917. private _collisionMask;
  101918. /**
  101919. * Get the mask that the camera ignores in collision events.
  101920. */
  101921. /**
  101922. * Set the mask that the camera ignores in collision events.
  101923. */
  101924. collisionMask: number;
  101925. /** @hidden */
  101926. _collideWithWorld(displacement: Vector3): void;
  101927. /** @hidden */
  101928. private _onCollisionPositionChange;
  101929. /** @hidden */
  101930. _checkInputs(): void;
  101931. /** @hidden */
  101932. _decideIfNeedsToMove(): boolean;
  101933. /** @hidden */
  101934. _updatePosition(): void;
  101935. /**
  101936. * Restore the Roll to its target value at the rate specified.
  101937. * @param rate - Higher means slower restoring.
  101938. * @hidden
  101939. */
  101940. restoreRoll(rate: number): void;
  101941. /**
  101942. * Destroy the camera and release the current resources held by it.
  101943. */
  101944. dispose(): void;
  101945. /**
  101946. * Get the current object class name.
  101947. * @returns the class name.
  101948. */
  101949. getClassName(): string;
  101950. }
  101951. }
  101952. declare module BABYLON {
  101953. /**
  101954. * Listen to keyboard events to control the camera.
  101955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101956. */
  101957. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101958. /**
  101959. * Defines the camera the input is attached to.
  101960. */
  101961. camera: FlyCamera;
  101962. /**
  101963. * The list of keyboard keys used to control the forward move of the camera.
  101964. */
  101965. keysForward: number[];
  101966. /**
  101967. * The list of keyboard keys used to control the backward move of the camera.
  101968. */
  101969. keysBackward: number[];
  101970. /**
  101971. * The list of keyboard keys used to control the forward move of the camera.
  101972. */
  101973. keysUp: number[];
  101974. /**
  101975. * The list of keyboard keys used to control the backward move of the camera.
  101976. */
  101977. keysDown: number[];
  101978. /**
  101979. * The list of keyboard keys used to control the right strafe move of the camera.
  101980. */
  101981. keysRight: number[];
  101982. /**
  101983. * The list of keyboard keys used to control the left strafe move of the camera.
  101984. */
  101985. keysLeft: number[];
  101986. private _keys;
  101987. private _onCanvasBlurObserver;
  101988. private _onKeyboardObserver;
  101989. private _engine;
  101990. private _scene;
  101991. /**
  101992. * Attach the input controls to a specific dom element to get the input from.
  101993. * @param element Defines the element the controls should be listened from
  101994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101995. */
  101996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101997. /**
  101998. * Detach the current controls from the specified dom element.
  101999. * @param element Defines the element to stop listening the inputs from
  102000. */
  102001. detachControl(element: Nullable<HTMLElement>): void;
  102002. /**
  102003. * Gets the class name of the current intput.
  102004. * @returns the class name
  102005. */
  102006. getClassName(): string;
  102007. /** @hidden */
  102008. _onLostFocus(e: FocusEvent): void;
  102009. /**
  102010. * Get the friendly name associated with the input class.
  102011. * @returns the input friendly name
  102012. */
  102013. getSimpleName(): string;
  102014. /**
  102015. * Update the current camera state depending on the inputs that have been used this frame.
  102016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102017. */
  102018. checkInputs(): void;
  102019. }
  102020. }
  102021. declare module BABYLON {
  102022. /**
  102023. * Manage the mouse wheel inputs to control a follow camera.
  102024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102025. */
  102026. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102027. /**
  102028. * Defines the camera the input is attached to.
  102029. */
  102030. camera: FollowCamera;
  102031. /**
  102032. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102033. */
  102034. axisControlRadius: boolean;
  102035. /**
  102036. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102037. */
  102038. axisControlHeight: boolean;
  102039. /**
  102040. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102041. */
  102042. axisControlRotation: boolean;
  102043. /**
  102044. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102045. * relation to mouseWheel events.
  102046. */
  102047. wheelPrecision: number;
  102048. /**
  102049. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102050. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102051. */
  102052. wheelDeltaPercentage: number;
  102053. private _wheel;
  102054. private _observer;
  102055. /**
  102056. * Attach the input controls to a specific dom element to get the input from.
  102057. * @param element Defines the element the controls should be listened from
  102058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102059. */
  102060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102061. /**
  102062. * Detach the current controls from the specified dom element.
  102063. * @param element Defines the element to stop listening the inputs from
  102064. */
  102065. detachControl(element: Nullable<HTMLElement>): void;
  102066. /**
  102067. * Gets the class name of the current intput.
  102068. * @returns the class name
  102069. */
  102070. getClassName(): string;
  102071. /**
  102072. * Get the friendly name associated with the input class.
  102073. * @returns the input friendly name
  102074. */
  102075. getSimpleName(): string;
  102076. }
  102077. }
  102078. declare module BABYLON {
  102079. /**
  102080. * Manage the pointers inputs to control an follow camera.
  102081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102082. */
  102083. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102084. /**
  102085. * Defines the camera the input is attached to.
  102086. */
  102087. camera: FollowCamera;
  102088. /**
  102089. * Gets the class name of the current input.
  102090. * @returns the class name
  102091. */
  102092. getClassName(): string;
  102093. /**
  102094. * Defines the pointer angular sensibility along the X axis or how fast is
  102095. * the camera rotating.
  102096. * A negative number will reverse the axis direction.
  102097. */
  102098. angularSensibilityX: number;
  102099. /**
  102100. * Defines the pointer angular sensibility along the Y axis or how fast is
  102101. * the camera rotating.
  102102. * A negative number will reverse the axis direction.
  102103. */
  102104. angularSensibilityY: number;
  102105. /**
  102106. * Defines the pointer pinch precision or how fast is the camera zooming.
  102107. * A negative number will reverse the axis direction.
  102108. */
  102109. pinchPrecision: number;
  102110. /**
  102111. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102112. * from 0.
  102113. * It defines the percentage of current camera.radius to use as delta when
  102114. * pinch zoom is used.
  102115. */
  102116. pinchDeltaPercentage: number;
  102117. /**
  102118. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102119. */
  102120. axisXControlRadius: boolean;
  102121. /**
  102122. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102123. */
  102124. axisXControlHeight: boolean;
  102125. /**
  102126. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102127. */
  102128. axisXControlRotation: boolean;
  102129. /**
  102130. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102131. */
  102132. axisYControlRadius: boolean;
  102133. /**
  102134. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102135. */
  102136. axisYControlHeight: boolean;
  102137. /**
  102138. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102139. */
  102140. axisYControlRotation: boolean;
  102141. /**
  102142. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102143. */
  102144. axisPinchControlRadius: boolean;
  102145. /**
  102146. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102147. */
  102148. axisPinchControlHeight: boolean;
  102149. /**
  102150. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102151. */
  102152. axisPinchControlRotation: boolean;
  102153. /**
  102154. * Log error messages if basic misconfiguration has occurred.
  102155. */
  102156. warningEnable: boolean;
  102157. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102159. private _warningCounter;
  102160. private _warning;
  102161. }
  102162. }
  102163. declare module BABYLON {
  102164. /**
  102165. * Default Inputs manager for the FollowCamera.
  102166. * It groups all the default supported inputs for ease of use.
  102167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102168. */
  102169. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102170. /**
  102171. * Instantiates a new FollowCameraInputsManager.
  102172. * @param camera Defines the camera the inputs belong to
  102173. */
  102174. constructor(camera: FollowCamera);
  102175. /**
  102176. * Add keyboard input support to the input manager.
  102177. * @returns the current input manager
  102178. */
  102179. addKeyboard(): FollowCameraInputsManager;
  102180. /**
  102181. * Add mouse wheel input support to the input manager.
  102182. * @returns the current input manager
  102183. */
  102184. addMouseWheel(): FollowCameraInputsManager;
  102185. /**
  102186. * Add pointers input support to the input manager.
  102187. * @returns the current input manager
  102188. */
  102189. addPointers(): FollowCameraInputsManager;
  102190. /**
  102191. * Add orientation input support to the input manager.
  102192. * @returns the current input manager
  102193. */
  102194. addVRDeviceOrientation(): FollowCameraInputsManager;
  102195. }
  102196. }
  102197. declare module BABYLON {
  102198. /**
  102199. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102200. * an arc rotate version arcFollowCamera are available.
  102201. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102202. */
  102203. export class FollowCamera extends TargetCamera {
  102204. /**
  102205. * Distance the follow camera should follow an object at
  102206. */
  102207. radius: number;
  102208. /**
  102209. * Minimum allowed distance of the camera to the axis of rotation
  102210. * (The camera can not get closer).
  102211. * This can help limiting how the Camera is able to move in the scene.
  102212. */
  102213. lowerRadiusLimit: Nullable<number>;
  102214. /**
  102215. * Maximum allowed distance of the camera to the axis of rotation
  102216. * (The camera can not get further).
  102217. * This can help limiting how the Camera is able to move in the scene.
  102218. */
  102219. upperRadiusLimit: Nullable<number>;
  102220. /**
  102221. * Define a rotation offset between the camera and the object it follows
  102222. */
  102223. rotationOffset: number;
  102224. /**
  102225. * Minimum allowed angle to camera position relative to target object.
  102226. * This can help limiting how the Camera is able to move in the scene.
  102227. */
  102228. lowerRotationOffsetLimit: Nullable<number>;
  102229. /**
  102230. * Maximum allowed angle to camera position relative to target object.
  102231. * This can help limiting how the Camera is able to move in the scene.
  102232. */
  102233. upperRotationOffsetLimit: Nullable<number>;
  102234. /**
  102235. * Define a height offset between the camera and the object it follows.
  102236. * It can help following an object from the top (like a car chaing a plane)
  102237. */
  102238. heightOffset: number;
  102239. /**
  102240. * Minimum allowed height of camera position relative to target object.
  102241. * This can help limiting how the Camera is able to move in the scene.
  102242. */
  102243. lowerHeightOffsetLimit: Nullable<number>;
  102244. /**
  102245. * Maximum allowed height of camera position relative to target object.
  102246. * This can help limiting how the Camera is able to move in the scene.
  102247. */
  102248. upperHeightOffsetLimit: Nullable<number>;
  102249. /**
  102250. * Define how fast the camera can accelerate to follow it s target.
  102251. */
  102252. cameraAcceleration: number;
  102253. /**
  102254. * Define the speed limit of the camera following an object.
  102255. */
  102256. maxCameraSpeed: number;
  102257. /**
  102258. * Define the target of the camera.
  102259. */
  102260. lockedTarget: Nullable<AbstractMesh>;
  102261. /**
  102262. * Defines the input associated with the camera.
  102263. */
  102264. inputs: FollowCameraInputsManager;
  102265. /**
  102266. * Instantiates the follow camera.
  102267. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102268. * @param name Define the name of the camera in the scene
  102269. * @param position Define the position of the camera
  102270. * @param scene Define the scene the camera belong to
  102271. * @param lockedTarget Define the target of the camera
  102272. */
  102273. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102274. private _follow;
  102275. /**
  102276. * Attached controls to the current camera.
  102277. * @param element Defines the element the controls should be listened from
  102278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102279. */
  102280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102281. /**
  102282. * Detach the current controls from the camera.
  102283. * The camera will stop reacting to inputs.
  102284. * @param element Defines the element to stop listening the inputs from
  102285. */
  102286. detachControl(element: HTMLElement): void;
  102287. /** @hidden */
  102288. _checkInputs(): void;
  102289. private _checkLimits;
  102290. /**
  102291. * Gets the camera class name.
  102292. * @returns the class name
  102293. */
  102294. getClassName(): string;
  102295. }
  102296. /**
  102297. * Arc Rotate version of the follow camera.
  102298. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102299. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102300. */
  102301. export class ArcFollowCamera extends TargetCamera {
  102302. /** The longitudinal angle of the camera */
  102303. alpha: number;
  102304. /** The latitudinal angle of the camera */
  102305. beta: number;
  102306. /** The radius of the camera from its target */
  102307. radius: number;
  102308. /** Define the camera target (the messh it should follow) */
  102309. target: Nullable<AbstractMesh>;
  102310. private _cartesianCoordinates;
  102311. /**
  102312. * Instantiates a new ArcFollowCamera
  102313. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102314. * @param name Define the name of the camera
  102315. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102316. * @param beta Define the rotation angle of the camera around the elevation axis
  102317. * @param radius Define the radius of the camera from its target point
  102318. * @param target Define the target of the camera
  102319. * @param scene Define the scene the camera belongs to
  102320. */
  102321. constructor(name: string,
  102322. /** The longitudinal angle of the camera */
  102323. alpha: number,
  102324. /** The latitudinal angle of the camera */
  102325. beta: number,
  102326. /** The radius of the camera from its target */
  102327. radius: number,
  102328. /** Define the camera target (the messh it should follow) */
  102329. target: Nullable<AbstractMesh>, scene: Scene);
  102330. private _follow;
  102331. /** @hidden */
  102332. _checkInputs(): void;
  102333. /**
  102334. * Returns the class name of the object.
  102335. * It is mostly used internally for serialization purposes.
  102336. */
  102337. getClassName(): string;
  102338. }
  102339. }
  102340. declare module BABYLON {
  102341. /**
  102342. * Manage the keyboard inputs to control the movement of a follow camera.
  102343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102344. */
  102345. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102346. /**
  102347. * Defines the camera the input is attached to.
  102348. */
  102349. camera: FollowCamera;
  102350. /**
  102351. * Defines the list of key codes associated with the up action (increase heightOffset)
  102352. */
  102353. keysHeightOffsetIncr: number[];
  102354. /**
  102355. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102356. */
  102357. keysHeightOffsetDecr: number[];
  102358. /**
  102359. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102360. */
  102361. keysHeightOffsetModifierAlt: boolean;
  102362. /**
  102363. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102364. */
  102365. keysHeightOffsetModifierCtrl: boolean;
  102366. /**
  102367. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102368. */
  102369. keysHeightOffsetModifierShift: boolean;
  102370. /**
  102371. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102372. */
  102373. keysRotationOffsetIncr: number[];
  102374. /**
  102375. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102376. */
  102377. keysRotationOffsetDecr: number[];
  102378. /**
  102379. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102380. */
  102381. keysRotationOffsetModifierAlt: boolean;
  102382. /**
  102383. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102384. */
  102385. keysRotationOffsetModifierCtrl: boolean;
  102386. /**
  102387. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102388. */
  102389. keysRotationOffsetModifierShift: boolean;
  102390. /**
  102391. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102392. */
  102393. keysRadiusIncr: number[];
  102394. /**
  102395. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102396. */
  102397. keysRadiusDecr: number[];
  102398. /**
  102399. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102400. */
  102401. keysRadiusModifierAlt: boolean;
  102402. /**
  102403. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102404. */
  102405. keysRadiusModifierCtrl: boolean;
  102406. /**
  102407. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102408. */
  102409. keysRadiusModifierShift: boolean;
  102410. /**
  102411. * Defines the rate of change of heightOffset.
  102412. */
  102413. heightSensibility: number;
  102414. /**
  102415. * Defines the rate of change of rotationOffset.
  102416. */
  102417. rotationSensibility: number;
  102418. /**
  102419. * Defines the rate of change of radius.
  102420. */
  102421. radiusSensibility: number;
  102422. private _keys;
  102423. private _ctrlPressed;
  102424. private _altPressed;
  102425. private _shiftPressed;
  102426. private _onCanvasBlurObserver;
  102427. private _onKeyboardObserver;
  102428. private _engine;
  102429. private _scene;
  102430. /**
  102431. * Attach the input controls to a specific dom element to get the input from.
  102432. * @param element Defines the element the controls should be listened from
  102433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102434. */
  102435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102436. /**
  102437. * Detach the current controls from the specified dom element.
  102438. * @param element Defines the element to stop listening the inputs from
  102439. */
  102440. detachControl(element: Nullable<HTMLElement>): void;
  102441. /**
  102442. * Update the current camera state depending on the inputs that have been used this frame.
  102443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102444. */
  102445. checkInputs(): void;
  102446. /**
  102447. * Gets the class name of the current input.
  102448. * @returns the class name
  102449. */
  102450. getClassName(): string;
  102451. /**
  102452. * Get the friendly name associated with the input class.
  102453. * @returns the input friendly name
  102454. */
  102455. getSimpleName(): string;
  102456. /**
  102457. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102458. * allow modification of the heightOffset value.
  102459. */
  102460. private _modifierHeightOffset;
  102461. /**
  102462. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102463. * allow modification of the rotationOffset value.
  102464. */
  102465. private _modifierRotationOffset;
  102466. /**
  102467. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102468. * allow modification of the radius value.
  102469. */
  102470. private _modifierRadius;
  102471. }
  102472. }
  102473. declare module BABYLON {
  102474. interface FreeCameraInputsManager {
  102475. /**
  102476. * @hidden
  102477. */
  102478. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102479. /**
  102480. * Add orientation input support to the input manager.
  102481. * @returns the current input manager
  102482. */
  102483. addDeviceOrientation(): FreeCameraInputsManager;
  102484. }
  102485. /**
  102486. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102487. * Screen rotation is taken into account.
  102488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102489. */
  102490. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102491. private _camera;
  102492. private _screenOrientationAngle;
  102493. private _constantTranform;
  102494. private _screenQuaternion;
  102495. private _alpha;
  102496. private _beta;
  102497. private _gamma;
  102498. /**
  102499. * Can be used to detect if a device orientation sensor is availible on a device
  102500. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102501. * @returns a promise that will resolve on orientation change
  102502. */
  102503. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102504. /**
  102505. * @hidden
  102506. */
  102507. _onDeviceOrientationChangedObservable: Observable<void>;
  102508. /**
  102509. * Instantiates a new input
  102510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102511. */
  102512. constructor();
  102513. /**
  102514. * Define the camera controlled by the input.
  102515. */
  102516. camera: FreeCamera;
  102517. /**
  102518. * Attach the input controls to a specific dom element to get the input from.
  102519. * @param element Defines the element the controls should be listened from
  102520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102521. */
  102522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102523. private _orientationChanged;
  102524. private _deviceOrientation;
  102525. /**
  102526. * Detach the current controls from the specified dom element.
  102527. * @param element Defines the element to stop listening the inputs from
  102528. */
  102529. detachControl(element: Nullable<HTMLElement>): void;
  102530. /**
  102531. * Update the current camera state depending on the inputs that have been used this frame.
  102532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102533. */
  102534. checkInputs(): void;
  102535. /**
  102536. * Gets the class name of the current intput.
  102537. * @returns the class name
  102538. */
  102539. getClassName(): string;
  102540. /**
  102541. * Get the friendly name associated with the input class.
  102542. * @returns the input friendly name
  102543. */
  102544. getSimpleName(): string;
  102545. }
  102546. }
  102547. declare module BABYLON {
  102548. /**
  102549. * Manage the gamepad inputs to control a free camera.
  102550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102551. */
  102552. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102553. /**
  102554. * Define the camera the input is attached to.
  102555. */
  102556. camera: FreeCamera;
  102557. /**
  102558. * Define the Gamepad controlling the input
  102559. */
  102560. gamepad: Nullable<Gamepad>;
  102561. /**
  102562. * Defines the gamepad rotation sensiblity.
  102563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102564. */
  102565. gamepadAngularSensibility: number;
  102566. /**
  102567. * Defines the gamepad move sensiblity.
  102568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102569. */
  102570. gamepadMoveSensibility: number;
  102571. private _onGamepadConnectedObserver;
  102572. private _onGamepadDisconnectedObserver;
  102573. private _cameraTransform;
  102574. private _deltaTransform;
  102575. private _vector3;
  102576. private _vector2;
  102577. /**
  102578. * Attach the input controls to a specific dom element to get the input from.
  102579. * @param element Defines the element the controls should be listened from
  102580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102581. */
  102582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102583. /**
  102584. * Detach the current controls from the specified dom element.
  102585. * @param element Defines the element to stop listening the inputs from
  102586. */
  102587. detachControl(element: Nullable<HTMLElement>): void;
  102588. /**
  102589. * Update the current camera state depending on the inputs that have been used this frame.
  102590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102591. */
  102592. checkInputs(): void;
  102593. /**
  102594. * Gets the class name of the current intput.
  102595. * @returns the class name
  102596. */
  102597. getClassName(): string;
  102598. /**
  102599. * Get the friendly name associated with the input class.
  102600. * @returns the input friendly name
  102601. */
  102602. getSimpleName(): string;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Defines the potential axis of a Joystick
  102608. */
  102609. export enum JoystickAxis {
  102610. /** X axis */
  102611. X = 0,
  102612. /** Y axis */
  102613. Y = 1,
  102614. /** Z axis */
  102615. Z = 2
  102616. }
  102617. /**
  102618. * Class used to define virtual joystick (used in touch mode)
  102619. */
  102620. export class VirtualJoystick {
  102621. /**
  102622. * Gets or sets a boolean indicating that left and right values must be inverted
  102623. */
  102624. reverseLeftRight: boolean;
  102625. /**
  102626. * Gets or sets a boolean indicating that up and down values must be inverted
  102627. */
  102628. reverseUpDown: boolean;
  102629. /**
  102630. * Gets the offset value for the position (ie. the change of the position value)
  102631. */
  102632. deltaPosition: Vector3;
  102633. /**
  102634. * Gets a boolean indicating if the virtual joystick was pressed
  102635. */
  102636. pressed: boolean;
  102637. /**
  102638. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102639. */
  102640. static Canvas: Nullable<HTMLCanvasElement>;
  102641. private static _globalJoystickIndex;
  102642. private static vjCanvasContext;
  102643. private static vjCanvasWidth;
  102644. private static vjCanvasHeight;
  102645. private static halfWidth;
  102646. private _action;
  102647. private _axisTargetedByLeftAndRight;
  102648. private _axisTargetedByUpAndDown;
  102649. private _joystickSensibility;
  102650. private _inversedSensibility;
  102651. private _joystickPointerID;
  102652. private _joystickColor;
  102653. private _joystickPointerPos;
  102654. private _joystickPreviousPointerPos;
  102655. private _joystickPointerStartPos;
  102656. private _deltaJoystickVector;
  102657. private _leftJoystick;
  102658. private _touches;
  102659. private _onPointerDownHandlerRef;
  102660. private _onPointerMoveHandlerRef;
  102661. private _onPointerUpHandlerRef;
  102662. private _onResize;
  102663. /**
  102664. * Creates a new virtual joystick
  102665. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102666. */
  102667. constructor(leftJoystick?: boolean);
  102668. /**
  102669. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102670. * @param newJoystickSensibility defines the new sensibility
  102671. */
  102672. setJoystickSensibility(newJoystickSensibility: number): void;
  102673. private _onPointerDown;
  102674. private _onPointerMove;
  102675. private _onPointerUp;
  102676. /**
  102677. * Change the color of the virtual joystick
  102678. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102679. */
  102680. setJoystickColor(newColor: string): void;
  102681. /**
  102682. * Defines a callback to call when the joystick is touched
  102683. * @param action defines the callback
  102684. */
  102685. setActionOnTouch(action: () => any): void;
  102686. /**
  102687. * Defines which axis you'd like to control for left & right
  102688. * @param axis defines the axis to use
  102689. */
  102690. setAxisForLeftRight(axis: JoystickAxis): void;
  102691. /**
  102692. * Defines which axis you'd like to control for up & down
  102693. * @param axis defines the axis to use
  102694. */
  102695. setAxisForUpDown(axis: JoystickAxis): void;
  102696. private _drawVirtualJoystick;
  102697. /**
  102698. * Release internal HTML canvas
  102699. */
  102700. releaseCanvas(): void;
  102701. }
  102702. }
  102703. declare module BABYLON {
  102704. interface FreeCameraInputsManager {
  102705. /**
  102706. * Add virtual joystick input support to the input manager.
  102707. * @returns the current input manager
  102708. */
  102709. addVirtualJoystick(): FreeCameraInputsManager;
  102710. }
  102711. /**
  102712. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102714. */
  102715. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102716. /**
  102717. * Defines the camera the input is attached to.
  102718. */
  102719. camera: FreeCamera;
  102720. private _leftjoystick;
  102721. private _rightjoystick;
  102722. /**
  102723. * Gets the left stick of the virtual joystick.
  102724. * @returns The virtual Joystick
  102725. */
  102726. getLeftJoystick(): VirtualJoystick;
  102727. /**
  102728. * Gets the right stick of the virtual joystick.
  102729. * @returns The virtual Joystick
  102730. */
  102731. getRightJoystick(): VirtualJoystick;
  102732. /**
  102733. * Update the current camera state depending on the inputs that have been used this frame.
  102734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102735. */
  102736. checkInputs(): void;
  102737. /**
  102738. * Attach the input controls to a specific dom element to get the input from.
  102739. * @param element Defines the element the controls should be listened from
  102740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102741. */
  102742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102743. /**
  102744. * Detach the current controls from the specified dom element.
  102745. * @param element Defines the element to stop listening the inputs from
  102746. */
  102747. detachControl(element: Nullable<HTMLElement>): void;
  102748. /**
  102749. * Gets the class name of the current intput.
  102750. * @returns the class name
  102751. */
  102752. getClassName(): string;
  102753. /**
  102754. * Get the friendly name associated with the input class.
  102755. * @returns the input friendly name
  102756. */
  102757. getSimpleName(): string;
  102758. }
  102759. }
  102760. declare module BABYLON {
  102761. /**
  102762. * This represents a FPS type of camera controlled by touch.
  102763. * This is like a universal camera minus the Gamepad controls.
  102764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102765. */
  102766. export class TouchCamera extends FreeCamera {
  102767. /**
  102768. * Defines the touch sensibility for rotation.
  102769. * The higher the faster.
  102770. */
  102771. touchAngularSensibility: number;
  102772. /**
  102773. * Defines the touch sensibility for move.
  102774. * The higher the faster.
  102775. */
  102776. touchMoveSensibility: number;
  102777. /**
  102778. * Instantiates a new touch camera.
  102779. * This represents a FPS type of camera controlled by touch.
  102780. * This is like a universal camera minus the Gamepad controls.
  102781. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102782. * @param name Define the name of the camera in the scene
  102783. * @param position Define the start position of the camera in the scene
  102784. * @param scene Define the scene the camera belongs to
  102785. */
  102786. constructor(name: string, position: Vector3, scene: Scene);
  102787. /**
  102788. * Gets the current object class name.
  102789. * @return the class name
  102790. */
  102791. getClassName(): string;
  102792. /** @hidden */
  102793. _setupInputs(): void;
  102794. }
  102795. }
  102796. declare module BABYLON {
  102797. /**
  102798. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102799. * being tilted forward or back and left or right.
  102800. */
  102801. export class DeviceOrientationCamera extends FreeCamera {
  102802. private _initialQuaternion;
  102803. private _quaternionCache;
  102804. private _tmpDragQuaternion;
  102805. private _disablePointerInputWhenUsingDeviceOrientation;
  102806. /**
  102807. * Creates a new device orientation camera
  102808. * @param name The name of the camera
  102809. * @param position The start position camera
  102810. * @param scene The scene the camera belongs to
  102811. */
  102812. constructor(name: string, position: Vector3, scene: Scene);
  102813. /**
  102814. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  102815. */
  102816. disablePointerInputWhenUsingDeviceOrientation: boolean;
  102817. private _dragFactor;
  102818. /**
  102819. * Enabled turning on the y axis when the orientation sensor is active
  102820. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102821. */
  102822. enableHorizontalDragging(dragFactor?: number): void;
  102823. /**
  102824. * Gets the current instance class name ("DeviceOrientationCamera").
  102825. * This helps avoiding instanceof at run time.
  102826. * @returns the class name
  102827. */
  102828. getClassName(): string;
  102829. /**
  102830. * @hidden
  102831. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102832. */
  102833. _checkInputs(): void;
  102834. /**
  102835. * Reset the camera to its default orientation on the specified axis only.
  102836. * @param axis The axis to reset
  102837. */
  102838. resetToCurrentRotation(axis?: Axis): void;
  102839. }
  102840. }
  102841. declare module BABYLON {
  102842. /**
  102843. * Defines supported buttons for XBox360 compatible gamepads
  102844. */
  102845. export enum Xbox360Button {
  102846. /** A */
  102847. A = 0,
  102848. /** B */
  102849. B = 1,
  102850. /** X */
  102851. X = 2,
  102852. /** Y */
  102853. Y = 3,
  102854. /** Start */
  102855. Start = 4,
  102856. /** Back */
  102857. Back = 5,
  102858. /** Left button */
  102859. LB = 6,
  102860. /** Right button */
  102861. RB = 7,
  102862. /** Left stick */
  102863. LeftStick = 8,
  102864. /** Right stick */
  102865. RightStick = 9
  102866. }
  102867. /** Defines values for XBox360 DPad */
  102868. export enum Xbox360Dpad {
  102869. /** Up */
  102870. Up = 0,
  102871. /** Down */
  102872. Down = 1,
  102873. /** Left */
  102874. Left = 2,
  102875. /** Right */
  102876. Right = 3
  102877. }
  102878. /**
  102879. * Defines a XBox360 gamepad
  102880. */
  102881. export class Xbox360Pad extends Gamepad {
  102882. private _leftTrigger;
  102883. private _rightTrigger;
  102884. private _onlefttriggerchanged;
  102885. private _onrighttriggerchanged;
  102886. private _onbuttondown;
  102887. private _onbuttonup;
  102888. private _ondpaddown;
  102889. private _ondpadup;
  102890. /** Observable raised when a button is pressed */
  102891. onButtonDownObservable: Observable<Xbox360Button>;
  102892. /** Observable raised when a button is released */
  102893. onButtonUpObservable: Observable<Xbox360Button>;
  102894. /** Observable raised when a pad is pressed */
  102895. onPadDownObservable: Observable<Xbox360Dpad>;
  102896. /** Observable raised when a pad is released */
  102897. onPadUpObservable: Observable<Xbox360Dpad>;
  102898. private _buttonA;
  102899. private _buttonB;
  102900. private _buttonX;
  102901. private _buttonY;
  102902. private _buttonBack;
  102903. private _buttonStart;
  102904. private _buttonLB;
  102905. private _buttonRB;
  102906. private _buttonLeftStick;
  102907. private _buttonRightStick;
  102908. private _dPadUp;
  102909. private _dPadDown;
  102910. private _dPadLeft;
  102911. private _dPadRight;
  102912. private _isXboxOnePad;
  102913. /**
  102914. * Creates a new XBox360 gamepad object
  102915. * @param id defines the id of this gamepad
  102916. * @param index defines its index
  102917. * @param gamepad defines the internal HTML gamepad object
  102918. * @param xboxOne defines if it is a XBox One gamepad
  102919. */
  102920. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102921. /**
  102922. * Defines the callback to call when left trigger is pressed
  102923. * @param callback defines the callback to use
  102924. */
  102925. onlefttriggerchanged(callback: (value: number) => void): void;
  102926. /**
  102927. * Defines the callback to call when right trigger is pressed
  102928. * @param callback defines the callback to use
  102929. */
  102930. onrighttriggerchanged(callback: (value: number) => void): void;
  102931. /**
  102932. * Gets the left trigger value
  102933. */
  102934. /**
  102935. * Sets the left trigger value
  102936. */
  102937. leftTrigger: number;
  102938. /**
  102939. * Gets the right trigger value
  102940. */
  102941. /**
  102942. * Sets the right trigger value
  102943. */
  102944. rightTrigger: number;
  102945. /**
  102946. * Defines the callback to call when a button is pressed
  102947. * @param callback defines the callback to use
  102948. */
  102949. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102950. /**
  102951. * Defines the callback to call when a button is released
  102952. * @param callback defines the callback to use
  102953. */
  102954. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102955. /**
  102956. * Defines the callback to call when a pad is pressed
  102957. * @param callback defines the callback to use
  102958. */
  102959. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102960. /**
  102961. * Defines the callback to call when a pad is released
  102962. * @param callback defines the callback to use
  102963. */
  102964. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102965. private _setButtonValue;
  102966. private _setDPadValue;
  102967. /**
  102968. * Gets the value of the `A` button
  102969. */
  102970. /**
  102971. * Sets the value of the `A` button
  102972. */
  102973. buttonA: number;
  102974. /**
  102975. * Gets the value of the `B` button
  102976. */
  102977. /**
  102978. * Sets the value of the `B` button
  102979. */
  102980. buttonB: number;
  102981. /**
  102982. * Gets the value of the `X` button
  102983. */
  102984. /**
  102985. * Sets the value of the `X` button
  102986. */
  102987. buttonX: number;
  102988. /**
  102989. * Gets the value of the `Y` button
  102990. */
  102991. /**
  102992. * Sets the value of the `Y` button
  102993. */
  102994. buttonY: number;
  102995. /**
  102996. * Gets the value of the `Start` button
  102997. */
  102998. /**
  102999. * Sets the value of the `Start` button
  103000. */
  103001. buttonStart: number;
  103002. /**
  103003. * Gets the value of the `Back` button
  103004. */
  103005. /**
  103006. * Sets the value of the `Back` button
  103007. */
  103008. buttonBack: number;
  103009. /**
  103010. * Gets the value of the `Left` button
  103011. */
  103012. /**
  103013. * Sets the value of the `Left` button
  103014. */
  103015. buttonLB: number;
  103016. /**
  103017. * Gets the value of the `Right` button
  103018. */
  103019. /**
  103020. * Sets the value of the `Right` button
  103021. */
  103022. buttonRB: number;
  103023. /**
  103024. * Gets the value of the Left joystick
  103025. */
  103026. /**
  103027. * Sets the value of the Left joystick
  103028. */
  103029. buttonLeftStick: number;
  103030. /**
  103031. * Gets the value of the Right joystick
  103032. */
  103033. /**
  103034. * Sets the value of the Right joystick
  103035. */
  103036. buttonRightStick: number;
  103037. /**
  103038. * Gets the value of D-pad up
  103039. */
  103040. /**
  103041. * Sets the value of D-pad up
  103042. */
  103043. dPadUp: number;
  103044. /**
  103045. * Gets the value of D-pad down
  103046. */
  103047. /**
  103048. * Sets the value of D-pad down
  103049. */
  103050. dPadDown: number;
  103051. /**
  103052. * Gets the value of D-pad left
  103053. */
  103054. /**
  103055. * Sets the value of D-pad left
  103056. */
  103057. dPadLeft: number;
  103058. /**
  103059. * Gets the value of D-pad right
  103060. */
  103061. /**
  103062. * Sets the value of D-pad right
  103063. */
  103064. dPadRight: number;
  103065. /**
  103066. * Force the gamepad to synchronize with device values
  103067. */
  103068. update(): void;
  103069. /**
  103070. * Disposes the gamepad
  103071. */
  103072. dispose(): void;
  103073. }
  103074. }
  103075. declare module BABYLON {
  103076. /**
  103077. * Defines supported buttons for DualShock compatible gamepads
  103078. */
  103079. export enum DualShockButton {
  103080. /** Cross */
  103081. Cross = 0,
  103082. /** Circle */
  103083. Circle = 1,
  103084. /** Square */
  103085. Square = 2,
  103086. /** Triangle */
  103087. Triangle = 3,
  103088. /** Options */
  103089. Options = 4,
  103090. /** Share */
  103091. Share = 5,
  103092. /** L1 */
  103093. L1 = 6,
  103094. /** R1 */
  103095. R1 = 7,
  103096. /** Left stick */
  103097. LeftStick = 8,
  103098. /** Right stick */
  103099. RightStick = 9
  103100. }
  103101. /** Defines values for DualShock DPad */
  103102. export enum DualShockDpad {
  103103. /** Up */
  103104. Up = 0,
  103105. /** Down */
  103106. Down = 1,
  103107. /** Left */
  103108. Left = 2,
  103109. /** Right */
  103110. Right = 3
  103111. }
  103112. /**
  103113. * Defines a DualShock gamepad
  103114. */
  103115. export class DualShockPad extends Gamepad {
  103116. private _leftTrigger;
  103117. private _rightTrigger;
  103118. private _onlefttriggerchanged;
  103119. private _onrighttriggerchanged;
  103120. private _onbuttondown;
  103121. private _onbuttonup;
  103122. private _ondpaddown;
  103123. private _ondpadup;
  103124. /** Observable raised when a button is pressed */
  103125. onButtonDownObservable: Observable<DualShockButton>;
  103126. /** Observable raised when a button is released */
  103127. onButtonUpObservable: Observable<DualShockButton>;
  103128. /** Observable raised when a pad is pressed */
  103129. onPadDownObservable: Observable<DualShockDpad>;
  103130. /** Observable raised when a pad is released */
  103131. onPadUpObservable: Observable<DualShockDpad>;
  103132. private _buttonCross;
  103133. private _buttonCircle;
  103134. private _buttonSquare;
  103135. private _buttonTriangle;
  103136. private _buttonShare;
  103137. private _buttonOptions;
  103138. private _buttonL1;
  103139. private _buttonR1;
  103140. private _buttonLeftStick;
  103141. private _buttonRightStick;
  103142. private _dPadUp;
  103143. private _dPadDown;
  103144. private _dPadLeft;
  103145. private _dPadRight;
  103146. /**
  103147. * Creates a new DualShock gamepad object
  103148. * @param id defines the id of this gamepad
  103149. * @param index defines its index
  103150. * @param gamepad defines the internal HTML gamepad object
  103151. */
  103152. constructor(id: string, index: number, gamepad: any);
  103153. /**
  103154. * Defines the callback to call when left trigger is pressed
  103155. * @param callback defines the callback to use
  103156. */
  103157. onlefttriggerchanged(callback: (value: number) => void): void;
  103158. /**
  103159. * Defines the callback to call when right trigger is pressed
  103160. * @param callback defines the callback to use
  103161. */
  103162. onrighttriggerchanged(callback: (value: number) => void): void;
  103163. /**
  103164. * Gets the left trigger value
  103165. */
  103166. /**
  103167. * Sets the left trigger value
  103168. */
  103169. leftTrigger: number;
  103170. /**
  103171. * Gets the right trigger value
  103172. */
  103173. /**
  103174. * Sets the right trigger value
  103175. */
  103176. rightTrigger: number;
  103177. /**
  103178. * Defines the callback to call when a button is pressed
  103179. * @param callback defines the callback to use
  103180. */
  103181. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103182. /**
  103183. * Defines the callback to call when a button is released
  103184. * @param callback defines the callback to use
  103185. */
  103186. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103187. /**
  103188. * Defines the callback to call when a pad is pressed
  103189. * @param callback defines the callback to use
  103190. */
  103191. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103192. /**
  103193. * Defines the callback to call when a pad is released
  103194. * @param callback defines the callback to use
  103195. */
  103196. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103197. private _setButtonValue;
  103198. private _setDPadValue;
  103199. /**
  103200. * Gets the value of the `Cross` button
  103201. */
  103202. /**
  103203. * Sets the value of the `Cross` button
  103204. */
  103205. buttonCross: number;
  103206. /**
  103207. * Gets the value of the `Circle` button
  103208. */
  103209. /**
  103210. * Sets the value of the `Circle` button
  103211. */
  103212. buttonCircle: number;
  103213. /**
  103214. * Gets the value of the `Square` button
  103215. */
  103216. /**
  103217. * Sets the value of the `Square` button
  103218. */
  103219. buttonSquare: number;
  103220. /**
  103221. * Gets the value of the `Triangle` button
  103222. */
  103223. /**
  103224. * Sets the value of the `Triangle` button
  103225. */
  103226. buttonTriangle: number;
  103227. /**
  103228. * Gets the value of the `Options` button
  103229. */
  103230. /**
  103231. * Sets the value of the `Options` button
  103232. */
  103233. buttonOptions: number;
  103234. /**
  103235. * Gets the value of the `Share` button
  103236. */
  103237. /**
  103238. * Sets the value of the `Share` button
  103239. */
  103240. buttonShare: number;
  103241. /**
  103242. * Gets the value of the `L1` button
  103243. */
  103244. /**
  103245. * Sets the value of the `L1` button
  103246. */
  103247. buttonL1: number;
  103248. /**
  103249. * Gets the value of the `R1` button
  103250. */
  103251. /**
  103252. * Sets the value of the `R1` button
  103253. */
  103254. buttonR1: number;
  103255. /**
  103256. * Gets the value of the Left joystick
  103257. */
  103258. /**
  103259. * Sets the value of the Left joystick
  103260. */
  103261. buttonLeftStick: number;
  103262. /**
  103263. * Gets the value of the Right joystick
  103264. */
  103265. /**
  103266. * Sets the value of the Right joystick
  103267. */
  103268. buttonRightStick: number;
  103269. /**
  103270. * Gets the value of D-pad up
  103271. */
  103272. /**
  103273. * Sets the value of D-pad up
  103274. */
  103275. dPadUp: number;
  103276. /**
  103277. * Gets the value of D-pad down
  103278. */
  103279. /**
  103280. * Sets the value of D-pad down
  103281. */
  103282. dPadDown: number;
  103283. /**
  103284. * Gets the value of D-pad left
  103285. */
  103286. /**
  103287. * Sets the value of D-pad left
  103288. */
  103289. dPadLeft: number;
  103290. /**
  103291. * Gets the value of D-pad right
  103292. */
  103293. /**
  103294. * Sets the value of D-pad right
  103295. */
  103296. dPadRight: number;
  103297. /**
  103298. * Force the gamepad to synchronize with device values
  103299. */
  103300. update(): void;
  103301. /**
  103302. * Disposes the gamepad
  103303. */
  103304. dispose(): void;
  103305. }
  103306. }
  103307. declare module BABYLON {
  103308. /**
  103309. * Manager for handling gamepads
  103310. */
  103311. export class GamepadManager {
  103312. private _scene?;
  103313. private _babylonGamepads;
  103314. private _oneGamepadConnected;
  103315. /** @hidden */
  103316. _isMonitoring: boolean;
  103317. private _gamepadEventSupported;
  103318. private _gamepadSupport;
  103319. /**
  103320. * observable to be triggered when the gamepad controller has been connected
  103321. */
  103322. onGamepadConnectedObservable: Observable<Gamepad>;
  103323. /**
  103324. * observable to be triggered when the gamepad controller has been disconnected
  103325. */
  103326. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103327. private _onGamepadConnectedEvent;
  103328. private _onGamepadDisconnectedEvent;
  103329. /**
  103330. * Initializes the gamepad manager
  103331. * @param _scene BabylonJS scene
  103332. */
  103333. constructor(_scene?: Scene | undefined);
  103334. /**
  103335. * The gamepads in the game pad manager
  103336. */
  103337. readonly gamepads: Gamepad[];
  103338. /**
  103339. * Get the gamepad controllers based on type
  103340. * @param type The type of gamepad controller
  103341. * @returns Nullable gamepad
  103342. */
  103343. getGamepadByType(type?: number): Nullable<Gamepad>;
  103344. /**
  103345. * Disposes the gamepad manager
  103346. */
  103347. dispose(): void;
  103348. private _addNewGamepad;
  103349. private _startMonitoringGamepads;
  103350. private _stopMonitoringGamepads;
  103351. /** @hidden */
  103352. _checkGamepadsStatus(): void;
  103353. private _updateGamepadObjects;
  103354. }
  103355. }
  103356. declare module BABYLON {
  103357. interface Scene {
  103358. /** @hidden */
  103359. _gamepadManager: Nullable<GamepadManager>;
  103360. /**
  103361. * Gets the gamepad manager associated with the scene
  103362. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103363. */
  103364. gamepadManager: GamepadManager;
  103365. }
  103366. /**
  103367. * Interface representing a free camera inputs manager
  103368. */
  103369. interface FreeCameraInputsManager {
  103370. /**
  103371. * Adds gamepad input support to the FreeCameraInputsManager.
  103372. * @returns the FreeCameraInputsManager
  103373. */
  103374. addGamepad(): FreeCameraInputsManager;
  103375. }
  103376. /**
  103377. * Interface representing an arc rotate camera inputs manager
  103378. */
  103379. interface ArcRotateCameraInputsManager {
  103380. /**
  103381. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103382. * @returns the camera inputs manager
  103383. */
  103384. addGamepad(): ArcRotateCameraInputsManager;
  103385. }
  103386. /**
  103387. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103388. */
  103389. export class GamepadSystemSceneComponent implements ISceneComponent {
  103390. /**
  103391. * The component name helpfull to identify the component in the list of scene components.
  103392. */
  103393. readonly name: string;
  103394. /**
  103395. * The scene the component belongs to.
  103396. */
  103397. scene: Scene;
  103398. /**
  103399. * Creates a new instance of the component for the given scene
  103400. * @param scene Defines the scene to register the component in
  103401. */
  103402. constructor(scene: Scene);
  103403. /**
  103404. * Registers the component in a given scene
  103405. */
  103406. register(): void;
  103407. /**
  103408. * Rebuilds the elements related to this component in case of
  103409. * context lost for instance.
  103410. */
  103411. rebuild(): void;
  103412. /**
  103413. * Disposes the component and the associated ressources
  103414. */
  103415. dispose(): void;
  103416. private _beforeCameraUpdate;
  103417. }
  103418. }
  103419. declare module BABYLON {
  103420. /**
  103421. * 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,
  103422. * which still works and will still be found in many Playgrounds.
  103423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103424. */
  103425. export class UniversalCamera extends TouchCamera {
  103426. /**
  103427. * Defines the gamepad rotation sensiblity.
  103428. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103429. */
  103430. gamepadAngularSensibility: number;
  103431. /**
  103432. * Defines the gamepad move sensiblity.
  103433. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103434. */
  103435. gamepadMoveSensibility: number;
  103436. /**
  103437. * 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,
  103438. * which still works and will still be found in many Playgrounds.
  103439. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103440. * @param name Define the name of the camera in the scene
  103441. * @param position Define the start position of the camera in the scene
  103442. * @param scene Define the scene the camera belongs to
  103443. */
  103444. constructor(name: string, position: Vector3, scene: Scene);
  103445. /**
  103446. * Gets the current object class name.
  103447. * @return the class name
  103448. */
  103449. getClassName(): string;
  103450. }
  103451. }
  103452. declare module BABYLON {
  103453. /**
  103454. * This represents a FPS type of camera. This is only here for back compat purpose.
  103455. * Please use the UniversalCamera instead as both are identical.
  103456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103457. */
  103458. export class GamepadCamera extends UniversalCamera {
  103459. /**
  103460. * Instantiates a new Gamepad Camera
  103461. * This represents a FPS type of camera. This is only here for back compat purpose.
  103462. * Please use the UniversalCamera instead as both are identical.
  103463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103464. * @param name Define the name of the camera in the scene
  103465. * @param position Define the start position of the camera in the scene
  103466. * @param scene Define the scene the camera belongs to
  103467. */
  103468. constructor(name: string, position: Vector3, scene: Scene);
  103469. /**
  103470. * Gets the current object class name.
  103471. * @return the class name
  103472. */
  103473. getClassName(): string;
  103474. }
  103475. }
  103476. declare module BABYLON {
  103477. /** @hidden */
  103478. export var passPixelShader: {
  103479. name: string;
  103480. shader: string;
  103481. };
  103482. }
  103483. declare module BABYLON {
  103484. /** @hidden */
  103485. export var passCubePixelShader: {
  103486. name: string;
  103487. shader: string;
  103488. };
  103489. }
  103490. declare module BABYLON {
  103491. /**
  103492. * PassPostProcess which produces an output the same as it's input
  103493. */
  103494. export class PassPostProcess extends PostProcess {
  103495. /**
  103496. * Creates the PassPostProcess
  103497. * @param name The name of the effect.
  103498. * @param options The required width/height ratio to downsize to before computing the render pass.
  103499. * @param camera The camera to apply the render pass to.
  103500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103501. * @param engine The engine which the post process will be applied. (default: current engine)
  103502. * @param reusable If the post process can be reused on the same frame. (default: false)
  103503. * @param textureType The type of texture to be used when performing the post processing.
  103504. * @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)
  103505. */
  103506. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103507. }
  103508. /**
  103509. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103510. */
  103511. export class PassCubePostProcess extends PostProcess {
  103512. private _face;
  103513. /**
  103514. * Gets or sets the cube face to display.
  103515. * * 0 is +X
  103516. * * 1 is -X
  103517. * * 2 is +Y
  103518. * * 3 is -Y
  103519. * * 4 is +Z
  103520. * * 5 is -Z
  103521. */
  103522. face: number;
  103523. /**
  103524. * Creates the PassCubePostProcess
  103525. * @param name The name of the effect.
  103526. * @param options The required width/height ratio to downsize to before computing the render pass.
  103527. * @param camera The camera to apply the render pass to.
  103528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103529. * @param engine The engine which the post process will be applied. (default: current engine)
  103530. * @param reusable If the post process can be reused on the same frame. (default: false)
  103531. * @param textureType The type of texture to be used when performing the post processing.
  103532. * @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)
  103533. */
  103534. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103535. }
  103536. }
  103537. declare module BABYLON {
  103538. /** @hidden */
  103539. export var anaglyphPixelShader: {
  103540. name: string;
  103541. shader: string;
  103542. };
  103543. }
  103544. declare module BABYLON {
  103545. /**
  103546. * Postprocess used to generate anaglyphic rendering
  103547. */
  103548. export class AnaglyphPostProcess extends PostProcess {
  103549. private _passedProcess;
  103550. /**
  103551. * Creates a new AnaglyphPostProcess
  103552. * @param name defines postprocess name
  103553. * @param options defines creation options or target ratio scale
  103554. * @param rigCameras defines cameras using this postprocess
  103555. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103556. * @param engine defines hosting engine
  103557. * @param reusable defines if the postprocess will be reused multiple times per frame
  103558. */
  103559. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103560. }
  103561. }
  103562. declare module BABYLON {
  103563. /**
  103564. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103565. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103566. */
  103567. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103568. /**
  103569. * Creates a new AnaglyphArcRotateCamera
  103570. * @param name defines camera name
  103571. * @param alpha defines alpha angle (in radians)
  103572. * @param beta defines beta angle (in radians)
  103573. * @param radius defines radius
  103574. * @param target defines camera target
  103575. * @param interaxialDistance defines distance between each color axis
  103576. * @param scene defines the hosting scene
  103577. */
  103578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103579. /**
  103580. * Gets camera class name
  103581. * @returns AnaglyphArcRotateCamera
  103582. */
  103583. getClassName(): string;
  103584. }
  103585. }
  103586. declare module BABYLON {
  103587. /**
  103588. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103589. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103590. */
  103591. export class AnaglyphFreeCamera extends FreeCamera {
  103592. /**
  103593. * Creates a new AnaglyphFreeCamera
  103594. * @param name defines camera name
  103595. * @param position defines initial position
  103596. * @param interaxialDistance defines distance between each color axis
  103597. * @param scene defines the hosting scene
  103598. */
  103599. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103600. /**
  103601. * Gets camera class name
  103602. * @returns AnaglyphFreeCamera
  103603. */
  103604. getClassName(): string;
  103605. }
  103606. }
  103607. declare module BABYLON {
  103608. /**
  103609. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103610. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103611. */
  103612. export class AnaglyphGamepadCamera extends GamepadCamera {
  103613. /**
  103614. * Creates a new AnaglyphGamepadCamera
  103615. * @param name defines camera name
  103616. * @param position defines initial position
  103617. * @param interaxialDistance defines distance between each color axis
  103618. * @param scene defines the hosting scene
  103619. */
  103620. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103621. /**
  103622. * Gets camera class name
  103623. * @returns AnaglyphGamepadCamera
  103624. */
  103625. getClassName(): string;
  103626. }
  103627. }
  103628. declare module BABYLON {
  103629. /**
  103630. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103632. */
  103633. export class AnaglyphUniversalCamera extends UniversalCamera {
  103634. /**
  103635. * Creates a new AnaglyphUniversalCamera
  103636. * @param name defines camera name
  103637. * @param position defines initial position
  103638. * @param interaxialDistance defines distance between each color axis
  103639. * @param scene defines the hosting scene
  103640. */
  103641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103642. /**
  103643. * Gets camera class name
  103644. * @returns AnaglyphUniversalCamera
  103645. */
  103646. getClassName(): string;
  103647. }
  103648. }
  103649. declare module BABYLON {
  103650. /** @hidden */
  103651. export var stereoscopicInterlacePixelShader: {
  103652. name: string;
  103653. shader: string;
  103654. };
  103655. }
  103656. declare module BABYLON {
  103657. /**
  103658. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103659. */
  103660. export class StereoscopicInterlacePostProcess extends PostProcess {
  103661. private _stepSize;
  103662. private _passedProcess;
  103663. /**
  103664. * Initializes a StereoscopicInterlacePostProcess
  103665. * @param name The name of the effect.
  103666. * @param rigCameras The rig cameras to be appled to the post process
  103667. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103669. * @param engine The engine which the post process will be applied. (default: current engine)
  103670. * @param reusable If the post process can be reused on the same frame. (default: false)
  103671. */
  103672. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103673. }
  103674. }
  103675. declare module BABYLON {
  103676. /**
  103677. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103678. * @see http://doc.babylonjs.com/features/cameras
  103679. */
  103680. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103681. /**
  103682. * Creates a new StereoscopicArcRotateCamera
  103683. * @param name defines camera name
  103684. * @param alpha defines alpha angle (in radians)
  103685. * @param beta defines beta angle (in radians)
  103686. * @param radius defines radius
  103687. * @param target defines camera target
  103688. * @param interaxialDistance defines distance between each color axis
  103689. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103690. * @param scene defines the hosting scene
  103691. */
  103692. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103693. /**
  103694. * Gets camera class name
  103695. * @returns StereoscopicArcRotateCamera
  103696. */
  103697. getClassName(): string;
  103698. }
  103699. }
  103700. declare module BABYLON {
  103701. /**
  103702. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103703. * @see http://doc.babylonjs.com/features/cameras
  103704. */
  103705. export class StereoscopicFreeCamera extends FreeCamera {
  103706. /**
  103707. * Creates a new StereoscopicFreeCamera
  103708. * @param name defines camera name
  103709. * @param position defines initial position
  103710. * @param interaxialDistance defines distance between each color axis
  103711. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103712. * @param scene defines the hosting scene
  103713. */
  103714. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103715. /**
  103716. * Gets camera class name
  103717. * @returns StereoscopicFreeCamera
  103718. */
  103719. getClassName(): string;
  103720. }
  103721. }
  103722. declare module BABYLON {
  103723. /**
  103724. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103725. * @see http://doc.babylonjs.com/features/cameras
  103726. */
  103727. export class StereoscopicGamepadCamera extends GamepadCamera {
  103728. /**
  103729. * Creates a new StereoscopicGamepadCamera
  103730. * @param name defines camera name
  103731. * @param position defines initial position
  103732. * @param interaxialDistance defines distance between each color axis
  103733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103734. * @param scene defines the hosting scene
  103735. */
  103736. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103737. /**
  103738. * Gets camera class name
  103739. * @returns StereoscopicGamepadCamera
  103740. */
  103741. getClassName(): string;
  103742. }
  103743. }
  103744. declare module BABYLON {
  103745. /**
  103746. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103747. * @see http://doc.babylonjs.com/features/cameras
  103748. */
  103749. export class StereoscopicUniversalCamera extends UniversalCamera {
  103750. /**
  103751. * Creates a new StereoscopicUniversalCamera
  103752. * @param name defines camera name
  103753. * @param position defines initial position
  103754. * @param interaxialDistance defines distance between each color axis
  103755. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103756. * @param scene defines the hosting scene
  103757. */
  103758. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103759. /**
  103760. * Gets camera class name
  103761. * @returns StereoscopicUniversalCamera
  103762. */
  103763. getClassName(): string;
  103764. }
  103765. }
  103766. declare module BABYLON {
  103767. /**
  103768. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103769. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103770. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103771. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103772. */
  103773. export class VirtualJoysticksCamera extends FreeCamera {
  103774. /**
  103775. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103776. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103777. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103778. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103779. * @param name Define the name of the camera in the scene
  103780. * @param position Define the start position of the camera in the scene
  103781. * @param scene Define the scene the camera belongs to
  103782. */
  103783. constructor(name: string, position: Vector3, scene: Scene);
  103784. /**
  103785. * Gets the current object class name.
  103786. * @return the class name
  103787. */
  103788. getClassName(): string;
  103789. }
  103790. }
  103791. declare module BABYLON {
  103792. /**
  103793. * This represents all the required metrics to create a VR camera.
  103794. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103795. */
  103796. export class VRCameraMetrics {
  103797. /**
  103798. * Define the horizontal resolution off the screen.
  103799. */
  103800. hResolution: number;
  103801. /**
  103802. * Define the vertical resolution off the screen.
  103803. */
  103804. vResolution: number;
  103805. /**
  103806. * Define the horizontal screen size.
  103807. */
  103808. hScreenSize: number;
  103809. /**
  103810. * Define the vertical screen size.
  103811. */
  103812. vScreenSize: number;
  103813. /**
  103814. * Define the vertical screen center position.
  103815. */
  103816. vScreenCenter: number;
  103817. /**
  103818. * Define the distance of the eyes to the screen.
  103819. */
  103820. eyeToScreenDistance: number;
  103821. /**
  103822. * Define the distance between both lenses
  103823. */
  103824. lensSeparationDistance: number;
  103825. /**
  103826. * Define the distance between both viewer's eyes.
  103827. */
  103828. interpupillaryDistance: number;
  103829. /**
  103830. * Define the distortion factor of the VR postprocess.
  103831. * Please, touch with care.
  103832. */
  103833. distortionK: number[];
  103834. /**
  103835. * Define the chromatic aberration correction factors for the VR post process.
  103836. */
  103837. chromaAbCorrection: number[];
  103838. /**
  103839. * Define the scale factor of the post process.
  103840. * The smaller the better but the slower.
  103841. */
  103842. postProcessScaleFactor: number;
  103843. /**
  103844. * Define an offset for the lens center.
  103845. */
  103846. lensCenterOffset: number;
  103847. /**
  103848. * Define if the current vr camera should compensate the distortion of the lense or not.
  103849. */
  103850. compensateDistortion: boolean;
  103851. /**
  103852. * Defines if multiview should be enabled when rendering (Default: false)
  103853. */
  103854. multiviewEnabled: boolean;
  103855. /**
  103856. * Gets the rendering aspect ratio based on the provided resolutions.
  103857. */
  103858. readonly aspectRatio: number;
  103859. /**
  103860. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103861. */
  103862. readonly aspectRatioFov: number;
  103863. /**
  103864. * @hidden
  103865. */
  103866. readonly leftHMatrix: Matrix;
  103867. /**
  103868. * @hidden
  103869. */
  103870. readonly rightHMatrix: Matrix;
  103871. /**
  103872. * @hidden
  103873. */
  103874. readonly leftPreViewMatrix: Matrix;
  103875. /**
  103876. * @hidden
  103877. */
  103878. readonly rightPreViewMatrix: Matrix;
  103879. /**
  103880. * Get the default VRMetrics based on the most generic setup.
  103881. * @returns the default vr metrics
  103882. */
  103883. static GetDefault(): VRCameraMetrics;
  103884. }
  103885. }
  103886. declare module BABYLON {
  103887. /** @hidden */
  103888. export var vrDistortionCorrectionPixelShader: {
  103889. name: string;
  103890. shader: string;
  103891. };
  103892. }
  103893. declare module BABYLON {
  103894. /**
  103895. * VRDistortionCorrectionPostProcess used for mobile VR
  103896. */
  103897. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103898. private _isRightEye;
  103899. private _distortionFactors;
  103900. private _postProcessScaleFactor;
  103901. private _lensCenterOffset;
  103902. private _scaleIn;
  103903. private _scaleFactor;
  103904. private _lensCenter;
  103905. /**
  103906. * Initializes the VRDistortionCorrectionPostProcess
  103907. * @param name The name of the effect.
  103908. * @param camera The camera to apply the render pass to.
  103909. * @param isRightEye If this is for the right eye distortion
  103910. * @param vrMetrics All the required metrics for the VR camera
  103911. */
  103912. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103913. }
  103914. }
  103915. declare module BABYLON {
  103916. /**
  103917. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103918. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103919. */
  103920. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103921. /**
  103922. * Creates a new VRDeviceOrientationArcRotateCamera
  103923. * @param name defines camera name
  103924. * @param alpha defines the camera rotation along the logitudinal axis
  103925. * @param beta defines the camera rotation along the latitudinal axis
  103926. * @param radius defines the camera distance from its target
  103927. * @param target defines the camera target
  103928. * @param scene defines the scene the camera belongs to
  103929. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103930. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103931. */
  103932. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103933. /**
  103934. * Gets camera class name
  103935. * @returns VRDeviceOrientationArcRotateCamera
  103936. */
  103937. getClassName(): string;
  103938. }
  103939. }
  103940. declare module BABYLON {
  103941. /**
  103942. * Camera used to simulate VR rendering (based on FreeCamera)
  103943. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103944. */
  103945. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103946. /**
  103947. * Creates a new VRDeviceOrientationFreeCamera
  103948. * @param name defines camera name
  103949. * @param position defines the start position of the camera
  103950. * @param scene defines the scene the camera belongs to
  103951. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103952. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103953. */
  103954. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103955. /**
  103956. * Gets camera class name
  103957. * @returns VRDeviceOrientationFreeCamera
  103958. */
  103959. getClassName(): string;
  103960. }
  103961. }
  103962. declare module BABYLON {
  103963. /**
  103964. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103965. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103966. */
  103967. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103968. /**
  103969. * Creates a new VRDeviceOrientationGamepadCamera
  103970. * @param name defines camera name
  103971. * @param position defines the start position of the camera
  103972. * @param scene defines the scene the camera belongs to
  103973. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103974. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103975. */
  103976. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103977. /**
  103978. * Gets camera class name
  103979. * @returns VRDeviceOrientationGamepadCamera
  103980. */
  103981. getClassName(): string;
  103982. }
  103983. }
  103984. declare module BABYLON {
  103985. /**
  103986. * Base class of materials working in push mode in babylon JS
  103987. * @hidden
  103988. */
  103989. export class PushMaterial extends Material {
  103990. protected _activeEffect: Effect;
  103991. protected _normalMatrix: Matrix;
  103992. /**
  103993. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103994. * This means that the material can keep using a previous shader while a new one is being compiled.
  103995. * This is mostly used when shader parallel compilation is supported (true by default)
  103996. */
  103997. allowShaderHotSwapping: boolean;
  103998. constructor(name: string, scene: Scene);
  103999. getEffect(): Effect;
  104000. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104001. /**
  104002. * Binds the given world matrix to the active effect
  104003. *
  104004. * @param world the matrix to bind
  104005. */
  104006. bindOnlyWorldMatrix(world: Matrix): void;
  104007. /**
  104008. * Binds the given normal matrix to the active effect
  104009. *
  104010. * @param normalMatrix the matrix to bind
  104011. */
  104012. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104013. bind(world: Matrix, mesh?: Mesh): void;
  104014. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104015. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104016. }
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * This groups all the flags used to control the materials channel.
  104021. */
  104022. export class MaterialFlags {
  104023. private static _DiffuseTextureEnabled;
  104024. /**
  104025. * Are diffuse textures enabled in the application.
  104026. */
  104027. static DiffuseTextureEnabled: boolean;
  104028. private static _AmbientTextureEnabled;
  104029. /**
  104030. * Are ambient textures enabled in the application.
  104031. */
  104032. static AmbientTextureEnabled: boolean;
  104033. private static _OpacityTextureEnabled;
  104034. /**
  104035. * Are opacity textures enabled in the application.
  104036. */
  104037. static OpacityTextureEnabled: boolean;
  104038. private static _ReflectionTextureEnabled;
  104039. /**
  104040. * Are reflection textures enabled in the application.
  104041. */
  104042. static ReflectionTextureEnabled: boolean;
  104043. private static _EmissiveTextureEnabled;
  104044. /**
  104045. * Are emissive textures enabled in the application.
  104046. */
  104047. static EmissiveTextureEnabled: boolean;
  104048. private static _SpecularTextureEnabled;
  104049. /**
  104050. * Are specular textures enabled in the application.
  104051. */
  104052. static SpecularTextureEnabled: boolean;
  104053. private static _BumpTextureEnabled;
  104054. /**
  104055. * Are bump textures enabled in the application.
  104056. */
  104057. static BumpTextureEnabled: boolean;
  104058. private static _LightmapTextureEnabled;
  104059. /**
  104060. * Are lightmap textures enabled in the application.
  104061. */
  104062. static LightmapTextureEnabled: boolean;
  104063. private static _RefractionTextureEnabled;
  104064. /**
  104065. * Are refraction textures enabled in the application.
  104066. */
  104067. static RefractionTextureEnabled: boolean;
  104068. private static _ColorGradingTextureEnabled;
  104069. /**
  104070. * Are color grading textures enabled in the application.
  104071. */
  104072. static ColorGradingTextureEnabled: boolean;
  104073. private static _FresnelEnabled;
  104074. /**
  104075. * Are fresnels enabled in the application.
  104076. */
  104077. static FresnelEnabled: boolean;
  104078. private static _ClearCoatTextureEnabled;
  104079. /**
  104080. * Are clear coat textures enabled in the application.
  104081. */
  104082. static ClearCoatTextureEnabled: boolean;
  104083. private static _ClearCoatBumpTextureEnabled;
  104084. /**
  104085. * Are clear coat bump textures enabled in the application.
  104086. */
  104087. static ClearCoatBumpTextureEnabled: boolean;
  104088. private static _ClearCoatTintTextureEnabled;
  104089. /**
  104090. * Are clear coat tint textures enabled in the application.
  104091. */
  104092. static ClearCoatTintTextureEnabled: boolean;
  104093. private static _SheenTextureEnabled;
  104094. /**
  104095. * Are sheen textures enabled in the application.
  104096. */
  104097. static SheenTextureEnabled: boolean;
  104098. private static _AnisotropicTextureEnabled;
  104099. /**
  104100. * Are anisotropic textures enabled in the application.
  104101. */
  104102. static AnisotropicTextureEnabled: boolean;
  104103. private static _ThicknessTextureEnabled;
  104104. /**
  104105. * Are thickness textures enabled in the application.
  104106. */
  104107. static ThicknessTextureEnabled: boolean;
  104108. }
  104109. }
  104110. declare module BABYLON {
  104111. /** @hidden */
  104112. export var defaultFragmentDeclaration: {
  104113. name: string;
  104114. shader: string;
  104115. };
  104116. }
  104117. declare module BABYLON {
  104118. /** @hidden */
  104119. export var defaultUboDeclaration: {
  104120. name: string;
  104121. shader: string;
  104122. };
  104123. }
  104124. declare module BABYLON {
  104125. /** @hidden */
  104126. export var lightFragmentDeclaration: {
  104127. name: string;
  104128. shader: string;
  104129. };
  104130. }
  104131. declare module BABYLON {
  104132. /** @hidden */
  104133. export var lightUboDeclaration: {
  104134. name: string;
  104135. shader: string;
  104136. };
  104137. }
  104138. declare module BABYLON {
  104139. /** @hidden */
  104140. export var lightsFragmentFunctions: {
  104141. name: string;
  104142. shader: string;
  104143. };
  104144. }
  104145. declare module BABYLON {
  104146. /** @hidden */
  104147. export var shadowsFragmentFunctions: {
  104148. name: string;
  104149. shader: string;
  104150. };
  104151. }
  104152. declare module BABYLON {
  104153. /** @hidden */
  104154. export var fresnelFunction: {
  104155. name: string;
  104156. shader: string;
  104157. };
  104158. }
  104159. declare module BABYLON {
  104160. /** @hidden */
  104161. export var reflectionFunction: {
  104162. name: string;
  104163. shader: string;
  104164. };
  104165. }
  104166. declare module BABYLON {
  104167. /** @hidden */
  104168. export var bumpFragmentFunctions: {
  104169. name: string;
  104170. shader: string;
  104171. };
  104172. }
  104173. declare module BABYLON {
  104174. /** @hidden */
  104175. export var logDepthDeclaration: {
  104176. name: string;
  104177. shader: string;
  104178. };
  104179. }
  104180. declare module BABYLON {
  104181. /** @hidden */
  104182. export var bumpFragment: {
  104183. name: string;
  104184. shader: string;
  104185. };
  104186. }
  104187. declare module BABYLON {
  104188. /** @hidden */
  104189. export var depthPrePass: {
  104190. name: string;
  104191. shader: string;
  104192. };
  104193. }
  104194. declare module BABYLON {
  104195. /** @hidden */
  104196. export var lightFragment: {
  104197. name: string;
  104198. shader: string;
  104199. };
  104200. }
  104201. declare module BABYLON {
  104202. /** @hidden */
  104203. export var logDepthFragment: {
  104204. name: string;
  104205. shader: string;
  104206. };
  104207. }
  104208. declare module BABYLON {
  104209. /** @hidden */
  104210. export var defaultPixelShader: {
  104211. name: string;
  104212. shader: string;
  104213. };
  104214. }
  104215. declare module BABYLON {
  104216. /** @hidden */
  104217. export var defaultVertexDeclaration: {
  104218. name: string;
  104219. shader: string;
  104220. };
  104221. }
  104222. declare module BABYLON {
  104223. /** @hidden */
  104224. export var bumpVertexDeclaration: {
  104225. name: string;
  104226. shader: string;
  104227. };
  104228. }
  104229. declare module BABYLON {
  104230. /** @hidden */
  104231. export var bumpVertex: {
  104232. name: string;
  104233. shader: string;
  104234. };
  104235. }
  104236. declare module BABYLON {
  104237. /** @hidden */
  104238. export var fogVertex: {
  104239. name: string;
  104240. shader: string;
  104241. };
  104242. }
  104243. declare module BABYLON {
  104244. /** @hidden */
  104245. export var shadowsVertex: {
  104246. name: string;
  104247. shader: string;
  104248. };
  104249. }
  104250. declare module BABYLON {
  104251. /** @hidden */
  104252. export var pointCloudVertex: {
  104253. name: string;
  104254. shader: string;
  104255. };
  104256. }
  104257. declare module BABYLON {
  104258. /** @hidden */
  104259. export var logDepthVertex: {
  104260. name: string;
  104261. shader: string;
  104262. };
  104263. }
  104264. declare module BABYLON {
  104265. /** @hidden */
  104266. export var defaultVertexShader: {
  104267. name: string;
  104268. shader: string;
  104269. };
  104270. }
  104271. declare module BABYLON {
  104272. /** @hidden */
  104273. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104274. MAINUV1: boolean;
  104275. MAINUV2: boolean;
  104276. DIFFUSE: boolean;
  104277. DIFFUSEDIRECTUV: number;
  104278. AMBIENT: boolean;
  104279. AMBIENTDIRECTUV: number;
  104280. OPACITY: boolean;
  104281. OPACITYDIRECTUV: number;
  104282. OPACITYRGB: boolean;
  104283. REFLECTION: boolean;
  104284. EMISSIVE: boolean;
  104285. EMISSIVEDIRECTUV: number;
  104286. SPECULAR: boolean;
  104287. SPECULARDIRECTUV: number;
  104288. BUMP: boolean;
  104289. BUMPDIRECTUV: number;
  104290. PARALLAX: boolean;
  104291. PARALLAXOCCLUSION: boolean;
  104292. SPECULAROVERALPHA: boolean;
  104293. CLIPPLANE: boolean;
  104294. CLIPPLANE2: boolean;
  104295. CLIPPLANE3: boolean;
  104296. CLIPPLANE4: boolean;
  104297. ALPHATEST: boolean;
  104298. DEPTHPREPASS: boolean;
  104299. ALPHAFROMDIFFUSE: boolean;
  104300. POINTSIZE: boolean;
  104301. FOG: boolean;
  104302. SPECULARTERM: boolean;
  104303. DIFFUSEFRESNEL: boolean;
  104304. OPACITYFRESNEL: boolean;
  104305. REFLECTIONFRESNEL: boolean;
  104306. REFRACTIONFRESNEL: boolean;
  104307. EMISSIVEFRESNEL: boolean;
  104308. FRESNEL: boolean;
  104309. NORMAL: boolean;
  104310. UV1: boolean;
  104311. UV2: boolean;
  104312. VERTEXCOLOR: boolean;
  104313. VERTEXALPHA: boolean;
  104314. NUM_BONE_INFLUENCERS: number;
  104315. BonesPerMesh: number;
  104316. BONETEXTURE: boolean;
  104317. INSTANCES: boolean;
  104318. GLOSSINESS: boolean;
  104319. ROUGHNESS: boolean;
  104320. EMISSIVEASILLUMINATION: boolean;
  104321. LINKEMISSIVEWITHDIFFUSE: boolean;
  104322. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104323. LIGHTMAP: boolean;
  104324. LIGHTMAPDIRECTUV: number;
  104325. OBJECTSPACE_NORMALMAP: boolean;
  104326. USELIGHTMAPASSHADOWMAP: boolean;
  104327. REFLECTIONMAP_3D: boolean;
  104328. REFLECTIONMAP_SPHERICAL: boolean;
  104329. REFLECTIONMAP_PLANAR: boolean;
  104330. REFLECTIONMAP_CUBIC: boolean;
  104331. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104332. REFLECTIONMAP_PROJECTION: boolean;
  104333. REFLECTIONMAP_SKYBOX: boolean;
  104334. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104335. REFLECTIONMAP_EXPLICIT: boolean;
  104336. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104337. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104338. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104339. INVERTCUBICMAP: boolean;
  104340. LOGARITHMICDEPTH: boolean;
  104341. REFRACTION: boolean;
  104342. REFRACTIONMAP_3D: boolean;
  104343. REFLECTIONOVERALPHA: boolean;
  104344. TWOSIDEDLIGHTING: boolean;
  104345. SHADOWFLOAT: boolean;
  104346. MORPHTARGETS: boolean;
  104347. MORPHTARGETS_NORMAL: boolean;
  104348. MORPHTARGETS_TANGENT: boolean;
  104349. MORPHTARGETS_UV: boolean;
  104350. NUM_MORPH_INFLUENCERS: number;
  104351. NONUNIFORMSCALING: boolean;
  104352. PREMULTIPLYALPHA: boolean;
  104353. IMAGEPROCESSING: boolean;
  104354. VIGNETTE: boolean;
  104355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104356. VIGNETTEBLENDMODEOPAQUE: boolean;
  104357. TONEMAPPING: boolean;
  104358. TONEMAPPING_ACES: boolean;
  104359. CONTRAST: boolean;
  104360. COLORCURVES: boolean;
  104361. COLORGRADING: boolean;
  104362. COLORGRADING3D: boolean;
  104363. SAMPLER3DGREENDEPTH: boolean;
  104364. SAMPLER3DBGRMAP: boolean;
  104365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104366. MULTIVIEW: boolean;
  104367. /**
  104368. * If the reflection texture on this material is in linear color space
  104369. * @hidden
  104370. */
  104371. IS_REFLECTION_LINEAR: boolean;
  104372. /**
  104373. * If the refraction texture on this material is in linear color space
  104374. * @hidden
  104375. */
  104376. IS_REFRACTION_LINEAR: boolean;
  104377. EXPOSURE: boolean;
  104378. constructor();
  104379. setReflectionMode(modeToEnable: string): void;
  104380. }
  104381. /**
  104382. * This is the default material used in Babylon. It is the best trade off between quality
  104383. * and performances.
  104384. * @see http://doc.babylonjs.com/babylon101/materials
  104385. */
  104386. export class StandardMaterial extends PushMaterial {
  104387. private _diffuseTexture;
  104388. /**
  104389. * The basic texture of the material as viewed under a light.
  104390. */
  104391. diffuseTexture: Nullable<BaseTexture>;
  104392. private _ambientTexture;
  104393. /**
  104394. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104395. */
  104396. ambientTexture: Nullable<BaseTexture>;
  104397. private _opacityTexture;
  104398. /**
  104399. * Define the transparency of the material from a texture.
  104400. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104401. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104402. */
  104403. opacityTexture: Nullable<BaseTexture>;
  104404. private _reflectionTexture;
  104405. /**
  104406. * Define the texture used to display the reflection.
  104407. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104408. */
  104409. reflectionTexture: Nullable<BaseTexture>;
  104410. private _emissiveTexture;
  104411. /**
  104412. * Define texture of the material as if self lit.
  104413. * This will be mixed in the final result even in the absence of light.
  104414. */
  104415. emissiveTexture: Nullable<BaseTexture>;
  104416. private _specularTexture;
  104417. /**
  104418. * Define how the color and intensity of the highlight given by the light in the material.
  104419. */
  104420. specularTexture: Nullable<BaseTexture>;
  104421. private _bumpTexture;
  104422. /**
  104423. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104424. * 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.
  104425. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104426. */
  104427. bumpTexture: Nullable<BaseTexture>;
  104428. private _lightmapTexture;
  104429. /**
  104430. * Complex lighting can be computationally expensive to compute at runtime.
  104431. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104432. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104433. */
  104434. lightmapTexture: Nullable<BaseTexture>;
  104435. private _refractionTexture;
  104436. /**
  104437. * Define the texture used to display the refraction.
  104438. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104439. */
  104440. refractionTexture: Nullable<BaseTexture>;
  104441. /**
  104442. * The color of the material lit by the environmental background lighting.
  104443. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104444. */
  104445. ambientColor: Color3;
  104446. /**
  104447. * The basic color of the material as viewed under a light.
  104448. */
  104449. diffuseColor: Color3;
  104450. /**
  104451. * Define how the color and intensity of the highlight given by the light in the material.
  104452. */
  104453. specularColor: Color3;
  104454. /**
  104455. * Define the color of the material as if self lit.
  104456. * This will be mixed in the final result even in the absence of light.
  104457. */
  104458. emissiveColor: Color3;
  104459. /**
  104460. * Defines how sharp are the highlights in the material.
  104461. * The bigger the value the sharper giving a more glossy feeling to the result.
  104462. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104463. */
  104464. specularPower: number;
  104465. private _useAlphaFromDiffuseTexture;
  104466. /**
  104467. * Does the transparency come from the diffuse texture alpha channel.
  104468. */
  104469. useAlphaFromDiffuseTexture: boolean;
  104470. private _useEmissiveAsIllumination;
  104471. /**
  104472. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104473. */
  104474. useEmissiveAsIllumination: boolean;
  104475. private _linkEmissiveWithDiffuse;
  104476. /**
  104477. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104478. * the emissive level when the final color is close to one.
  104479. */
  104480. linkEmissiveWithDiffuse: boolean;
  104481. private _useSpecularOverAlpha;
  104482. /**
  104483. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104484. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104485. */
  104486. useSpecularOverAlpha: boolean;
  104487. private _useReflectionOverAlpha;
  104488. /**
  104489. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104490. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104491. */
  104492. useReflectionOverAlpha: boolean;
  104493. private _disableLighting;
  104494. /**
  104495. * Does lights from the scene impacts this material.
  104496. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104497. */
  104498. disableLighting: boolean;
  104499. private _useObjectSpaceNormalMap;
  104500. /**
  104501. * Allows using an object space normal map (instead of tangent space).
  104502. */
  104503. useObjectSpaceNormalMap: boolean;
  104504. private _useParallax;
  104505. /**
  104506. * Is parallax enabled or not.
  104507. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104508. */
  104509. useParallax: boolean;
  104510. private _useParallaxOcclusion;
  104511. /**
  104512. * Is parallax occlusion enabled or not.
  104513. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104514. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104515. */
  104516. useParallaxOcclusion: boolean;
  104517. /**
  104518. * 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.
  104519. */
  104520. parallaxScaleBias: number;
  104521. private _roughness;
  104522. /**
  104523. * Helps to define how blurry the reflections should appears in the material.
  104524. */
  104525. roughness: number;
  104526. /**
  104527. * In case of refraction, define the value of the index of refraction.
  104528. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104529. */
  104530. indexOfRefraction: number;
  104531. /**
  104532. * Invert the refraction texture alongside the y axis.
  104533. * It can be useful with procedural textures or probe for instance.
  104534. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104535. */
  104536. invertRefractionY: boolean;
  104537. /**
  104538. * Defines the alpha limits in alpha test mode.
  104539. */
  104540. alphaCutOff: number;
  104541. private _useLightmapAsShadowmap;
  104542. /**
  104543. * In case of light mapping, define whether the map contains light or shadow informations.
  104544. */
  104545. useLightmapAsShadowmap: boolean;
  104546. private _diffuseFresnelParameters;
  104547. /**
  104548. * Define the diffuse fresnel parameters of the material.
  104549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104550. */
  104551. diffuseFresnelParameters: FresnelParameters;
  104552. private _opacityFresnelParameters;
  104553. /**
  104554. * Define the opacity fresnel parameters of the material.
  104555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104556. */
  104557. opacityFresnelParameters: FresnelParameters;
  104558. private _reflectionFresnelParameters;
  104559. /**
  104560. * Define the reflection fresnel parameters of the material.
  104561. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104562. */
  104563. reflectionFresnelParameters: FresnelParameters;
  104564. private _refractionFresnelParameters;
  104565. /**
  104566. * Define the refraction fresnel parameters of the material.
  104567. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104568. */
  104569. refractionFresnelParameters: FresnelParameters;
  104570. private _emissiveFresnelParameters;
  104571. /**
  104572. * Define the emissive fresnel parameters of the material.
  104573. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104574. */
  104575. emissiveFresnelParameters: FresnelParameters;
  104576. private _useReflectionFresnelFromSpecular;
  104577. /**
  104578. * If true automatically deducts the fresnels values from the material specularity.
  104579. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104580. */
  104581. useReflectionFresnelFromSpecular: boolean;
  104582. private _useGlossinessFromSpecularMapAlpha;
  104583. /**
  104584. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104585. */
  104586. useGlossinessFromSpecularMapAlpha: boolean;
  104587. private _maxSimultaneousLights;
  104588. /**
  104589. * Defines the maximum number of lights that can be used in the material
  104590. */
  104591. maxSimultaneousLights: number;
  104592. private _invertNormalMapX;
  104593. /**
  104594. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104595. */
  104596. invertNormalMapX: boolean;
  104597. private _invertNormalMapY;
  104598. /**
  104599. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104600. */
  104601. invertNormalMapY: boolean;
  104602. private _twoSidedLighting;
  104603. /**
  104604. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104605. */
  104606. twoSidedLighting: boolean;
  104607. /**
  104608. * Default configuration related to image processing available in the standard Material.
  104609. */
  104610. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104611. /**
  104612. * Gets the image processing configuration used either in this material.
  104613. */
  104614. /**
  104615. * Sets the Default image processing configuration used either in the this material.
  104616. *
  104617. * If sets to null, the scene one is in use.
  104618. */
  104619. imageProcessingConfiguration: ImageProcessingConfiguration;
  104620. /**
  104621. * Keep track of the image processing observer to allow dispose and replace.
  104622. */
  104623. private _imageProcessingObserver;
  104624. /**
  104625. * Attaches a new image processing configuration to the Standard Material.
  104626. * @param configuration
  104627. */
  104628. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104629. /**
  104630. * Gets wether the color curves effect is enabled.
  104631. */
  104632. /**
  104633. * Sets wether the color curves effect is enabled.
  104634. */
  104635. cameraColorCurvesEnabled: boolean;
  104636. /**
  104637. * Gets wether the color grading effect is enabled.
  104638. */
  104639. /**
  104640. * Gets wether the color grading effect is enabled.
  104641. */
  104642. cameraColorGradingEnabled: boolean;
  104643. /**
  104644. * Gets wether tonemapping is enabled or not.
  104645. */
  104646. /**
  104647. * Sets wether tonemapping is enabled or not
  104648. */
  104649. cameraToneMappingEnabled: boolean;
  104650. /**
  104651. * The camera exposure used on this material.
  104652. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104653. * This corresponds to a photographic exposure.
  104654. */
  104655. /**
  104656. * The camera exposure used on this material.
  104657. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104658. * This corresponds to a photographic exposure.
  104659. */
  104660. cameraExposure: number;
  104661. /**
  104662. * Gets The camera contrast used on this material.
  104663. */
  104664. /**
  104665. * Sets The camera contrast used on this material.
  104666. */
  104667. cameraContrast: number;
  104668. /**
  104669. * Gets the Color Grading 2D Lookup Texture.
  104670. */
  104671. /**
  104672. * Sets the Color Grading 2D Lookup Texture.
  104673. */
  104674. cameraColorGradingTexture: Nullable<BaseTexture>;
  104675. /**
  104676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104678. * 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;
  104679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104680. */
  104681. /**
  104682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104684. * 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;
  104685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104686. */
  104687. cameraColorCurves: Nullable<ColorCurves>;
  104688. /**
  104689. * Custom callback helping to override the default shader used in the material.
  104690. */
  104691. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104692. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104693. protected _worldViewProjectionMatrix: Matrix;
  104694. protected _globalAmbientColor: Color3;
  104695. protected _useLogarithmicDepth: boolean;
  104696. /**
  104697. * Instantiates a new standard material.
  104698. * This is the default material used in Babylon. It is the best trade off between quality
  104699. * and performances.
  104700. * @see http://doc.babylonjs.com/babylon101/materials
  104701. * @param name Define the name of the material in the scene
  104702. * @param scene Define the scene the material belong to
  104703. */
  104704. constructor(name: string, scene: Scene);
  104705. /**
  104706. * Gets a boolean indicating that current material needs to register RTT
  104707. */
  104708. readonly hasRenderTargetTextures: boolean;
  104709. /**
  104710. * Gets the current class name of the material e.g. "StandardMaterial"
  104711. * Mainly use in serialization.
  104712. * @returns the class name
  104713. */
  104714. getClassName(): string;
  104715. /**
  104716. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104717. * You can try switching to logarithmic depth.
  104718. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104719. */
  104720. useLogarithmicDepth: boolean;
  104721. /**
  104722. * Specifies if the material will require alpha blending
  104723. * @returns a boolean specifying if alpha blending is needed
  104724. */
  104725. needAlphaBlending(): boolean;
  104726. /**
  104727. * Specifies if this material should be rendered in alpha test mode
  104728. * @returns a boolean specifying if an alpha test is needed.
  104729. */
  104730. needAlphaTesting(): boolean;
  104731. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104732. /**
  104733. * Get the texture used for alpha test purpose.
  104734. * @returns the diffuse texture in case of the standard material.
  104735. */
  104736. getAlphaTestTexture(): Nullable<BaseTexture>;
  104737. /**
  104738. * Get if the submesh is ready to be used and all its information available.
  104739. * Child classes can use it to update shaders
  104740. * @param mesh defines the mesh to check
  104741. * @param subMesh defines which submesh to check
  104742. * @param useInstances specifies that instances should be used
  104743. * @returns a boolean indicating that the submesh is ready or not
  104744. */
  104745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104746. /**
  104747. * Builds the material UBO layouts.
  104748. * Used internally during the effect preparation.
  104749. */
  104750. buildUniformLayout(): void;
  104751. /**
  104752. * Unbinds the material from the mesh
  104753. */
  104754. unbind(): void;
  104755. /**
  104756. * Binds the submesh to this material by preparing the effect and shader to draw
  104757. * @param world defines the world transformation matrix
  104758. * @param mesh defines the mesh containing the submesh
  104759. * @param subMesh defines the submesh to bind the material to
  104760. */
  104761. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104762. /**
  104763. * Get the list of animatables in the material.
  104764. * @returns the list of animatables object used in the material
  104765. */
  104766. getAnimatables(): IAnimatable[];
  104767. /**
  104768. * Gets the active textures from the material
  104769. * @returns an array of textures
  104770. */
  104771. getActiveTextures(): BaseTexture[];
  104772. /**
  104773. * Specifies if the material uses a texture
  104774. * @param texture defines the texture to check against the material
  104775. * @returns a boolean specifying if the material uses the texture
  104776. */
  104777. hasTexture(texture: BaseTexture): boolean;
  104778. /**
  104779. * Disposes the material
  104780. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104781. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104782. */
  104783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104784. /**
  104785. * Makes a duplicate of the material, and gives it a new name
  104786. * @param name defines the new name for the duplicated material
  104787. * @returns the cloned material
  104788. */
  104789. clone(name: string): StandardMaterial;
  104790. /**
  104791. * Serializes this material in a JSON representation
  104792. * @returns the serialized material object
  104793. */
  104794. serialize(): any;
  104795. /**
  104796. * Creates a standard material from parsed material data
  104797. * @param source defines the JSON representation of the material
  104798. * @param scene defines the hosting scene
  104799. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104800. * @returns a new standard material
  104801. */
  104802. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104803. /**
  104804. * Are diffuse textures enabled in the application.
  104805. */
  104806. static DiffuseTextureEnabled: boolean;
  104807. /**
  104808. * Are ambient textures enabled in the application.
  104809. */
  104810. static AmbientTextureEnabled: boolean;
  104811. /**
  104812. * Are opacity textures enabled in the application.
  104813. */
  104814. static OpacityTextureEnabled: boolean;
  104815. /**
  104816. * Are reflection textures enabled in the application.
  104817. */
  104818. static ReflectionTextureEnabled: boolean;
  104819. /**
  104820. * Are emissive textures enabled in the application.
  104821. */
  104822. static EmissiveTextureEnabled: boolean;
  104823. /**
  104824. * Are specular textures enabled in the application.
  104825. */
  104826. static SpecularTextureEnabled: boolean;
  104827. /**
  104828. * Are bump textures enabled in the application.
  104829. */
  104830. static BumpTextureEnabled: boolean;
  104831. /**
  104832. * Are lightmap textures enabled in the application.
  104833. */
  104834. static LightmapTextureEnabled: boolean;
  104835. /**
  104836. * Are refraction textures enabled in the application.
  104837. */
  104838. static RefractionTextureEnabled: boolean;
  104839. /**
  104840. * Are color grading textures enabled in the application.
  104841. */
  104842. static ColorGradingTextureEnabled: boolean;
  104843. /**
  104844. * Are fresnels enabled in the application.
  104845. */
  104846. static FresnelEnabled: boolean;
  104847. }
  104848. }
  104849. declare module BABYLON {
  104850. /**
  104851. * A class extending Texture allowing drawing on a texture
  104852. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104853. */
  104854. export class DynamicTexture extends Texture {
  104855. private _generateMipMaps;
  104856. private _canvas;
  104857. private _context;
  104858. private _engine;
  104859. /**
  104860. * Creates a DynamicTexture
  104861. * @param name defines the name of the texture
  104862. * @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
  104863. * @param scene defines the scene where you want the texture
  104864. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104865. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104866. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104867. */
  104868. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104869. /**
  104870. * Get the current class name of the texture useful for serialization or dynamic coding.
  104871. * @returns "DynamicTexture"
  104872. */
  104873. getClassName(): string;
  104874. /**
  104875. * Gets the current state of canRescale
  104876. */
  104877. readonly canRescale: boolean;
  104878. private _recreate;
  104879. /**
  104880. * Scales the texture
  104881. * @param ratio the scale factor to apply to both width and height
  104882. */
  104883. scale(ratio: number): void;
  104884. /**
  104885. * Resizes the texture
  104886. * @param width the new width
  104887. * @param height the new height
  104888. */
  104889. scaleTo(width: number, height: number): void;
  104890. /**
  104891. * Gets the context of the canvas used by the texture
  104892. * @returns the canvas context of the dynamic texture
  104893. */
  104894. getContext(): CanvasRenderingContext2D;
  104895. /**
  104896. * Clears the texture
  104897. */
  104898. clear(): void;
  104899. /**
  104900. * Updates the texture
  104901. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104902. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104903. */
  104904. update(invertY?: boolean, premulAlpha?: boolean): void;
  104905. /**
  104906. * Draws text onto the texture
  104907. * @param text defines the text to be drawn
  104908. * @param x defines the placement of the text from the left
  104909. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104910. * @param font defines the font to be used with font-style, font-size, font-name
  104911. * @param color defines the color used for the text
  104912. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104913. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104914. * @param update defines whether texture is immediately update (default is true)
  104915. */
  104916. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104917. /**
  104918. * Clones the texture
  104919. * @returns the clone of the texture.
  104920. */
  104921. clone(): DynamicTexture;
  104922. /**
  104923. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104924. * @returns a serialized dynamic texture object
  104925. */
  104926. serialize(): any;
  104927. /** @hidden */
  104928. _rebuild(): void;
  104929. }
  104930. }
  104931. declare module BABYLON {
  104932. /** @hidden */
  104933. export var imageProcessingPixelShader: {
  104934. name: string;
  104935. shader: string;
  104936. };
  104937. }
  104938. declare module BABYLON {
  104939. /**
  104940. * ImageProcessingPostProcess
  104941. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104942. */
  104943. export class ImageProcessingPostProcess extends PostProcess {
  104944. /**
  104945. * Default configuration related to image processing available in the PBR Material.
  104946. */
  104947. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104948. /**
  104949. * Gets the image processing configuration used either in this material.
  104950. */
  104951. /**
  104952. * Sets the Default image processing configuration used either in the this material.
  104953. *
  104954. * If sets to null, the scene one is in use.
  104955. */
  104956. imageProcessingConfiguration: ImageProcessingConfiguration;
  104957. /**
  104958. * Keep track of the image processing observer to allow dispose and replace.
  104959. */
  104960. private _imageProcessingObserver;
  104961. /**
  104962. * Attaches a new image processing configuration to the PBR Material.
  104963. * @param configuration
  104964. */
  104965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104966. /**
  104967. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104968. */
  104969. /**
  104970. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104971. */
  104972. colorCurves: Nullable<ColorCurves>;
  104973. /**
  104974. * Gets wether the color curves effect is enabled.
  104975. */
  104976. /**
  104977. * Sets wether the color curves effect is enabled.
  104978. */
  104979. colorCurvesEnabled: boolean;
  104980. /**
  104981. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104982. */
  104983. /**
  104984. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104985. */
  104986. colorGradingTexture: Nullable<BaseTexture>;
  104987. /**
  104988. * Gets wether the color grading effect is enabled.
  104989. */
  104990. /**
  104991. * Gets wether the color grading effect is enabled.
  104992. */
  104993. colorGradingEnabled: boolean;
  104994. /**
  104995. * Gets exposure used in the effect.
  104996. */
  104997. /**
  104998. * Sets exposure used in the effect.
  104999. */
  105000. exposure: number;
  105001. /**
  105002. * Gets wether tonemapping is enabled or not.
  105003. */
  105004. /**
  105005. * Sets wether tonemapping is enabled or not
  105006. */
  105007. toneMappingEnabled: boolean;
  105008. /**
  105009. * Gets the type of tone mapping effect.
  105010. */
  105011. /**
  105012. * Sets the type of tone mapping effect.
  105013. */
  105014. toneMappingType: number;
  105015. /**
  105016. * Gets contrast used in the effect.
  105017. */
  105018. /**
  105019. * Sets contrast used in the effect.
  105020. */
  105021. contrast: number;
  105022. /**
  105023. * Gets Vignette stretch size.
  105024. */
  105025. /**
  105026. * Sets Vignette stretch size.
  105027. */
  105028. vignetteStretch: number;
  105029. /**
  105030. * Gets Vignette centre X Offset.
  105031. */
  105032. /**
  105033. * Sets Vignette centre X Offset.
  105034. */
  105035. vignetteCentreX: number;
  105036. /**
  105037. * Gets Vignette centre Y Offset.
  105038. */
  105039. /**
  105040. * Sets Vignette centre Y Offset.
  105041. */
  105042. vignetteCentreY: number;
  105043. /**
  105044. * Gets Vignette weight or intensity of the vignette effect.
  105045. */
  105046. /**
  105047. * Sets Vignette weight or intensity of the vignette effect.
  105048. */
  105049. vignetteWeight: number;
  105050. /**
  105051. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105052. * if vignetteEnabled is set to true.
  105053. */
  105054. /**
  105055. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105056. * if vignetteEnabled is set to true.
  105057. */
  105058. vignetteColor: Color4;
  105059. /**
  105060. * Gets Camera field of view used by the Vignette effect.
  105061. */
  105062. /**
  105063. * Sets Camera field of view used by the Vignette effect.
  105064. */
  105065. vignetteCameraFov: number;
  105066. /**
  105067. * Gets the vignette blend mode allowing different kind of effect.
  105068. */
  105069. /**
  105070. * Sets the vignette blend mode allowing different kind of effect.
  105071. */
  105072. vignetteBlendMode: number;
  105073. /**
  105074. * Gets wether the vignette effect is enabled.
  105075. */
  105076. /**
  105077. * Sets wether the vignette effect is enabled.
  105078. */
  105079. vignetteEnabled: boolean;
  105080. private _fromLinearSpace;
  105081. /**
  105082. * Gets wether the input of the processing is in Gamma or Linear Space.
  105083. */
  105084. /**
  105085. * Sets wether the input of the processing is in Gamma or Linear Space.
  105086. */
  105087. fromLinearSpace: boolean;
  105088. /**
  105089. * Defines cache preventing GC.
  105090. */
  105091. private _defines;
  105092. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105093. /**
  105094. * "ImageProcessingPostProcess"
  105095. * @returns "ImageProcessingPostProcess"
  105096. */
  105097. getClassName(): string;
  105098. protected _updateParameters(): void;
  105099. dispose(camera?: Camera): void;
  105100. }
  105101. }
  105102. declare module BABYLON {
  105103. /**
  105104. * Class containing static functions to help procedurally build meshes
  105105. */
  105106. export class GroundBuilder {
  105107. /**
  105108. * Creates a ground mesh
  105109. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105110. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105112. * @param name defines the name of the mesh
  105113. * @param options defines the options used to create the mesh
  105114. * @param scene defines the hosting scene
  105115. * @returns the ground mesh
  105116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105117. */
  105118. static CreateGround(name: string, options: {
  105119. width?: number;
  105120. height?: number;
  105121. subdivisions?: number;
  105122. subdivisionsX?: number;
  105123. subdivisionsY?: number;
  105124. updatable?: boolean;
  105125. }, scene: any): Mesh;
  105126. /**
  105127. * Creates a tiled ground mesh
  105128. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105129. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105130. * * 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
  105131. * * 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
  105132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105133. * @param name defines the name of the mesh
  105134. * @param options defines the options used to create the mesh
  105135. * @param scene defines the hosting scene
  105136. * @returns the tiled ground mesh
  105137. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105138. */
  105139. static CreateTiledGround(name: string, options: {
  105140. xmin: number;
  105141. zmin: number;
  105142. xmax: number;
  105143. zmax: number;
  105144. subdivisions?: {
  105145. w: number;
  105146. h: number;
  105147. };
  105148. precision?: {
  105149. w: number;
  105150. h: number;
  105151. };
  105152. updatable?: boolean;
  105153. }, scene?: Nullable<Scene>): Mesh;
  105154. /**
  105155. * Creates a ground mesh from a height map
  105156. * * The parameter `url` sets the URL of the height map image resource.
  105157. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105158. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105159. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105160. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105161. * * 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.
  105162. * * 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).
  105163. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105165. * @param name defines the name of the mesh
  105166. * @param url defines the url to the height map
  105167. * @param options defines the options used to create the mesh
  105168. * @param scene defines the hosting scene
  105169. * @returns the ground mesh
  105170. * @see https://doc.babylonjs.com/babylon101/height_map
  105171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105172. */
  105173. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105174. width?: number;
  105175. height?: number;
  105176. subdivisions?: number;
  105177. minHeight?: number;
  105178. maxHeight?: number;
  105179. colorFilter?: Color3;
  105180. alphaFilter?: number;
  105181. updatable?: boolean;
  105182. onReady?: (mesh: GroundMesh) => void;
  105183. }, scene?: Nullable<Scene>): GroundMesh;
  105184. }
  105185. }
  105186. declare module BABYLON {
  105187. /**
  105188. * Class containing static functions to help procedurally build meshes
  105189. */
  105190. export class TorusBuilder {
  105191. /**
  105192. * Creates a torus mesh
  105193. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105194. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105195. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105199. * @param name defines the name of the mesh
  105200. * @param options defines the options used to create the mesh
  105201. * @param scene defines the hosting scene
  105202. * @returns the torus mesh
  105203. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105204. */
  105205. static CreateTorus(name: string, options: {
  105206. diameter?: number;
  105207. thickness?: number;
  105208. tessellation?: number;
  105209. updatable?: boolean;
  105210. sideOrientation?: number;
  105211. frontUVs?: Vector4;
  105212. backUVs?: Vector4;
  105213. }, scene: any): Mesh;
  105214. }
  105215. }
  105216. declare module BABYLON {
  105217. /**
  105218. * Class containing static functions to help procedurally build meshes
  105219. */
  105220. export class CylinderBuilder {
  105221. /**
  105222. * Creates a cylinder or a cone mesh
  105223. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105224. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105225. * * 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.
  105226. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105227. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105228. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105229. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105230. * * 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).
  105231. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105232. * * 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).
  105233. * * 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
  105234. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105235. * * 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
  105236. * * 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.
  105237. * * If `enclose` is false, a ring surface is one element.
  105238. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105239. * * 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
  105240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105243. * @param name defines the name of the mesh
  105244. * @param options defines the options used to create the mesh
  105245. * @param scene defines the hosting scene
  105246. * @returns the cylinder mesh
  105247. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105248. */
  105249. static CreateCylinder(name: string, options: {
  105250. height?: number;
  105251. diameterTop?: number;
  105252. diameterBottom?: number;
  105253. diameter?: number;
  105254. tessellation?: number;
  105255. subdivisions?: number;
  105256. arc?: number;
  105257. faceColors?: Color4[];
  105258. faceUV?: Vector4[];
  105259. updatable?: boolean;
  105260. hasRings?: boolean;
  105261. enclose?: boolean;
  105262. cap?: number;
  105263. sideOrientation?: number;
  105264. frontUVs?: Vector4;
  105265. backUVs?: Vector4;
  105266. }, scene: any): Mesh;
  105267. }
  105268. }
  105269. declare module BABYLON {
  105270. /**
  105271. * Options to modify the vr teleportation behavior.
  105272. */
  105273. export interface VRTeleportationOptions {
  105274. /**
  105275. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105276. */
  105277. floorMeshName?: string;
  105278. /**
  105279. * A list of meshes to be used as the teleportation floor. (default: empty)
  105280. */
  105281. floorMeshes?: Mesh[];
  105282. }
  105283. /**
  105284. * Options to modify the vr experience helper's behavior.
  105285. */
  105286. export interface VRExperienceHelperOptions extends WebVROptions {
  105287. /**
  105288. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105289. */
  105290. createDeviceOrientationCamera?: boolean;
  105291. /**
  105292. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105293. */
  105294. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105295. /**
  105296. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105297. */
  105298. laserToggle?: boolean;
  105299. /**
  105300. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105301. */
  105302. floorMeshes?: Mesh[];
  105303. /**
  105304. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105305. */
  105306. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105307. }
  105308. /**
  105309. * Event containing information after VR has been entered
  105310. */
  105311. export class OnAfterEnteringVRObservableEvent {
  105312. /**
  105313. * If entering vr was successful
  105314. */
  105315. success: boolean;
  105316. }
  105317. /**
  105318. * Helps to quickly add VR support to an existing scene.
  105319. * See http://doc.babylonjs.com/how_to/webvr_helper
  105320. */
  105321. export class VRExperienceHelper {
  105322. /** Options to modify the vr experience helper's behavior. */
  105323. webVROptions: VRExperienceHelperOptions;
  105324. private _scene;
  105325. private _position;
  105326. private _btnVR;
  105327. private _btnVRDisplayed;
  105328. private _webVRsupported;
  105329. private _webVRready;
  105330. private _webVRrequesting;
  105331. private _webVRpresenting;
  105332. private _hasEnteredVR;
  105333. private _fullscreenVRpresenting;
  105334. private _canvas;
  105335. private _webVRCamera;
  105336. private _vrDeviceOrientationCamera;
  105337. private _deviceOrientationCamera;
  105338. private _existingCamera;
  105339. private _onKeyDown;
  105340. private _onVrDisplayPresentChange;
  105341. private _onVRDisplayChanged;
  105342. private _onVRRequestPresentStart;
  105343. private _onVRRequestPresentComplete;
  105344. /**
  105345. * 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)
  105346. */
  105347. enableGazeEvenWhenNoPointerLock: boolean;
  105348. /**
  105349. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105350. */
  105351. exitVROnDoubleTap: boolean;
  105352. /**
  105353. * Observable raised right before entering VR.
  105354. */
  105355. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105356. /**
  105357. * Observable raised when entering VR has completed.
  105358. */
  105359. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105360. /**
  105361. * Observable raised when exiting VR.
  105362. */
  105363. onExitingVRObservable: Observable<VRExperienceHelper>;
  105364. /**
  105365. * Observable raised when controller mesh is loaded.
  105366. */
  105367. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105368. /** Return this.onEnteringVRObservable
  105369. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105370. */
  105371. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105372. /** Return this.onExitingVRObservable
  105373. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105374. */
  105375. readonly onExitingVR: Observable<VRExperienceHelper>;
  105376. /** Return this.onControllerMeshLoadedObservable
  105377. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105378. */
  105379. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105380. private _rayLength;
  105381. private _useCustomVRButton;
  105382. private _teleportationRequested;
  105383. private _teleportActive;
  105384. private _floorMeshName;
  105385. private _floorMeshesCollection;
  105386. private _rotationAllowed;
  105387. private _teleportBackwardsVector;
  105388. private _teleportationTarget;
  105389. private _isDefaultTeleportationTarget;
  105390. private _postProcessMove;
  105391. private _teleportationFillColor;
  105392. private _teleportationBorderColor;
  105393. private _rotationAngle;
  105394. private _haloCenter;
  105395. private _cameraGazer;
  105396. private _padSensibilityUp;
  105397. private _padSensibilityDown;
  105398. private _leftController;
  105399. private _rightController;
  105400. /**
  105401. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105402. */
  105403. onNewMeshSelected: Observable<AbstractMesh>;
  105404. /**
  105405. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105406. */
  105407. onNewMeshPicked: Observable<PickingInfo>;
  105408. private _circleEase;
  105409. /**
  105410. * Observable raised before camera teleportation
  105411. */
  105412. onBeforeCameraTeleport: Observable<Vector3>;
  105413. /**
  105414. * Observable raised after camera teleportation
  105415. */
  105416. onAfterCameraTeleport: Observable<Vector3>;
  105417. /**
  105418. * Observable raised when current selected mesh gets unselected
  105419. */
  105420. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105421. private _raySelectionPredicate;
  105422. /**
  105423. * To be optionaly changed by user to define custom ray selection
  105424. */
  105425. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105426. /**
  105427. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105428. */
  105429. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105430. /**
  105431. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105432. */
  105433. teleportationEnabled: boolean;
  105434. private _defaultHeight;
  105435. private _teleportationInitialized;
  105436. private _interactionsEnabled;
  105437. private _interactionsRequested;
  105438. private _displayGaze;
  105439. private _displayLaserPointer;
  105440. /**
  105441. * The mesh used to display where the user is going to teleport.
  105442. */
  105443. /**
  105444. * Sets the mesh to be used to display where the user is going to teleport.
  105445. */
  105446. teleportationTarget: Mesh;
  105447. /**
  105448. * 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
  105449. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105450. * See http://doc.babylonjs.com/resources/baking_transformations
  105451. */
  105452. gazeTrackerMesh: Mesh;
  105453. /**
  105454. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105455. */
  105456. updateGazeTrackerScale: boolean;
  105457. /**
  105458. * If the gaze trackers color should be updated when selecting meshes
  105459. */
  105460. updateGazeTrackerColor: boolean;
  105461. /**
  105462. * The gaze tracking mesh corresponding to the left controller
  105463. */
  105464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105465. /**
  105466. * The gaze tracking mesh corresponding to the right controller
  105467. */
  105468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105469. /**
  105470. * If the ray of the gaze should be displayed.
  105471. */
  105472. /**
  105473. * Sets if the ray of the gaze should be displayed.
  105474. */
  105475. displayGaze: boolean;
  105476. /**
  105477. * If the ray of the LaserPointer should be displayed.
  105478. */
  105479. /**
  105480. * Sets if the ray of the LaserPointer should be displayed.
  105481. */
  105482. displayLaserPointer: boolean;
  105483. /**
  105484. * The deviceOrientationCamera used as the camera when not in VR.
  105485. */
  105486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105487. /**
  105488. * Based on the current WebVR support, returns the current VR camera used.
  105489. */
  105490. readonly currentVRCamera: Nullable<Camera>;
  105491. /**
  105492. * The webVRCamera which is used when in VR.
  105493. */
  105494. readonly webVRCamera: WebVRFreeCamera;
  105495. /**
  105496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105497. */
  105498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105499. /**
  105500. * The html button that is used to trigger entering into VR.
  105501. */
  105502. readonly vrButton: Nullable<HTMLButtonElement>;
  105503. private readonly _teleportationRequestInitiated;
  105504. /**
  105505. * Defines wether or not Pointer lock should be requested when switching to
  105506. * full screen.
  105507. */
  105508. requestPointerLockOnFullScreen: boolean;
  105509. /**
  105510. * Instantiates a VRExperienceHelper.
  105511. * Helps to quickly add VR support to an existing scene.
  105512. * @param scene The scene the VRExperienceHelper belongs to.
  105513. * @param webVROptions Options to modify the vr experience helper's behavior.
  105514. */
  105515. constructor(scene: Scene,
  105516. /** Options to modify the vr experience helper's behavior. */
  105517. webVROptions?: VRExperienceHelperOptions);
  105518. private _onDefaultMeshLoaded;
  105519. private _onResize;
  105520. private _onFullscreenChange;
  105521. /**
  105522. * Gets a value indicating if we are currently in VR mode.
  105523. */
  105524. readonly isInVRMode: boolean;
  105525. private onVrDisplayPresentChange;
  105526. private onVRDisplayChanged;
  105527. private moveButtonToBottomRight;
  105528. private displayVRButton;
  105529. private updateButtonVisibility;
  105530. private _cachedAngularSensibility;
  105531. /**
  105532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105533. * Otherwise, will use the fullscreen API.
  105534. */
  105535. enterVR(): void;
  105536. /**
  105537. * Attempt to exit VR, or fullscreen.
  105538. */
  105539. exitVR(): void;
  105540. /**
  105541. * The position of the vr experience helper.
  105542. */
  105543. /**
  105544. * Sets the position of the vr experience helper.
  105545. */
  105546. position: Vector3;
  105547. /**
  105548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105549. */
  105550. enableInteractions(): void;
  105551. private readonly _noControllerIsActive;
  105552. private beforeRender;
  105553. private _isTeleportationFloor;
  105554. /**
  105555. * Adds a floor mesh to be used for teleportation.
  105556. * @param floorMesh the mesh to be used for teleportation.
  105557. */
  105558. addFloorMesh(floorMesh: Mesh): void;
  105559. /**
  105560. * Removes a floor mesh from being used for teleportation.
  105561. * @param floorMesh the mesh to be removed.
  105562. */
  105563. removeFloorMesh(floorMesh: Mesh): void;
  105564. /**
  105565. * Enables interactions and teleportation using the VR controllers and gaze.
  105566. * @param vrTeleportationOptions options to modify teleportation behavior.
  105567. */
  105568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105569. private _onNewGamepadConnected;
  105570. private _tryEnableInteractionOnController;
  105571. private _onNewGamepadDisconnected;
  105572. private _enableInteractionOnController;
  105573. private _checkTeleportWithRay;
  105574. private _checkRotate;
  105575. private _checkTeleportBackwards;
  105576. private _enableTeleportationOnController;
  105577. private _createTeleportationCircles;
  105578. private _displayTeleportationTarget;
  105579. private _hideTeleportationTarget;
  105580. private _rotateCamera;
  105581. private _moveTeleportationSelectorTo;
  105582. private _workingVector;
  105583. private _workingQuaternion;
  105584. private _workingMatrix;
  105585. /**
  105586. * Teleports the users feet to the desired location
  105587. * @param location The location where the user's feet should be placed
  105588. */
  105589. teleportCamera(location: Vector3): void;
  105590. private _convertNormalToDirectionOfRay;
  105591. private _castRayAndSelectObject;
  105592. private _notifySelectedMeshUnselected;
  105593. /**
  105594. * Sets the color of the laser ray from the vr controllers.
  105595. * @param color new color for the ray.
  105596. */
  105597. changeLaserColor(color: Color3): void;
  105598. /**
  105599. * Sets the color of the ray from the vr headsets gaze.
  105600. * @param color new color for the ray.
  105601. */
  105602. changeGazeColor(color: Color3): void;
  105603. /**
  105604. * Exits VR and disposes of the vr experience helper
  105605. */
  105606. dispose(): void;
  105607. /**
  105608. * Gets the name of the VRExperienceHelper class
  105609. * @returns "VRExperienceHelper"
  105610. */
  105611. getClassName(): string;
  105612. }
  105613. }
  105614. declare module BABYLON {
  105615. /**
  105616. * Manages an XRSession to work with Babylon's engine
  105617. * @see https://doc.babylonjs.com/how_to/webxr
  105618. */
  105619. export class WebXRSessionManager implements IDisposable {
  105620. private scene;
  105621. /**
  105622. * Fires every time a new xrFrame arrives which can be used to update the camera
  105623. */
  105624. onXRFrameObservable: Observable<any>;
  105625. /**
  105626. * Fires when the xr session is ended either by the device or manually done
  105627. */
  105628. onXRSessionEnded: Observable<any>;
  105629. /**
  105630. * Underlying xr session
  105631. */
  105632. session: XRSession;
  105633. /**
  105634. * Type of reference space used when creating the session
  105635. */
  105636. referenceSpace: XRReferenceSpace;
  105637. /** @hidden */
  105638. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105639. /**
  105640. * Current XR frame
  105641. */
  105642. currentFrame: Nullable<XRFrame>;
  105643. private _xrNavigator;
  105644. private baseLayer;
  105645. /**
  105646. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105647. * @param scene The scene which the session should be created for
  105648. */
  105649. constructor(scene: Scene);
  105650. /**
  105651. * Initializes the manager
  105652. * After initialization enterXR can be called to start an XR session
  105653. * @returns Promise which resolves after it is initialized
  105654. */
  105655. initializeAsync(): Promise<void>;
  105656. /**
  105657. * Initializes an xr session
  105658. * @param xrSessionMode mode to initialize
  105659. * @returns a promise which will resolve once the session has been initialized
  105660. */
  105661. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105662. /**
  105663. * Sets the reference space on the xr session
  105664. * @param referenceSpace space to set
  105665. * @returns a promise that will resolve once the reference space has been set
  105666. */
  105667. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105668. /**
  105669. * Updates the render state of the session
  105670. * @param state state to set
  105671. * @returns a promise that resolves once the render state has been updated
  105672. */
  105673. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105674. /**
  105675. * Starts rendering to the xr layer
  105676. * @returns a promise that will resolve once rendering has started
  105677. */
  105678. startRenderingToXRAsync(): Promise<void>;
  105679. /**
  105680. * Stops the xrSession and restores the renderloop
  105681. * @returns Promise which resolves after it exits XR
  105682. */
  105683. exitXRAsync(): Promise<unknown>;
  105684. /**
  105685. * Checks if a session would be supported for the creation options specified
  105686. * @param sessionMode session mode to check if supported eg. immersive-vr
  105687. * @returns true if supported
  105688. */
  105689. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105690. /**
  105691. * @hidden
  105692. * Converts the render layer of xrSession to a render target
  105693. * @param session session to create render target for
  105694. * @param scene scene the new render target should be created for
  105695. */
  105696. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105697. /**
  105698. * Disposes of the session manager
  105699. */
  105700. dispose(): void;
  105701. }
  105702. }
  105703. declare module BABYLON {
  105704. /**
  105705. * WebXR Camera which holds the views for the xrSession
  105706. * @see https://doc.babylonjs.com/how_to/webxr
  105707. */
  105708. export class WebXRCamera extends FreeCamera {
  105709. private static _TmpMatrix;
  105710. /**
  105711. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105712. * @param name the name of the camera
  105713. * @param scene the scene to add the camera to
  105714. */
  105715. constructor(name: string, scene: Scene);
  105716. private _updateNumberOfRigCameras;
  105717. /** @hidden */
  105718. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105719. /**
  105720. * Updates the cameras position from the current pose information of the XR session
  105721. * @param xrSessionManager the session containing pose information
  105722. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105723. */
  105724. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105725. }
  105726. }
  105727. declare module BABYLON {
  105728. /**
  105729. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105730. */
  105731. export class WebXRManagedOutputCanvas implements IDisposable {
  105732. private helper;
  105733. private _canvas;
  105734. /**
  105735. * xrpresent context of the canvas which can be used to display/mirror xr content
  105736. */
  105737. canvasContext: WebGLRenderingContext;
  105738. /**
  105739. * xr layer for the canvas
  105740. */
  105741. xrLayer: Nullable<XRWebGLLayer>;
  105742. /**
  105743. * Initializes the xr layer for the session
  105744. * @param xrSession xr session
  105745. * @returns a promise that will resolve once the XR Layer has been created
  105746. */
  105747. initializeXRLayerAsync(xrSession: any): any;
  105748. /**
  105749. * Initializes the canvas to be added/removed upon entering/exiting xr
  105750. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105751. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105752. */
  105753. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105754. /**
  105755. * Disposes of the object
  105756. */
  105757. dispose(): void;
  105758. private _setManagedOutputCanvas;
  105759. private _addCanvas;
  105760. private _removeCanvas;
  105761. }
  105762. }
  105763. declare module BABYLON {
  105764. /**
  105765. * States of the webXR experience
  105766. */
  105767. export enum WebXRState {
  105768. /**
  105769. * Transitioning to being in XR mode
  105770. */
  105771. ENTERING_XR = 0,
  105772. /**
  105773. * Transitioning to non XR mode
  105774. */
  105775. EXITING_XR = 1,
  105776. /**
  105777. * In XR mode and presenting
  105778. */
  105779. IN_XR = 2,
  105780. /**
  105781. * Not entered XR mode
  105782. */
  105783. NOT_IN_XR = 3
  105784. }
  105785. /**
  105786. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105787. * @see https://doc.babylonjs.com/how_to/webxr
  105788. */
  105789. export class WebXRExperienceHelper implements IDisposable {
  105790. private scene;
  105791. /**
  105792. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  105793. */
  105794. container: AbstractMesh;
  105795. /**
  105796. * Camera used to render xr content
  105797. */
  105798. camera: WebXRCamera;
  105799. /**
  105800. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105801. */
  105802. state: WebXRState;
  105803. private _setState;
  105804. private static _TmpVector;
  105805. /**
  105806. * Fires when the state of the experience helper has changed
  105807. */
  105808. onStateChangedObservable: Observable<WebXRState>;
  105809. /** Session manager used to keep track of xr session */
  105810. sessionManager: WebXRSessionManager;
  105811. private _nonVRCamera;
  105812. private _originalSceneAutoClear;
  105813. private _supported;
  105814. /**
  105815. * Creates the experience helper
  105816. * @param scene the scene to attach the experience helper to
  105817. * @returns a promise for the experience helper
  105818. */
  105819. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105820. /**
  105821. * Creates a WebXRExperienceHelper
  105822. * @param scene The scene the helper should be created in
  105823. */
  105824. private constructor();
  105825. /**
  105826. * Exits XR mode and returns the scene to its original state
  105827. * @returns promise that resolves after xr mode has exited
  105828. */
  105829. exitXRAsync(): Promise<unknown>;
  105830. /**
  105831. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105832. * @param sessionCreationOptions options for the XR session
  105833. * @param referenceSpaceType frame of reference of the XR session
  105834. * @param outputCanvas the output canvas that will be used to enter XR mode
  105835. * @returns promise that resolves after xr mode has entered
  105836. */
  105837. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105838. /**
  105839. * Updates the global position of the camera by moving the camera's container
  105840. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  105841. * @param position The desired global position of the camera
  105842. */
  105843. setPositionOfCameraUsingContainer(position: Vector3): void;
  105844. /**
  105845. * Rotates the xr camera by rotating the camera's container around the camera's position
  105846. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105847. * @param rotation the desired quaternion rotation to apply to the camera
  105848. */
  105849. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105850. /**
  105851. * Disposes of the experience helper
  105852. */
  105853. dispose(): void;
  105854. }
  105855. }
  105856. declare module BABYLON {
  105857. /**
  105858. * Button which can be used to enter a different mode of XR
  105859. */
  105860. export class WebXREnterExitUIButton {
  105861. /** button element */
  105862. element: HTMLElement;
  105863. /** XR initialization options for the button */
  105864. sessionMode: XRSessionMode;
  105865. /** Reference space type */
  105866. referenceSpaceType: XRReferenceSpaceType;
  105867. /**
  105868. * Creates a WebXREnterExitUIButton
  105869. * @param element button element
  105870. * @param sessionMode XR initialization session mode
  105871. * @param referenceSpaceType the type of reference space to be used
  105872. */
  105873. constructor(
  105874. /** button element */
  105875. element: HTMLElement,
  105876. /** XR initialization options for the button */
  105877. sessionMode: XRSessionMode,
  105878. /** Reference space type */
  105879. referenceSpaceType: XRReferenceSpaceType);
  105880. /**
  105881. * Overwritable function which can be used to update the button's visuals when the state changes
  105882. * @param activeButton the current active button in the UI
  105883. */
  105884. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105885. }
  105886. /**
  105887. * Options to create the webXR UI
  105888. */
  105889. export class WebXREnterExitUIOptions {
  105890. /**
  105891. * Context to enter xr with
  105892. */
  105893. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105894. /**
  105895. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105896. */
  105897. customButtons?: Array<WebXREnterExitUIButton>;
  105898. }
  105899. /**
  105900. * UI to allow the user to enter/exit XR mode
  105901. */
  105902. export class WebXREnterExitUI implements IDisposable {
  105903. private scene;
  105904. private _overlay;
  105905. private _buttons;
  105906. private _activeButton;
  105907. /**
  105908. * Fired every time the active button is changed.
  105909. *
  105910. * When xr is entered via a button that launches xr that button will be the callback parameter
  105911. *
  105912. * When exiting xr the callback parameter will be null)
  105913. */
  105914. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105915. /**
  105916. * Creates UI to allow the user to enter/exit XR mode
  105917. * @param scene the scene to add the ui to
  105918. * @param helper the xr experience helper to enter/exit xr with
  105919. * @param options options to configure the UI
  105920. * @returns the created ui
  105921. */
  105922. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105923. private constructor();
  105924. private _updateButtons;
  105925. /**
  105926. * Disposes of the object
  105927. */
  105928. dispose(): void;
  105929. }
  105930. }
  105931. declare module BABYLON {
  105932. /**
  105933. * Represents an XR input
  105934. */
  105935. export class WebXRController {
  105936. private scene;
  105937. /** The underlying input source for the controller */
  105938. inputSource: XRInputSource;
  105939. private parentContainer;
  105940. /**
  105941. * 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
  105942. */
  105943. grip?: AbstractMesh;
  105944. /**
  105945. * Pointer which can be used to select objects or attach a visible laser to
  105946. */
  105947. pointer: AbstractMesh;
  105948. /**
  105949. * Event that fires when the controller is removed/disposed
  105950. */
  105951. onDisposeObservable: Observable<{}>;
  105952. private _tmpMatrix;
  105953. private _tmpQuaternion;
  105954. private _tmpVector;
  105955. /**
  105956. * Creates the controller
  105957. * @see https://doc.babylonjs.com/how_to/webxr
  105958. * @param scene the scene which the controller should be associated to
  105959. * @param inputSource the underlying input source for the controller
  105960. * @param parentContainer parent that the controller meshes should be children of
  105961. */
  105962. constructor(scene: Scene,
  105963. /** The underlying input source for the controller */
  105964. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105965. /**
  105966. * Updates the controller pose based on the given XRFrame
  105967. * @param xrFrame xr frame to update the pose with
  105968. * @param referenceSpace reference space to use
  105969. */
  105970. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105971. /**
  105972. * Gets a world space ray coming from the controller
  105973. * @param result the resulting ray
  105974. */
  105975. getWorldPointerRayToRef(result: Ray): void;
  105976. /**
  105977. * Disposes of the object
  105978. */
  105979. dispose(): void;
  105980. }
  105981. }
  105982. declare module BABYLON {
  105983. /**
  105984. * XR input used to track XR inputs such as controllers/rays
  105985. */
  105986. export class WebXRInput implements IDisposable {
  105987. /**
  105988. * Base experience the input listens to
  105989. */
  105990. baseExperience: WebXRExperienceHelper;
  105991. /**
  105992. * XR controllers being tracked
  105993. */
  105994. controllers: Array<WebXRController>;
  105995. private _frameObserver;
  105996. private _stateObserver;
  105997. /**
  105998. * Event when a controller has been connected/added
  105999. */
  106000. onControllerAddedObservable: Observable<WebXRController>;
  106001. /**
  106002. * Event when a controller has been removed/disconnected
  106003. */
  106004. onControllerRemovedObservable: Observable<WebXRController>;
  106005. /**
  106006. * Initializes the WebXRInput
  106007. * @param baseExperience experience helper which the input should be created for
  106008. */
  106009. constructor(
  106010. /**
  106011. * Base experience the input listens to
  106012. */
  106013. baseExperience: WebXRExperienceHelper);
  106014. private _onInputSourcesChange;
  106015. private _addAndRemoveControllers;
  106016. /**
  106017. * Disposes of the object
  106018. */
  106019. dispose(): void;
  106020. }
  106021. }
  106022. declare module BABYLON {
  106023. /**
  106024. * Enables teleportation
  106025. */
  106026. export class WebXRControllerTeleportation {
  106027. private _teleportationFillColor;
  106028. private _teleportationBorderColor;
  106029. private _tmpRay;
  106030. private _tmpVector;
  106031. /**
  106032. * Creates a WebXRControllerTeleportation
  106033. * @param input input manager to add teleportation to
  106034. * @param floorMeshes floormeshes which can be teleported to
  106035. */
  106036. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106037. }
  106038. }
  106039. declare module BABYLON {
  106040. /**
  106041. * Handles pointer input automatically for the pointer of XR controllers
  106042. */
  106043. export class WebXRControllerPointerSelection {
  106044. private static _idCounter;
  106045. private _tmpRay;
  106046. /**
  106047. * Creates a WebXRControllerPointerSelection
  106048. * @param input input manager to setup pointer selection
  106049. */
  106050. constructor(input: WebXRInput);
  106051. private _convertNormalToDirectionOfRay;
  106052. private _updatePointerDistance;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * Class used to represent data loading progression
  106058. */
  106059. export class SceneLoaderProgressEvent {
  106060. /** defines if data length to load can be evaluated */
  106061. readonly lengthComputable: boolean;
  106062. /** defines the loaded data length */
  106063. readonly loaded: number;
  106064. /** defines the data length to load */
  106065. readonly total: number;
  106066. /**
  106067. * Create a new progress event
  106068. * @param lengthComputable defines if data length to load can be evaluated
  106069. * @param loaded defines the loaded data length
  106070. * @param total defines the data length to load
  106071. */
  106072. constructor(
  106073. /** defines if data length to load can be evaluated */
  106074. lengthComputable: boolean,
  106075. /** defines the loaded data length */
  106076. loaded: number,
  106077. /** defines the data length to load */
  106078. total: number);
  106079. /**
  106080. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106081. * @param event defines the source event
  106082. * @returns a new SceneLoaderProgressEvent
  106083. */
  106084. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106085. }
  106086. /**
  106087. * Interface used by SceneLoader plugins to define supported file extensions
  106088. */
  106089. export interface ISceneLoaderPluginExtensions {
  106090. /**
  106091. * Defines the list of supported extensions
  106092. */
  106093. [extension: string]: {
  106094. isBinary: boolean;
  106095. };
  106096. }
  106097. /**
  106098. * Interface used by SceneLoader plugin factory
  106099. */
  106100. export interface ISceneLoaderPluginFactory {
  106101. /**
  106102. * Defines the name of the factory
  106103. */
  106104. name: string;
  106105. /**
  106106. * Function called to create a new plugin
  106107. * @return the new plugin
  106108. */
  106109. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106110. /**
  106111. * Boolean indicating if the plugin can direct load specific data
  106112. */
  106113. canDirectLoad?: (data: string) => boolean;
  106114. }
  106115. /**
  106116. * Interface used to define a SceneLoader plugin
  106117. */
  106118. export interface ISceneLoaderPlugin {
  106119. /**
  106120. * The friendly name of this plugin.
  106121. */
  106122. name: string;
  106123. /**
  106124. * The file extensions supported by this plugin.
  106125. */
  106126. extensions: string | ISceneLoaderPluginExtensions;
  106127. /**
  106128. * Import meshes into a scene.
  106129. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106130. * @param scene The scene to import into
  106131. * @param data The data to import
  106132. * @param rootUrl The root url for scene and resources
  106133. * @param meshes The meshes array to import into
  106134. * @param particleSystems The particle systems array to import into
  106135. * @param skeletons The skeletons array to import into
  106136. * @param onError The callback when import fails
  106137. * @returns True if successful or false otherwise
  106138. */
  106139. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106140. /**
  106141. * Load into a scene.
  106142. * @param scene The scene to load into
  106143. * @param data The data to import
  106144. * @param rootUrl The root url for scene and resources
  106145. * @param onError The callback when import fails
  106146. * @returns true if successful or false otherwise
  106147. */
  106148. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106149. /**
  106150. * The callback that returns true if the data can be directly loaded.
  106151. */
  106152. canDirectLoad?: (data: string) => boolean;
  106153. /**
  106154. * The callback that allows custom handling of the root url based on the response url.
  106155. */
  106156. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106157. /**
  106158. * Load into an asset container.
  106159. * @param scene The scene to load into
  106160. * @param data The data to import
  106161. * @param rootUrl The root url for scene and resources
  106162. * @param onError The callback when import fails
  106163. * @returns The loaded asset container
  106164. */
  106165. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106166. }
  106167. /**
  106168. * Interface used to define an async SceneLoader plugin
  106169. */
  106170. export interface ISceneLoaderPluginAsync {
  106171. /**
  106172. * The friendly name of this plugin.
  106173. */
  106174. name: string;
  106175. /**
  106176. * The file extensions supported by this plugin.
  106177. */
  106178. extensions: string | ISceneLoaderPluginExtensions;
  106179. /**
  106180. * Import meshes into a scene.
  106181. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106182. * @param scene The scene to import into
  106183. * @param data The data to import
  106184. * @param rootUrl The root url for scene and resources
  106185. * @param onProgress The callback when the load progresses
  106186. * @param fileName Defines the name of the file to load
  106187. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106188. */
  106189. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106190. meshes: AbstractMesh[];
  106191. particleSystems: IParticleSystem[];
  106192. skeletons: Skeleton[];
  106193. animationGroups: AnimationGroup[];
  106194. }>;
  106195. /**
  106196. * Load into a scene.
  106197. * @param scene The scene to load into
  106198. * @param data The data to import
  106199. * @param rootUrl The root url for scene and resources
  106200. * @param onProgress The callback when the load progresses
  106201. * @param fileName Defines the name of the file to load
  106202. * @returns Nothing
  106203. */
  106204. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106205. /**
  106206. * The callback that returns true if the data can be directly loaded.
  106207. */
  106208. canDirectLoad?: (data: string) => boolean;
  106209. /**
  106210. * The callback that allows custom handling of the root url based on the response url.
  106211. */
  106212. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106213. /**
  106214. * Load into an asset container.
  106215. * @param scene The scene to load into
  106216. * @param data The data to import
  106217. * @param rootUrl The root url for scene and resources
  106218. * @param onProgress The callback when the load progresses
  106219. * @param fileName Defines the name of the file to load
  106220. * @returns The loaded asset container
  106221. */
  106222. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106223. }
  106224. /**
  106225. * Class used to load scene from various file formats using registered plugins
  106226. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106227. */
  106228. export class SceneLoader {
  106229. /**
  106230. * No logging while loading
  106231. */
  106232. static readonly NO_LOGGING: number;
  106233. /**
  106234. * Minimal logging while loading
  106235. */
  106236. static readonly MINIMAL_LOGGING: number;
  106237. /**
  106238. * Summary logging while loading
  106239. */
  106240. static readonly SUMMARY_LOGGING: number;
  106241. /**
  106242. * Detailled logging while loading
  106243. */
  106244. static readonly DETAILED_LOGGING: number;
  106245. /**
  106246. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106247. */
  106248. static ForceFullSceneLoadingForIncremental: boolean;
  106249. /**
  106250. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106251. */
  106252. static ShowLoadingScreen: boolean;
  106253. /**
  106254. * Defines the current logging level (while loading the scene)
  106255. * @ignorenaming
  106256. */
  106257. static loggingLevel: number;
  106258. /**
  106259. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106260. */
  106261. static CleanBoneMatrixWeights: boolean;
  106262. /**
  106263. * Event raised when a plugin is used to load a scene
  106264. */
  106265. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106266. private static _registeredPlugins;
  106267. private static _getDefaultPlugin;
  106268. private static _getPluginForExtension;
  106269. private static _getPluginForDirectLoad;
  106270. private static _getPluginForFilename;
  106271. private static _getDirectLoad;
  106272. private static _loadData;
  106273. private static _getFileInfo;
  106274. /**
  106275. * Gets a plugin that can load the given extension
  106276. * @param extension defines the extension to load
  106277. * @returns a plugin or null if none works
  106278. */
  106279. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106280. /**
  106281. * Gets a boolean indicating that the given extension can be loaded
  106282. * @param extension defines the extension to load
  106283. * @returns true if the extension is supported
  106284. */
  106285. static IsPluginForExtensionAvailable(extension: string): boolean;
  106286. /**
  106287. * Adds a new plugin to the list of registered plugins
  106288. * @param plugin defines the plugin to add
  106289. */
  106290. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106291. /**
  106292. * Import meshes into a scene
  106293. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106294. * @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)
  106295. * @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)
  106296. * @param scene the instance of BABYLON.Scene to append to
  106297. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106298. * @param onProgress a callback with a progress event for each file being loaded
  106299. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106300. * @param pluginExtension the extension used to determine the plugin
  106301. * @returns The loaded plugin
  106302. */
  106303. 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>;
  106304. /**
  106305. * Import meshes into a scene
  106306. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106307. * @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)
  106308. * @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)
  106309. * @param scene the instance of BABYLON.Scene to append to
  106310. * @param onProgress a callback with a progress event for each file being loaded
  106311. * @param pluginExtension the extension used to determine the plugin
  106312. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106313. */
  106314. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106315. meshes: AbstractMesh[];
  106316. particleSystems: IParticleSystem[];
  106317. skeletons: Skeleton[];
  106318. animationGroups: AnimationGroup[];
  106319. }>;
  106320. /**
  106321. * Load a scene
  106322. * @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)
  106323. * @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)
  106324. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106325. * @param onSuccess a callback with the scene when import succeeds
  106326. * @param onProgress a callback with a progress event for each file being loaded
  106327. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106328. * @param pluginExtension the extension used to determine the plugin
  106329. * @returns The loaded plugin
  106330. */
  106331. 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>;
  106332. /**
  106333. * Load a scene
  106334. * @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)
  106335. * @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)
  106336. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106337. * @param onProgress a callback with a progress event for each file being loaded
  106338. * @param pluginExtension the extension used to determine the plugin
  106339. * @returns The loaded scene
  106340. */
  106341. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106342. /**
  106343. * Append a scene
  106344. * @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)
  106345. * @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)
  106346. * @param scene is the instance of BABYLON.Scene to append to
  106347. * @param onSuccess a callback with the scene when import succeeds
  106348. * @param onProgress a callback with a progress event for each file being loaded
  106349. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106350. * @param pluginExtension the extension used to determine the plugin
  106351. * @returns The loaded plugin
  106352. */
  106353. 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>;
  106354. /**
  106355. * Append a scene
  106356. * @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)
  106357. * @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)
  106358. * @param scene is the instance of BABYLON.Scene to append to
  106359. * @param onProgress a callback with a progress event for each file being loaded
  106360. * @param pluginExtension the extension used to determine the plugin
  106361. * @returns The given scene
  106362. */
  106363. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106364. /**
  106365. * Load a scene into an asset container
  106366. * @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)
  106367. * @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)
  106368. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106369. * @param onSuccess a callback with the scene when import succeeds
  106370. * @param onProgress a callback with a progress event for each file being loaded
  106371. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106372. * @param pluginExtension the extension used to determine the plugin
  106373. * @returns The loaded plugin
  106374. */
  106375. 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>;
  106376. /**
  106377. * Load a scene into an asset container
  106378. * @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)
  106379. * @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)
  106380. * @param scene is the instance of Scene to append to
  106381. * @param onProgress a callback with a progress event for each file being loaded
  106382. * @param pluginExtension the extension used to determine the plugin
  106383. * @returns The loaded asset container
  106384. */
  106385. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106386. }
  106387. }
  106388. declare module BABYLON {
  106389. /**
  106390. * Generic Controller
  106391. */
  106392. export class GenericController extends WebVRController {
  106393. /**
  106394. * Base Url for the controller model.
  106395. */
  106396. static readonly MODEL_BASE_URL: string;
  106397. /**
  106398. * File name for the controller model.
  106399. */
  106400. static readonly MODEL_FILENAME: string;
  106401. /**
  106402. * Creates a new GenericController from a gamepad
  106403. * @param vrGamepad the gamepad that the controller should be created from
  106404. */
  106405. constructor(vrGamepad: any);
  106406. /**
  106407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106408. * @param scene scene in which to add meshes
  106409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106410. */
  106411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106412. /**
  106413. * Called once for each button that changed state since the last frame
  106414. * @param buttonIdx Which button index changed
  106415. * @param state New state of the button
  106416. * @param changes Which properties on the state changed since last frame
  106417. */
  106418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106419. }
  106420. }
  106421. declare module BABYLON {
  106422. /**
  106423. * Defines the WindowsMotionController object that the state of the windows motion controller
  106424. */
  106425. export class WindowsMotionController extends WebVRController {
  106426. /**
  106427. * The base url used to load the left and right controller models
  106428. */
  106429. static MODEL_BASE_URL: string;
  106430. /**
  106431. * The name of the left controller model file
  106432. */
  106433. static MODEL_LEFT_FILENAME: string;
  106434. /**
  106435. * The name of the right controller model file
  106436. */
  106437. static MODEL_RIGHT_FILENAME: string;
  106438. /**
  106439. * The controller name prefix for this controller type
  106440. */
  106441. static readonly GAMEPAD_ID_PREFIX: string;
  106442. /**
  106443. * The controller id pattern for this controller type
  106444. */
  106445. private static readonly GAMEPAD_ID_PATTERN;
  106446. private _loadedMeshInfo;
  106447. private readonly _mapping;
  106448. /**
  106449. * Fired when the trackpad on this controller is clicked
  106450. */
  106451. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106452. /**
  106453. * Fired when the trackpad on this controller is modified
  106454. */
  106455. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106456. /**
  106457. * The current x and y values of this controller's trackpad
  106458. */
  106459. trackpad: StickValues;
  106460. /**
  106461. * Creates a new WindowsMotionController from a gamepad
  106462. * @param vrGamepad the gamepad that the controller should be created from
  106463. */
  106464. constructor(vrGamepad: any);
  106465. /**
  106466. * Fired when the trigger on this controller is modified
  106467. */
  106468. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106469. /**
  106470. * Fired when the menu button on this controller is modified
  106471. */
  106472. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106473. /**
  106474. * Fired when the grip button on this controller is modified
  106475. */
  106476. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106477. /**
  106478. * Fired when the thumbstick button on this controller is modified
  106479. */
  106480. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106481. /**
  106482. * Fired when the touchpad button on this controller is modified
  106483. */
  106484. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106485. /**
  106486. * Fired when the touchpad values on this controller are modified
  106487. */
  106488. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106489. private _updateTrackpad;
  106490. /**
  106491. * Called once per frame by the engine.
  106492. */
  106493. update(): void;
  106494. /**
  106495. * Called once for each button that changed state since the last frame
  106496. * @param buttonIdx Which button index changed
  106497. * @param state New state of the button
  106498. * @param changes Which properties on the state changed since last frame
  106499. */
  106500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106501. /**
  106502. * Moves the buttons on the controller mesh based on their current state
  106503. * @param buttonName the name of the button to move
  106504. * @param buttonValue the value of the button which determines the buttons new position
  106505. */
  106506. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106507. /**
  106508. * Moves the axis on the controller mesh based on its current state
  106509. * @param axis the index of the axis
  106510. * @param axisValue the value of the axis which determines the meshes new position
  106511. * @hidden
  106512. */
  106513. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106514. /**
  106515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106516. * @param scene scene in which to add meshes
  106517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106518. */
  106519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106520. /**
  106521. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106522. * can be transformed by button presses and axes values, based on this._mapping.
  106523. *
  106524. * @param scene scene in which the meshes exist
  106525. * @param meshes list of meshes that make up the controller model to process
  106526. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106527. */
  106528. private processModel;
  106529. private createMeshInfo;
  106530. /**
  106531. * Gets the ray of the controller in the direction the controller is pointing
  106532. * @param length the length the resulting ray should be
  106533. * @returns a ray in the direction the controller is pointing
  106534. */
  106535. getForwardRay(length?: number): Ray;
  106536. /**
  106537. * Disposes of the controller
  106538. */
  106539. dispose(): void;
  106540. }
  106541. }
  106542. declare module BABYLON {
  106543. /**
  106544. * Oculus Touch Controller
  106545. */
  106546. export class OculusTouchController extends WebVRController {
  106547. /**
  106548. * Base Url for the controller model.
  106549. */
  106550. static MODEL_BASE_URL: string;
  106551. /**
  106552. * File name for the left controller model.
  106553. */
  106554. static MODEL_LEFT_FILENAME: string;
  106555. /**
  106556. * File name for the right controller model.
  106557. */
  106558. static MODEL_RIGHT_FILENAME: string;
  106559. /**
  106560. * Base Url for the Quest controller model.
  106561. */
  106562. static QUEST_MODEL_BASE_URL: string;
  106563. /**
  106564. * @hidden
  106565. * If the controllers are running on a device that needs the updated Quest controller models
  106566. */
  106567. static _IsQuest: boolean;
  106568. /**
  106569. * Fired when the secondary trigger on this controller is modified
  106570. */
  106571. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106572. /**
  106573. * Fired when the thumb rest on this controller is modified
  106574. */
  106575. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106576. /**
  106577. * Creates a new OculusTouchController from a gamepad
  106578. * @param vrGamepad the gamepad that the controller should be created from
  106579. */
  106580. constructor(vrGamepad: any);
  106581. /**
  106582. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106583. * @param scene scene in which to add meshes
  106584. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106585. */
  106586. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106587. /**
  106588. * Fired when the A button on this controller is modified
  106589. */
  106590. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106591. /**
  106592. * Fired when the B button on this controller is modified
  106593. */
  106594. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106595. /**
  106596. * Fired when the X button on this controller is modified
  106597. */
  106598. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106599. /**
  106600. * Fired when the Y button on this controller is modified
  106601. */
  106602. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106603. /**
  106604. * Called once for each button that changed state since the last frame
  106605. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106606. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106607. * 2) secondary trigger (same)
  106608. * 3) A (right) X (left), touch, pressed = value
  106609. * 4) B / Y
  106610. * 5) thumb rest
  106611. * @param buttonIdx Which button index changed
  106612. * @param state New state of the button
  106613. * @param changes Which properties on the state changed since last frame
  106614. */
  106615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106616. }
  106617. }
  106618. declare module BABYLON {
  106619. /**
  106620. * Vive Controller
  106621. */
  106622. export class ViveController extends WebVRController {
  106623. /**
  106624. * Base Url for the controller model.
  106625. */
  106626. static MODEL_BASE_URL: string;
  106627. /**
  106628. * File name for the controller model.
  106629. */
  106630. static MODEL_FILENAME: string;
  106631. /**
  106632. * Creates a new ViveController from a gamepad
  106633. * @param vrGamepad the gamepad that the controller should be created from
  106634. */
  106635. constructor(vrGamepad: any);
  106636. /**
  106637. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106638. * @param scene scene in which to add meshes
  106639. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106640. */
  106641. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106642. /**
  106643. * Fired when the left button on this controller is modified
  106644. */
  106645. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106646. /**
  106647. * Fired when the right button on this controller is modified
  106648. */
  106649. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106650. /**
  106651. * Fired when the menu button on this controller is modified
  106652. */
  106653. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106654. /**
  106655. * Called once for each button that changed state since the last frame
  106656. * Vive mapping:
  106657. * 0: touchpad
  106658. * 1: trigger
  106659. * 2: left AND right buttons
  106660. * 3: menu button
  106661. * @param buttonIdx Which button index changed
  106662. * @param state New state of the button
  106663. * @param changes Which properties on the state changed since last frame
  106664. */
  106665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106666. }
  106667. }
  106668. declare module BABYLON {
  106669. /**
  106670. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106671. */
  106672. export class WebXRControllerModelLoader {
  106673. /**
  106674. * Creates the WebXRControllerModelLoader
  106675. * @param input xr input that creates the controllers
  106676. */
  106677. constructor(input: WebXRInput);
  106678. }
  106679. }
  106680. declare module BABYLON {
  106681. /**
  106682. * Contains an array of blocks representing the octree
  106683. */
  106684. export interface IOctreeContainer<T> {
  106685. /**
  106686. * Blocks within the octree
  106687. */
  106688. blocks: Array<OctreeBlock<T>>;
  106689. }
  106690. /**
  106691. * Class used to store a cell in an octree
  106692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106693. */
  106694. export class OctreeBlock<T> {
  106695. /**
  106696. * Gets the content of the current block
  106697. */
  106698. entries: T[];
  106699. /**
  106700. * Gets the list of block children
  106701. */
  106702. blocks: Array<OctreeBlock<T>>;
  106703. private _depth;
  106704. private _maxDepth;
  106705. private _capacity;
  106706. private _minPoint;
  106707. private _maxPoint;
  106708. private _boundingVectors;
  106709. private _creationFunc;
  106710. /**
  106711. * Creates a new block
  106712. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106713. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106714. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106715. * @param depth defines the current depth of this block in the octree
  106716. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106717. * @param creationFunc defines a callback to call when an element is added to the block
  106718. */
  106719. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106720. /**
  106721. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106722. */
  106723. readonly capacity: number;
  106724. /**
  106725. * Gets the minimum vector (in world space) of the block's bounding box
  106726. */
  106727. readonly minPoint: Vector3;
  106728. /**
  106729. * Gets the maximum vector (in world space) of the block's bounding box
  106730. */
  106731. readonly maxPoint: Vector3;
  106732. /**
  106733. * Add a new element to this block
  106734. * @param entry defines the element to add
  106735. */
  106736. addEntry(entry: T): void;
  106737. /**
  106738. * Remove an element from this block
  106739. * @param entry defines the element to remove
  106740. */
  106741. removeEntry(entry: T): void;
  106742. /**
  106743. * Add an array of elements to this block
  106744. * @param entries defines the array of elements to add
  106745. */
  106746. addEntries(entries: T[]): void;
  106747. /**
  106748. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106749. * @param frustumPlanes defines the frustum planes to test
  106750. * @param selection defines the array to store current content if selection is positive
  106751. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106752. */
  106753. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106754. /**
  106755. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106756. * @param sphereCenter defines the bounding sphere center
  106757. * @param sphereRadius defines the bounding sphere radius
  106758. * @param selection defines the array to store current content if selection is positive
  106759. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106760. */
  106761. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106762. /**
  106763. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106764. * @param ray defines the ray to test with
  106765. * @param selection defines the array to store current content if selection is positive
  106766. */
  106767. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106768. /**
  106769. * Subdivide the content into child blocks (this block will then be empty)
  106770. */
  106771. createInnerBlocks(): void;
  106772. /**
  106773. * @hidden
  106774. */
  106775. 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;
  106776. }
  106777. }
  106778. declare module BABYLON {
  106779. /**
  106780. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106781. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106782. */
  106783. export class Octree<T> {
  106784. /** 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.) */
  106785. maxDepth: number;
  106786. /**
  106787. * Blocks within the octree containing objects
  106788. */
  106789. blocks: Array<OctreeBlock<T>>;
  106790. /**
  106791. * Content stored in the octree
  106792. */
  106793. dynamicContent: T[];
  106794. private _maxBlockCapacity;
  106795. private _selectionContent;
  106796. private _creationFunc;
  106797. /**
  106798. * Creates a octree
  106799. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106800. * @param creationFunc function to be used to instatiate the octree
  106801. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106802. * @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.)
  106803. */
  106804. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106805. /** 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.) */
  106806. maxDepth?: number);
  106807. /**
  106808. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106809. * @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);
  106810. * @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);
  106811. * @param entries meshes to be added to the octree blocks
  106812. */
  106813. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106814. /**
  106815. * Adds a mesh to the octree
  106816. * @param entry Mesh to add to the octree
  106817. */
  106818. addMesh(entry: T): void;
  106819. /**
  106820. * Remove an element from the octree
  106821. * @param entry defines the element to remove
  106822. */
  106823. removeMesh(entry: T): void;
  106824. /**
  106825. * Selects an array of meshes within the frustum
  106826. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106827. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106828. * @returns array of meshes within the frustum
  106829. */
  106830. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106831. /**
  106832. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106833. * @param sphereCenter defines the bounding sphere center
  106834. * @param sphereRadius defines the bounding sphere radius
  106835. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106836. * @returns an array of objects that intersect the sphere
  106837. */
  106838. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106839. /**
  106840. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  106841. * @param ray defines the ray to test with
  106842. * @returns array of intersected objects
  106843. */
  106844. intersectsRay(ray: Ray): SmartArray<T>;
  106845. /**
  106846. * Adds a mesh into the octree block if it intersects the block
  106847. */
  106848. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106849. /**
  106850. * Adds a submesh into the octree block if it intersects the block
  106851. */
  106852. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106853. }
  106854. }
  106855. declare module BABYLON {
  106856. interface Scene {
  106857. /**
  106858. * @hidden
  106859. * Backing Filed
  106860. */
  106861. _selectionOctree: Octree<AbstractMesh>;
  106862. /**
  106863. * Gets the octree used to boost mesh selection (picking)
  106864. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106865. */
  106866. selectionOctree: Octree<AbstractMesh>;
  106867. /**
  106868. * Creates or updates the octree used to boost selection (picking)
  106869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106870. * @param maxCapacity defines the maximum capacity per leaf
  106871. * @param maxDepth defines the maximum depth of the octree
  106872. * @returns an octree of AbstractMesh
  106873. */
  106874. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106875. }
  106876. interface AbstractMesh {
  106877. /**
  106878. * @hidden
  106879. * Backing Field
  106880. */
  106881. _submeshesOctree: Octree<SubMesh>;
  106882. /**
  106883. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106884. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106885. * @param maxCapacity defines the maximum size of each block (64 by default)
  106886. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106887. * @returns the new octree
  106888. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106890. */
  106891. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106892. }
  106893. /**
  106894. * Defines the octree scene component responsible to manage any octrees
  106895. * in a given scene.
  106896. */
  106897. export class OctreeSceneComponent {
  106898. /**
  106899. * The component name help to identify the component in the list of scene components.
  106900. */
  106901. readonly name: string;
  106902. /**
  106903. * The scene the component belongs to.
  106904. */
  106905. scene: Scene;
  106906. /**
  106907. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106908. */
  106909. readonly checksIsEnabled: boolean;
  106910. /**
  106911. * Creates a new instance of the component for the given scene
  106912. * @param scene Defines the scene to register the component in
  106913. */
  106914. constructor(scene: Scene);
  106915. /**
  106916. * Registers the component in a given scene
  106917. */
  106918. register(): void;
  106919. /**
  106920. * Return the list of active meshes
  106921. * @returns the list of active meshes
  106922. */
  106923. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106924. /**
  106925. * Return the list of active sub meshes
  106926. * @param mesh The mesh to get the candidates sub meshes from
  106927. * @returns the list of active sub meshes
  106928. */
  106929. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106930. private _tempRay;
  106931. /**
  106932. * Return the list of sub meshes intersecting with a given local ray
  106933. * @param mesh defines the mesh to find the submesh for
  106934. * @param localRay defines the ray in local space
  106935. * @returns the list of intersecting sub meshes
  106936. */
  106937. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106938. /**
  106939. * Return the list of sub meshes colliding with a collider
  106940. * @param mesh defines the mesh to find the submesh for
  106941. * @param collider defines the collider to evaluate the collision against
  106942. * @returns the list of colliding sub meshes
  106943. */
  106944. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106945. /**
  106946. * Rebuilds the elements related to this component in case of
  106947. * context lost for instance.
  106948. */
  106949. rebuild(): void;
  106950. /**
  106951. * Disposes the component and the associated ressources.
  106952. */
  106953. dispose(): void;
  106954. }
  106955. }
  106956. declare module BABYLON {
  106957. /**
  106958. * Renders a layer on top of an existing scene
  106959. */
  106960. export class UtilityLayerRenderer implements IDisposable {
  106961. /** the original scene that will be rendered on top of */
  106962. originalScene: Scene;
  106963. private _pointerCaptures;
  106964. private _lastPointerEvents;
  106965. private static _DefaultUtilityLayer;
  106966. private static _DefaultKeepDepthUtilityLayer;
  106967. private _sharedGizmoLight;
  106968. private _renderCamera;
  106969. /**
  106970. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106971. * @returns the camera that is used when rendering the utility layer
  106972. */
  106973. getRenderCamera(): Nullable<Camera>;
  106974. /**
  106975. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106976. * @param cam the camera that should be used when rendering the utility layer
  106977. */
  106978. setRenderCamera(cam: Nullable<Camera>): void;
  106979. /**
  106980. * @hidden
  106981. * Light which used by gizmos to get light shading
  106982. */
  106983. _getSharedGizmoLight(): HemisphericLight;
  106984. /**
  106985. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106986. */
  106987. pickUtilitySceneFirst: boolean;
  106988. /**
  106989. * 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)
  106990. */
  106991. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106992. /**
  106993. * 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)
  106994. */
  106995. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106996. /**
  106997. * The scene that is rendered on top of the original scene
  106998. */
  106999. utilityLayerScene: Scene;
  107000. /**
  107001. * If the utility layer should automatically be rendered on top of existing scene
  107002. */
  107003. shouldRender: boolean;
  107004. /**
  107005. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107006. */
  107007. onlyCheckPointerDownEvents: boolean;
  107008. /**
  107009. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107010. */
  107011. processAllEvents: boolean;
  107012. /**
  107013. * Observable raised when the pointer move from the utility layer scene to the main scene
  107014. */
  107015. onPointerOutObservable: Observable<number>;
  107016. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107017. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107018. private _afterRenderObserver;
  107019. private _sceneDisposeObserver;
  107020. private _originalPointerObserver;
  107021. /**
  107022. * Instantiates a UtilityLayerRenderer
  107023. * @param originalScene the original scene that will be rendered on top of
  107024. * @param handleEvents boolean indicating if the utility layer should handle events
  107025. */
  107026. constructor(
  107027. /** the original scene that will be rendered on top of */
  107028. originalScene: Scene, handleEvents?: boolean);
  107029. private _notifyObservers;
  107030. /**
  107031. * Renders the utility layers scene on top of the original scene
  107032. */
  107033. render(): void;
  107034. /**
  107035. * Disposes of the renderer
  107036. */
  107037. dispose(): void;
  107038. private _updateCamera;
  107039. }
  107040. }
  107041. declare module BABYLON {
  107042. /**
  107043. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107044. */
  107045. export class Gizmo implements IDisposable {
  107046. /** The utility layer the gizmo will be added to */
  107047. gizmoLayer: UtilityLayerRenderer;
  107048. /**
  107049. * The root mesh of the gizmo
  107050. */
  107051. _rootMesh: Mesh;
  107052. private _attachedMesh;
  107053. /**
  107054. * Ratio for the scale of the gizmo (Default: 1)
  107055. */
  107056. scaleRatio: number;
  107057. /**
  107058. * If a custom mesh has been set (Default: false)
  107059. */
  107060. protected _customMeshSet: boolean;
  107061. /**
  107062. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107063. * * When set, interactions will be enabled
  107064. */
  107065. attachedMesh: Nullable<AbstractMesh>;
  107066. /**
  107067. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107068. * @param mesh The mesh to replace the default mesh of the gizmo
  107069. */
  107070. setCustomMesh(mesh: Mesh): void;
  107071. /**
  107072. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107073. */
  107074. updateGizmoRotationToMatchAttachedMesh: boolean;
  107075. /**
  107076. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107077. */
  107078. updateGizmoPositionToMatchAttachedMesh: boolean;
  107079. /**
  107080. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107081. */
  107082. updateScale: boolean;
  107083. protected _interactionsEnabled: boolean;
  107084. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107085. private _beforeRenderObserver;
  107086. private _tempVector;
  107087. /**
  107088. * Creates a gizmo
  107089. * @param gizmoLayer The utility layer the gizmo will be added to
  107090. */
  107091. constructor(
  107092. /** The utility layer the gizmo will be added to */
  107093. gizmoLayer?: UtilityLayerRenderer);
  107094. /**
  107095. * Updates the gizmo to match the attached mesh's position/rotation
  107096. */
  107097. protected _update(): void;
  107098. /**
  107099. * Disposes of the gizmo
  107100. */
  107101. dispose(): void;
  107102. }
  107103. }
  107104. declare module BABYLON {
  107105. /**
  107106. * Single plane drag gizmo
  107107. */
  107108. export class PlaneDragGizmo extends Gizmo {
  107109. /**
  107110. * Drag behavior responsible for the gizmos dragging interactions
  107111. */
  107112. dragBehavior: PointerDragBehavior;
  107113. private _pointerObserver;
  107114. /**
  107115. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107116. */
  107117. snapDistance: number;
  107118. /**
  107119. * Event that fires each time the gizmo snaps to a new location.
  107120. * * snapDistance is the the change in distance
  107121. */
  107122. onSnapObservable: Observable<{
  107123. snapDistance: number;
  107124. }>;
  107125. private _plane;
  107126. private _coloredMaterial;
  107127. private _hoverMaterial;
  107128. private _isEnabled;
  107129. private _parent;
  107130. /** @hidden */
  107131. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107132. /** @hidden */
  107133. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107134. /**
  107135. * Creates a PlaneDragGizmo
  107136. * @param gizmoLayer The utility layer the gizmo will be added to
  107137. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107138. * @param color The color of the gizmo
  107139. */
  107140. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107141. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107142. /**
  107143. * If the gizmo is enabled
  107144. */
  107145. isEnabled: boolean;
  107146. /**
  107147. * Disposes of the gizmo
  107148. */
  107149. dispose(): void;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /**
  107154. * Gizmo that enables dragging a mesh along 3 axis
  107155. */
  107156. export class PositionGizmo extends Gizmo {
  107157. /**
  107158. * Internal gizmo used for interactions on the x axis
  107159. */
  107160. xGizmo: AxisDragGizmo;
  107161. /**
  107162. * Internal gizmo used for interactions on the y axis
  107163. */
  107164. yGizmo: AxisDragGizmo;
  107165. /**
  107166. * Internal gizmo used for interactions on the z axis
  107167. */
  107168. zGizmo: AxisDragGizmo;
  107169. /**
  107170. * Internal gizmo used for interactions on the yz plane
  107171. */
  107172. xPlaneGizmo: PlaneDragGizmo;
  107173. /**
  107174. * Internal gizmo used for interactions on the xz plane
  107175. */
  107176. yPlaneGizmo: PlaneDragGizmo;
  107177. /**
  107178. * Internal gizmo used for interactions on the xy plane
  107179. */
  107180. zPlaneGizmo: PlaneDragGizmo;
  107181. /**
  107182. * private variables
  107183. */
  107184. private _meshAttached;
  107185. private _updateGizmoRotationToMatchAttachedMesh;
  107186. private _snapDistance;
  107187. private _scaleRatio;
  107188. /** Fires an event when any of it's sub gizmos are dragged */
  107189. onDragStartObservable: Observable<unknown>;
  107190. /** Fires an event when any of it's sub gizmos are released from dragging */
  107191. onDragEndObservable: Observable<unknown>;
  107192. /**
  107193. * If set to true, planar drag is enabled
  107194. */
  107195. private _planarGizmoEnabled;
  107196. attachedMesh: Nullable<AbstractMesh>;
  107197. /**
  107198. * Creates a PositionGizmo
  107199. * @param gizmoLayer The utility layer the gizmo will be added to
  107200. */
  107201. constructor(gizmoLayer?: UtilityLayerRenderer);
  107202. /**
  107203. * If the planar drag gizmo is enabled
  107204. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107205. */
  107206. planarGizmoEnabled: boolean;
  107207. updateGizmoRotationToMatchAttachedMesh: boolean;
  107208. /**
  107209. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107210. */
  107211. snapDistance: number;
  107212. /**
  107213. * Ratio for the scale of the gizmo (Default: 1)
  107214. */
  107215. scaleRatio: number;
  107216. /**
  107217. * Disposes of the gizmo
  107218. */
  107219. dispose(): void;
  107220. /**
  107221. * CustomMeshes are not supported by this gizmo
  107222. * @param mesh The mesh to replace the default mesh of the gizmo
  107223. */
  107224. setCustomMesh(mesh: Mesh): void;
  107225. }
  107226. }
  107227. declare module BABYLON {
  107228. /**
  107229. * Single axis drag gizmo
  107230. */
  107231. export class AxisDragGizmo extends Gizmo {
  107232. /**
  107233. * Drag behavior responsible for the gizmos dragging interactions
  107234. */
  107235. dragBehavior: PointerDragBehavior;
  107236. private _pointerObserver;
  107237. /**
  107238. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107239. */
  107240. snapDistance: number;
  107241. /**
  107242. * Event that fires each time the gizmo snaps to a new location.
  107243. * * snapDistance is the the change in distance
  107244. */
  107245. onSnapObservable: Observable<{
  107246. snapDistance: number;
  107247. }>;
  107248. private _isEnabled;
  107249. private _parent;
  107250. private _arrow;
  107251. private _coloredMaterial;
  107252. private _hoverMaterial;
  107253. /** @hidden */
  107254. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107255. /** @hidden */
  107256. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107257. /**
  107258. * Creates an AxisDragGizmo
  107259. * @param gizmoLayer The utility layer the gizmo will be added to
  107260. * @param dragAxis The axis which the gizmo will be able to drag on
  107261. * @param color The color of the gizmo
  107262. */
  107263. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107264. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107265. /**
  107266. * If the gizmo is enabled
  107267. */
  107268. isEnabled: boolean;
  107269. /**
  107270. * Disposes of the gizmo
  107271. */
  107272. dispose(): void;
  107273. }
  107274. }
  107275. declare module BABYLON.Debug {
  107276. /**
  107277. * The Axes viewer will show 3 axes in a specific point in space
  107278. */
  107279. export class AxesViewer {
  107280. private _xAxis;
  107281. private _yAxis;
  107282. private _zAxis;
  107283. private _scaleLinesFactor;
  107284. private _instanced;
  107285. /**
  107286. * Gets the hosting scene
  107287. */
  107288. scene: Scene;
  107289. /**
  107290. * Gets or sets a number used to scale line length
  107291. */
  107292. scaleLines: number;
  107293. /** Gets the node hierarchy used to render x-axis */
  107294. readonly xAxis: TransformNode;
  107295. /** Gets the node hierarchy used to render y-axis */
  107296. readonly yAxis: TransformNode;
  107297. /** Gets the node hierarchy used to render z-axis */
  107298. readonly zAxis: TransformNode;
  107299. /**
  107300. * Creates a new AxesViewer
  107301. * @param scene defines the hosting scene
  107302. * @param scaleLines defines a number used to scale line length (1 by default)
  107303. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107304. * @param xAxis defines the node hierarchy used to render the x-axis
  107305. * @param yAxis defines the node hierarchy used to render the y-axis
  107306. * @param zAxis defines the node hierarchy used to render the z-axis
  107307. */
  107308. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107309. /**
  107310. * Force the viewer to update
  107311. * @param position defines the position of the viewer
  107312. * @param xaxis defines the x axis of the viewer
  107313. * @param yaxis defines the y axis of the viewer
  107314. * @param zaxis defines the z axis of the viewer
  107315. */
  107316. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107317. /**
  107318. * Creates an instance of this axes viewer.
  107319. * @returns a new axes viewer with instanced meshes
  107320. */
  107321. createInstance(): AxesViewer;
  107322. /** Releases resources */
  107323. dispose(): void;
  107324. private static _SetRenderingGroupId;
  107325. }
  107326. }
  107327. declare module BABYLON.Debug {
  107328. /**
  107329. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107330. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107331. */
  107332. export class BoneAxesViewer extends AxesViewer {
  107333. /**
  107334. * Gets or sets the target mesh where to display the axes viewer
  107335. */
  107336. mesh: Nullable<Mesh>;
  107337. /**
  107338. * Gets or sets the target bone where to display the axes viewer
  107339. */
  107340. bone: Nullable<Bone>;
  107341. /** Gets current position */
  107342. pos: Vector3;
  107343. /** Gets direction of X axis */
  107344. xaxis: Vector3;
  107345. /** Gets direction of Y axis */
  107346. yaxis: Vector3;
  107347. /** Gets direction of Z axis */
  107348. zaxis: Vector3;
  107349. /**
  107350. * Creates a new BoneAxesViewer
  107351. * @param scene defines the hosting scene
  107352. * @param bone defines the target bone
  107353. * @param mesh defines the target mesh
  107354. * @param scaleLines defines a scaling factor for line length (1 by default)
  107355. */
  107356. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107357. /**
  107358. * Force the viewer to update
  107359. */
  107360. update(): void;
  107361. /** Releases resources */
  107362. dispose(): void;
  107363. }
  107364. }
  107365. declare module BABYLON {
  107366. /**
  107367. * Interface used to define scene explorer extensibility option
  107368. */
  107369. export interface IExplorerExtensibilityOption {
  107370. /**
  107371. * Define the option label
  107372. */
  107373. label: string;
  107374. /**
  107375. * Defines the action to execute on click
  107376. */
  107377. action: (entity: any) => void;
  107378. }
  107379. /**
  107380. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107381. */
  107382. export interface IExplorerExtensibilityGroup {
  107383. /**
  107384. * Defines a predicate to test if a given type mut be extended
  107385. */
  107386. predicate: (entity: any) => boolean;
  107387. /**
  107388. * Gets the list of options added to a type
  107389. */
  107390. entries: IExplorerExtensibilityOption[];
  107391. }
  107392. /**
  107393. * Interface used to define the options to use to create the Inspector
  107394. */
  107395. export interface IInspectorOptions {
  107396. /**
  107397. * Display in overlay mode (default: false)
  107398. */
  107399. overlay?: boolean;
  107400. /**
  107401. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107402. */
  107403. globalRoot?: HTMLElement;
  107404. /**
  107405. * Display the Scene explorer
  107406. */
  107407. showExplorer?: boolean;
  107408. /**
  107409. * Display the property inspector
  107410. */
  107411. showInspector?: boolean;
  107412. /**
  107413. * Display in embed mode (both panes on the right)
  107414. */
  107415. embedMode?: boolean;
  107416. /**
  107417. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107418. */
  107419. handleResize?: boolean;
  107420. /**
  107421. * Allow the panes to popup (default: true)
  107422. */
  107423. enablePopup?: boolean;
  107424. /**
  107425. * Allow the panes to be closed by users (default: true)
  107426. */
  107427. enableClose?: boolean;
  107428. /**
  107429. * Optional list of extensibility entries
  107430. */
  107431. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107432. /**
  107433. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107434. */
  107435. inspectorURL?: string;
  107436. }
  107437. interface Scene {
  107438. /**
  107439. * @hidden
  107440. * Backing field
  107441. */
  107442. _debugLayer: DebugLayer;
  107443. /**
  107444. * Gets the debug layer (aka Inspector) associated with the scene
  107445. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107446. */
  107447. debugLayer: DebugLayer;
  107448. }
  107449. /**
  107450. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107451. * what is happening in your scene
  107452. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107453. */
  107454. export class DebugLayer {
  107455. /**
  107456. * Define the url to get the inspector script from.
  107457. * By default it uses the babylonjs CDN.
  107458. * @ignoreNaming
  107459. */
  107460. static InspectorURL: string;
  107461. private _scene;
  107462. private BJSINSPECTOR;
  107463. private _onPropertyChangedObservable?;
  107464. /**
  107465. * Observable triggered when a property is changed through the inspector.
  107466. */
  107467. readonly onPropertyChangedObservable: any;
  107468. /**
  107469. * Instantiates a new debug layer.
  107470. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107471. * what is happening in your scene
  107472. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107473. * @param scene Defines the scene to inspect
  107474. */
  107475. constructor(scene: Scene);
  107476. /** Creates the inspector window. */
  107477. private _createInspector;
  107478. /**
  107479. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107480. * @param entity defines the entity to select
  107481. * @param lineContainerTitle defines the specific block to highlight
  107482. */
  107483. select(entity: any, lineContainerTitle?: string): void;
  107484. /** Get the inspector from bundle or global */
  107485. private _getGlobalInspector;
  107486. /**
  107487. * Get if the inspector is visible or not.
  107488. * @returns true if visible otherwise, false
  107489. */
  107490. isVisible(): boolean;
  107491. /**
  107492. * Hide the inspector and close its window.
  107493. */
  107494. hide(): void;
  107495. /**
  107496. * Launch the debugLayer.
  107497. * @param config Define the configuration of the inspector
  107498. * @return a promise fulfilled when the debug layer is visible
  107499. */
  107500. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107501. }
  107502. }
  107503. declare module BABYLON {
  107504. /**
  107505. * Class containing static functions to help procedurally build meshes
  107506. */
  107507. export class BoxBuilder {
  107508. /**
  107509. * Creates a box mesh
  107510. * * The parameter `size` sets the size (float) of each box side (default 1)
  107511. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107512. * * 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)
  107513. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107517. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107518. * @param name defines the name of the mesh
  107519. * @param options defines the options used to create the mesh
  107520. * @param scene defines the hosting scene
  107521. * @returns the box mesh
  107522. */
  107523. static CreateBox(name: string, options: {
  107524. size?: number;
  107525. width?: number;
  107526. height?: number;
  107527. depth?: number;
  107528. faceUV?: Vector4[];
  107529. faceColors?: Color4[];
  107530. sideOrientation?: number;
  107531. frontUVs?: Vector4;
  107532. backUVs?: Vector4;
  107533. wrap?: boolean;
  107534. topBaseAt?: number;
  107535. bottomBaseAt?: number;
  107536. updatable?: boolean;
  107537. }, scene?: Nullable<Scene>): Mesh;
  107538. }
  107539. }
  107540. declare module BABYLON {
  107541. /**
  107542. * Class containing static functions to help procedurally build meshes
  107543. */
  107544. export class SphereBuilder {
  107545. /**
  107546. * Creates a sphere mesh
  107547. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107548. * * 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`)
  107549. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107550. * * 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
  107551. * * 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)
  107552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107555. * @param name defines the name of the mesh
  107556. * @param options defines the options used to create the mesh
  107557. * @param scene defines the hosting scene
  107558. * @returns the sphere mesh
  107559. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107560. */
  107561. static CreateSphere(name: string, options: {
  107562. segments?: number;
  107563. diameter?: number;
  107564. diameterX?: number;
  107565. diameterY?: number;
  107566. diameterZ?: number;
  107567. arc?: number;
  107568. slice?: number;
  107569. sideOrientation?: number;
  107570. frontUVs?: Vector4;
  107571. backUVs?: Vector4;
  107572. updatable?: boolean;
  107573. }, scene: any): Mesh;
  107574. }
  107575. }
  107576. declare module BABYLON.Debug {
  107577. /**
  107578. * Used to show the physics impostor around the specific mesh
  107579. */
  107580. export class PhysicsViewer {
  107581. /** @hidden */
  107582. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107583. /** @hidden */
  107584. protected _meshes: Array<Nullable<AbstractMesh>>;
  107585. /** @hidden */
  107586. protected _scene: Nullable<Scene>;
  107587. /** @hidden */
  107588. protected _numMeshes: number;
  107589. /** @hidden */
  107590. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107591. private _renderFunction;
  107592. private _utilityLayer;
  107593. private _debugBoxMesh;
  107594. private _debugSphereMesh;
  107595. private _debugCylinderMesh;
  107596. private _debugMaterial;
  107597. private _debugMeshMeshes;
  107598. /**
  107599. * Creates a new PhysicsViewer
  107600. * @param scene defines the hosting scene
  107601. */
  107602. constructor(scene: Scene);
  107603. /** @hidden */
  107604. protected _updateDebugMeshes(): void;
  107605. /**
  107606. * Renders a specified physic impostor
  107607. * @param impostor defines the impostor to render
  107608. * @param targetMesh defines the mesh represented by the impostor
  107609. * @returns the new debug mesh used to render the impostor
  107610. */
  107611. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107612. /**
  107613. * Hides a specified physic impostor
  107614. * @param impostor defines the impostor to hide
  107615. */
  107616. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107617. private _getDebugMaterial;
  107618. private _getDebugBoxMesh;
  107619. private _getDebugSphereMesh;
  107620. private _getDebugCylinderMesh;
  107621. private _getDebugMeshMesh;
  107622. private _getDebugMesh;
  107623. /** Releases all resources */
  107624. dispose(): void;
  107625. }
  107626. }
  107627. declare module BABYLON {
  107628. /**
  107629. * Class containing static functions to help procedurally build meshes
  107630. */
  107631. export class LinesBuilder {
  107632. /**
  107633. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107634. * * 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
  107635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107636. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107637. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107638. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107639. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107640. * * 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
  107641. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107644. * @param name defines the name of the new line system
  107645. * @param options defines the options used to create the line system
  107646. * @param scene defines the hosting scene
  107647. * @returns a new line system mesh
  107648. */
  107649. static CreateLineSystem(name: string, options: {
  107650. lines: Vector3[][];
  107651. updatable?: boolean;
  107652. instance?: Nullable<LinesMesh>;
  107653. colors?: Nullable<Color4[][]>;
  107654. useVertexAlpha?: boolean;
  107655. }, scene: Nullable<Scene>): LinesMesh;
  107656. /**
  107657. * Creates a line mesh
  107658. * 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
  107659. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107660. * * The parameter `points` is an array successive Vector3
  107661. * * 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
  107662. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107663. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107664. * * When updating an instance, remember that only point positions can change, not the number of points
  107665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107667. * @param name defines the name of the new line system
  107668. * @param options defines the options used to create the line system
  107669. * @param scene defines the hosting scene
  107670. * @returns a new line mesh
  107671. */
  107672. static CreateLines(name: string, options: {
  107673. points: Vector3[];
  107674. updatable?: boolean;
  107675. instance?: Nullable<LinesMesh>;
  107676. colors?: Color4[];
  107677. useVertexAlpha?: boolean;
  107678. }, scene?: Nullable<Scene>): LinesMesh;
  107679. /**
  107680. * Creates a dashed line mesh
  107681. * * 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
  107682. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107683. * * The parameter `points` is an array successive Vector3
  107684. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107685. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107686. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107687. * * 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
  107688. * * When updating an instance, remember that only point positions can change, not the number of points
  107689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107690. * @param name defines the name of the mesh
  107691. * @param options defines the options used to create the mesh
  107692. * @param scene defines the hosting scene
  107693. * @returns the dashed line mesh
  107694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107695. */
  107696. static CreateDashedLines(name: string, options: {
  107697. points: Vector3[];
  107698. dashSize?: number;
  107699. gapSize?: number;
  107700. dashNb?: number;
  107701. updatable?: boolean;
  107702. instance?: LinesMesh;
  107703. }, scene?: Nullable<Scene>): LinesMesh;
  107704. }
  107705. }
  107706. declare module BABYLON {
  107707. /**
  107708. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107709. * in order to better appreciate the issue one might have.
  107710. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107711. */
  107712. export class RayHelper {
  107713. /**
  107714. * Defines the ray we are currently tryin to visualize.
  107715. */
  107716. ray: Nullable<Ray>;
  107717. private _renderPoints;
  107718. private _renderLine;
  107719. private _renderFunction;
  107720. private _scene;
  107721. private _updateToMeshFunction;
  107722. private _attachedToMesh;
  107723. private _meshSpaceDirection;
  107724. private _meshSpaceOrigin;
  107725. /**
  107726. * Helper function to create a colored helper in a scene in one line.
  107727. * @param ray Defines the ray we are currently tryin to visualize
  107728. * @param scene Defines the scene the ray is used in
  107729. * @param color Defines the color we want to see the ray in
  107730. * @returns The newly created ray helper.
  107731. */
  107732. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107733. /**
  107734. * Instantiate a new ray helper.
  107735. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107736. * in order to better appreciate the issue one might have.
  107737. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107738. * @param ray Defines the ray we are currently tryin to visualize
  107739. */
  107740. constructor(ray: Ray);
  107741. /**
  107742. * Shows the ray we are willing to debug.
  107743. * @param scene Defines the scene the ray needs to be rendered in
  107744. * @param color Defines the color the ray needs to be rendered in
  107745. */
  107746. show(scene: Scene, color?: Color3): void;
  107747. /**
  107748. * Hides the ray we are debugging.
  107749. */
  107750. hide(): void;
  107751. private _render;
  107752. /**
  107753. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107754. * @param mesh Defines the mesh we want the helper attached to
  107755. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107756. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107757. * @param length Defines the length of the ray
  107758. */
  107759. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107760. /**
  107761. * Detach the ray helper from the mesh it has previously been attached to.
  107762. */
  107763. detachFromMesh(): void;
  107764. private _updateToMesh;
  107765. /**
  107766. * Dispose the helper and release its associated resources.
  107767. */
  107768. dispose(): void;
  107769. }
  107770. }
  107771. declare module BABYLON.Debug {
  107772. /**
  107773. * Class used to render a debug view of a given skeleton
  107774. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107775. */
  107776. export class SkeletonViewer {
  107777. /** defines the skeleton to render */
  107778. skeleton: Skeleton;
  107779. /** defines the mesh attached to the skeleton */
  107780. mesh: AbstractMesh;
  107781. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107782. autoUpdateBonesMatrices: boolean;
  107783. /** defines the rendering group id to use with the viewer */
  107784. renderingGroupId: number;
  107785. /** Gets or sets the color used to render the skeleton */
  107786. color: Color3;
  107787. private _scene;
  107788. private _debugLines;
  107789. private _debugMesh;
  107790. private _isEnabled;
  107791. private _renderFunction;
  107792. private _utilityLayer;
  107793. /**
  107794. * Returns the mesh used to render the bones
  107795. */
  107796. readonly debugMesh: Nullable<LinesMesh>;
  107797. /**
  107798. * Creates a new SkeletonViewer
  107799. * @param skeleton defines the skeleton to render
  107800. * @param mesh defines the mesh attached to the skeleton
  107801. * @param scene defines the hosting scene
  107802. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107803. * @param renderingGroupId defines the rendering group id to use with the viewer
  107804. */
  107805. constructor(
  107806. /** defines the skeleton to render */
  107807. skeleton: Skeleton,
  107808. /** defines the mesh attached to the skeleton */
  107809. mesh: AbstractMesh, scene: Scene,
  107810. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107811. autoUpdateBonesMatrices?: boolean,
  107812. /** defines the rendering group id to use with the viewer */
  107813. renderingGroupId?: number);
  107814. /** Gets or sets a boolean indicating if the viewer is enabled */
  107815. isEnabled: boolean;
  107816. private _getBonePosition;
  107817. private _getLinesForBonesWithLength;
  107818. private _getLinesForBonesNoLength;
  107819. /** Update the viewer to sync with current skeleton state */
  107820. update(): void;
  107821. /** Release associated resources */
  107822. dispose(): void;
  107823. }
  107824. }
  107825. declare module BABYLON {
  107826. /**
  107827. * Options to create the null engine
  107828. */
  107829. export class NullEngineOptions {
  107830. /**
  107831. * Render width (Default: 512)
  107832. */
  107833. renderWidth: number;
  107834. /**
  107835. * Render height (Default: 256)
  107836. */
  107837. renderHeight: number;
  107838. /**
  107839. * Texture size (Default: 512)
  107840. */
  107841. textureSize: number;
  107842. /**
  107843. * If delta time between frames should be constant
  107844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107845. */
  107846. deterministicLockstep: boolean;
  107847. /**
  107848. * Maximum about of steps between frames (Default: 4)
  107849. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107850. */
  107851. lockstepMaxSteps: number;
  107852. }
  107853. /**
  107854. * The null engine class provides support for headless version of babylon.js.
  107855. * This can be used in server side scenario or for testing purposes
  107856. */
  107857. export class NullEngine extends Engine {
  107858. private _options;
  107859. /**
  107860. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107861. */
  107862. isDeterministicLockStep(): boolean;
  107863. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107864. getLockstepMaxSteps(): number;
  107865. /**
  107866. * Sets hardware scaling, used to save performance if needed
  107867. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107868. */
  107869. getHardwareScalingLevel(): number;
  107870. constructor(options?: NullEngineOptions);
  107871. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107872. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107873. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107874. getRenderWidth(useScreen?: boolean): number;
  107875. getRenderHeight(useScreen?: boolean): number;
  107876. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107877. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107878. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107879. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107880. bindSamplers(effect: Effect): void;
  107881. enableEffect(effect: Effect): void;
  107882. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107883. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107884. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107885. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107886. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107887. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107888. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107889. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107890. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107891. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107892. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107893. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107894. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107895. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107896. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107897. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107898. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107899. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107900. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107901. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107902. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107903. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107904. bindBuffers(vertexBuffers: {
  107905. [key: string]: VertexBuffer;
  107906. }, indexBuffer: DataBuffer, effect: Effect): void;
  107907. wipeCaches(bruteForce?: boolean): void;
  107908. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107909. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107910. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107911. /** @hidden */
  107912. _createTexture(): WebGLTexture;
  107913. /** @hidden */
  107914. _releaseTexture(texture: InternalTexture): void;
  107915. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  107916. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107917. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107919. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107920. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107921. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107922. areAllEffectsReady(): boolean;
  107923. /**
  107924. * @hidden
  107925. * Get the current error code of the webGL context
  107926. * @returns the error code
  107927. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107928. */
  107929. getError(): number;
  107930. /** @hidden */
  107931. _getUnpackAlignement(): number;
  107932. /** @hidden */
  107933. _unpackFlipY(value: boolean): void;
  107934. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107935. /**
  107936. * Updates a dynamic vertex buffer.
  107937. * @param vertexBuffer the vertex buffer to update
  107938. * @param data the data used to update the vertex buffer
  107939. * @param byteOffset the byte offset of the data (optional)
  107940. * @param byteLength the byte length of the data (optional)
  107941. */
  107942. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107943. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107944. /** @hidden */
  107945. _bindTexture(channel: number, texture: InternalTexture): void;
  107946. /** @hidden */
  107947. _releaseBuffer(buffer: DataBuffer): boolean;
  107948. releaseEffects(): void;
  107949. displayLoadingUI(): void;
  107950. hideLoadingUI(): void;
  107951. /** @hidden */
  107952. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107953. /** @hidden */
  107954. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107955. /** @hidden */
  107956. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107957. /** @hidden */
  107958. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107959. }
  107960. }
  107961. declare module BABYLON {
  107962. /** @hidden */
  107963. export class _OcclusionDataStorage {
  107964. /** @hidden */
  107965. occlusionInternalRetryCounter: number;
  107966. /** @hidden */
  107967. isOcclusionQueryInProgress: boolean;
  107968. /** @hidden */
  107969. isOccluded: boolean;
  107970. /** @hidden */
  107971. occlusionRetryCount: number;
  107972. /** @hidden */
  107973. occlusionType: number;
  107974. /** @hidden */
  107975. occlusionQueryAlgorithmType: number;
  107976. }
  107977. interface Engine {
  107978. /**
  107979. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107980. * @return the new query
  107981. */
  107982. createQuery(): WebGLQuery;
  107983. /**
  107984. * Delete and release a webGL query
  107985. * @param query defines the query to delete
  107986. * @return the current engine
  107987. */
  107988. deleteQuery(query: WebGLQuery): Engine;
  107989. /**
  107990. * Check if a given query has resolved and got its value
  107991. * @param query defines the query to check
  107992. * @returns true if the query got its value
  107993. */
  107994. isQueryResultAvailable(query: WebGLQuery): boolean;
  107995. /**
  107996. * Gets the value of a given query
  107997. * @param query defines the query to check
  107998. * @returns the value of the query
  107999. */
  108000. getQueryResult(query: WebGLQuery): number;
  108001. /**
  108002. * Initiates an occlusion query
  108003. * @param algorithmType defines the algorithm to use
  108004. * @param query defines the query to use
  108005. * @returns the current engine
  108006. * @see http://doc.babylonjs.com/features/occlusionquery
  108007. */
  108008. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108009. /**
  108010. * Ends an occlusion query
  108011. * @see http://doc.babylonjs.com/features/occlusionquery
  108012. * @param algorithmType defines the algorithm to use
  108013. * @returns the current engine
  108014. */
  108015. endOcclusionQuery(algorithmType: number): Engine;
  108016. /**
  108017. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108018. * Please note that only one query can be issued at a time
  108019. * @returns a time token used to track the time span
  108020. */
  108021. startTimeQuery(): Nullable<_TimeToken>;
  108022. /**
  108023. * Ends a time query
  108024. * @param token defines the token used to measure the time span
  108025. * @returns the time spent (in ns)
  108026. */
  108027. endTimeQuery(token: _TimeToken): int;
  108028. /** @hidden */
  108029. _currentNonTimestampToken: Nullable<_TimeToken>;
  108030. /** @hidden */
  108031. _createTimeQuery(): WebGLQuery;
  108032. /** @hidden */
  108033. _deleteTimeQuery(query: WebGLQuery): void;
  108034. /** @hidden */
  108035. _getGlAlgorithmType(algorithmType: number): number;
  108036. /** @hidden */
  108037. _getTimeQueryResult(query: WebGLQuery): any;
  108038. /** @hidden */
  108039. _getTimeQueryAvailability(query: WebGLQuery): any;
  108040. }
  108041. interface AbstractMesh {
  108042. /**
  108043. * Backing filed
  108044. * @hidden
  108045. */
  108046. __occlusionDataStorage: _OcclusionDataStorage;
  108047. /**
  108048. * Access property
  108049. * @hidden
  108050. */
  108051. _occlusionDataStorage: _OcclusionDataStorage;
  108052. /**
  108053. * 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.
  108054. * The default value is -1 which means don't break the query and wait till the result
  108055. * @see http://doc.babylonjs.com/features/occlusionquery
  108056. */
  108057. occlusionRetryCount: number;
  108058. /**
  108059. * 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:
  108060. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108061. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108062. * * 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.
  108063. * @see http://doc.babylonjs.com/features/occlusionquery
  108064. */
  108065. occlusionType: number;
  108066. /**
  108067. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108068. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108069. * * 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.
  108070. * @see http://doc.babylonjs.com/features/occlusionquery
  108071. */
  108072. occlusionQueryAlgorithmType: number;
  108073. /**
  108074. * 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
  108075. * @see http://doc.babylonjs.com/features/occlusionquery
  108076. */
  108077. isOccluded: boolean;
  108078. /**
  108079. * Flag to check the progress status of the query
  108080. * @see http://doc.babylonjs.com/features/occlusionquery
  108081. */
  108082. isOcclusionQueryInProgress: boolean;
  108083. }
  108084. }
  108085. declare module BABYLON {
  108086. /** @hidden */
  108087. export var _forceTransformFeedbackToBundle: boolean;
  108088. interface Engine {
  108089. /**
  108090. * Creates a webGL transform feedback object
  108091. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108092. * @returns the webGL transform feedback object
  108093. */
  108094. createTransformFeedback(): WebGLTransformFeedback;
  108095. /**
  108096. * Delete a webGL transform feedback object
  108097. * @param value defines the webGL transform feedback object to delete
  108098. */
  108099. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108100. /**
  108101. * Bind a webGL transform feedback object to the webgl context
  108102. * @param value defines the webGL transform feedback object to bind
  108103. */
  108104. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108105. /**
  108106. * Begins a transform feedback operation
  108107. * @param usePoints defines if points or triangles must be used
  108108. */
  108109. beginTransformFeedback(usePoints: boolean): void;
  108110. /**
  108111. * Ends a transform feedback operation
  108112. */
  108113. endTransformFeedback(): void;
  108114. /**
  108115. * Specify the varyings to use with transform feedback
  108116. * @param program defines the associated webGL program
  108117. * @param value defines the list of strings representing the varying names
  108118. */
  108119. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108120. /**
  108121. * Bind a webGL buffer for a transform feedback operation
  108122. * @param value defines the webGL buffer to bind
  108123. */
  108124. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108125. }
  108126. }
  108127. declare module BABYLON {
  108128. /**
  108129. * Creation options of the multi render target texture.
  108130. */
  108131. export interface IMultiRenderTargetOptions {
  108132. /**
  108133. * Define if the texture needs to create mip maps after render.
  108134. */
  108135. generateMipMaps?: boolean;
  108136. /**
  108137. * Define the types of all the draw buffers we want to create
  108138. */
  108139. types?: number[];
  108140. /**
  108141. * Define the sampling modes of all the draw buffers we want to create
  108142. */
  108143. samplingModes?: number[];
  108144. /**
  108145. * Define if a depth buffer is required
  108146. */
  108147. generateDepthBuffer?: boolean;
  108148. /**
  108149. * Define if a stencil buffer is required
  108150. */
  108151. generateStencilBuffer?: boolean;
  108152. /**
  108153. * Define if a depth texture is required instead of a depth buffer
  108154. */
  108155. generateDepthTexture?: boolean;
  108156. /**
  108157. * Define the number of desired draw buffers
  108158. */
  108159. textureCount?: number;
  108160. /**
  108161. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108162. */
  108163. doNotChangeAspectRatio?: boolean;
  108164. /**
  108165. * Define the default type of the buffers we are creating
  108166. */
  108167. defaultType?: number;
  108168. }
  108169. /**
  108170. * A multi render target, like a render target provides the ability to render to a texture.
  108171. * Unlike the render target, it can render to several draw buffers in one draw.
  108172. * This is specially interesting in deferred rendering or for any effects requiring more than
  108173. * just one color from a single pass.
  108174. */
  108175. export class MultiRenderTarget extends RenderTargetTexture {
  108176. private _internalTextures;
  108177. private _textures;
  108178. private _multiRenderTargetOptions;
  108179. /**
  108180. * Get if draw buffers are currently supported by the used hardware and browser.
  108181. */
  108182. readonly isSupported: boolean;
  108183. /**
  108184. * Get the list of textures generated by the multi render target.
  108185. */
  108186. readonly textures: Texture[];
  108187. /**
  108188. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108189. */
  108190. readonly depthTexture: Texture;
  108191. /**
  108192. * Set the wrapping mode on U of all the textures we are rendering to.
  108193. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108194. */
  108195. wrapU: number;
  108196. /**
  108197. * Set the wrapping mode on V of all the textures we are rendering to.
  108198. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108199. */
  108200. wrapV: number;
  108201. /**
  108202. * Instantiate a new multi render target texture.
  108203. * A multi render target, like a render target provides the ability to render to a texture.
  108204. * Unlike the render target, it can render to several draw buffers in one draw.
  108205. * This is specially interesting in deferred rendering or for any effects requiring more than
  108206. * just one color from a single pass.
  108207. * @param name Define the name of the texture
  108208. * @param size Define the size of the buffers to render to
  108209. * @param count Define the number of target we are rendering into
  108210. * @param scene Define the scene the texture belongs to
  108211. * @param options Define the options used to create the multi render target
  108212. */
  108213. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108214. /** @hidden */
  108215. _rebuild(): void;
  108216. private _createInternalTextures;
  108217. private _createTextures;
  108218. /**
  108219. * Define the number of samples used if MSAA is enabled.
  108220. */
  108221. samples: number;
  108222. /**
  108223. * Resize all the textures in the multi render target.
  108224. * Be carrefull as it will recreate all the data in the new texture.
  108225. * @param size Define the new size
  108226. */
  108227. resize(size: any): void;
  108228. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108229. /**
  108230. * Dispose the render targets and their associated resources
  108231. */
  108232. dispose(): void;
  108233. /**
  108234. * Release all the underlying texture used as draw buffers.
  108235. */
  108236. releaseInternalTextures(): void;
  108237. }
  108238. }
  108239. declare module BABYLON {
  108240. interface Engine {
  108241. /**
  108242. * Unbind a list of render target textures from the webGL context
  108243. * This is used only when drawBuffer extension or webGL2 are active
  108244. * @param textures defines the render target textures to unbind
  108245. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108246. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108247. */
  108248. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108249. /**
  108250. * Create a multi render target texture
  108251. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108252. * @param size defines the size of the texture
  108253. * @param options defines the creation options
  108254. * @returns the cube texture as an InternalTexture
  108255. */
  108256. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108257. /**
  108258. * Update the sample count for a given multiple render target texture
  108259. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108260. * @param textures defines the textures to update
  108261. * @param samples defines the sample count to set
  108262. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108263. */
  108264. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108265. }
  108266. }
  108267. declare module BABYLON {
  108268. /**
  108269. * Gather the list of clipboard event types as constants.
  108270. */
  108271. export class ClipboardEventTypes {
  108272. /**
  108273. * The clipboard event is fired when a copy command is active (pressed).
  108274. */
  108275. static readonly COPY: number;
  108276. /**
  108277. * The clipboard event is fired when a cut command is active (pressed).
  108278. */
  108279. static readonly CUT: number;
  108280. /**
  108281. * The clipboard event is fired when a paste command is active (pressed).
  108282. */
  108283. static readonly PASTE: number;
  108284. }
  108285. /**
  108286. * This class is used to store clipboard related info for the onClipboardObservable event.
  108287. */
  108288. export class ClipboardInfo {
  108289. /**
  108290. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108291. */
  108292. type: number;
  108293. /**
  108294. * Defines the related dom event
  108295. */
  108296. event: ClipboardEvent;
  108297. /**
  108298. *Creates an instance of ClipboardInfo.
  108299. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108300. * @param event Defines the related dom event
  108301. */
  108302. constructor(
  108303. /**
  108304. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108305. */
  108306. type: number,
  108307. /**
  108308. * Defines the related dom event
  108309. */
  108310. event: ClipboardEvent);
  108311. /**
  108312. * Get the clipboard event's type from the keycode.
  108313. * @param keyCode Defines the keyCode for the current keyboard event.
  108314. * @return {number}
  108315. */
  108316. static GetTypeFromCharacter(keyCode: number): number;
  108317. }
  108318. }
  108319. declare module BABYLON {
  108320. /**
  108321. * Google Daydream controller
  108322. */
  108323. export class DaydreamController extends WebVRController {
  108324. /**
  108325. * Base Url for the controller model.
  108326. */
  108327. static MODEL_BASE_URL: string;
  108328. /**
  108329. * File name for the controller model.
  108330. */
  108331. static MODEL_FILENAME: string;
  108332. /**
  108333. * Gamepad Id prefix used to identify Daydream Controller.
  108334. */
  108335. static readonly GAMEPAD_ID_PREFIX: string;
  108336. /**
  108337. * Creates a new DaydreamController from a gamepad
  108338. * @param vrGamepad the gamepad that the controller should be created from
  108339. */
  108340. constructor(vrGamepad: any);
  108341. /**
  108342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108343. * @param scene scene in which to add meshes
  108344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108345. */
  108346. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108347. /**
  108348. * Called once for each button that changed state since the last frame
  108349. * @param buttonIdx Which button index changed
  108350. * @param state New state of the button
  108351. * @param changes Which properties on the state changed since last frame
  108352. */
  108353. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108354. }
  108355. }
  108356. declare module BABYLON {
  108357. /**
  108358. * Gear VR Controller
  108359. */
  108360. export class GearVRController extends WebVRController {
  108361. /**
  108362. * Base Url for the controller model.
  108363. */
  108364. static MODEL_BASE_URL: string;
  108365. /**
  108366. * File name for the controller model.
  108367. */
  108368. static MODEL_FILENAME: string;
  108369. /**
  108370. * Gamepad Id prefix used to identify this controller.
  108371. */
  108372. static readonly GAMEPAD_ID_PREFIX: string;
  108373. private readonly _buttonIndexToObservableNameMap;
  108374. /**
  108375. * Creates a new GearVRController from a gamepad
  108376. * @param vrGamepad the gamepad that the controller should be created from
  108377. */
  108378. constructor(vrGamepad: any);
  108379. /**
  108380. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108381. * @param scene scene in which to add meshes
  108382. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108383. */
  108384. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108385. /**
  108386. * Called once for each button that changed state since the last frame
  108387. * @param buttonIdx Which button index changed
  108388. * @param state New state of the button
  108389. * @param changes Which properties on the state changed since last frame
  108390. */
  108391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108392. }
  108393. }
  108394. declare module BABYLON {
  108395. /**
  108396. * Class containing static functions to help procedurally build meshes
  108397. */
  108398. export class PolyhedronBuilder {
  108399. /**
  108400. * Creates a polyhedron mesh
  108401. * * 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
  108402. * * The parameter `size` (positive float, default 1) sets the polygon size
  108403. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108404. * * 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`
  108405. * * 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
  108406. * * 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)`)
  108407. * * 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
  108408. * * 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
  108409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108412. * @param name defines the name of the mesh
  108413. * @param options defines the options used to create the mesh
  108414. * @param scene defines the hosting scene
  108415. * @returns the polyhedron mesh
  108416. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108417. */
  108418. static CreatePolyhedron(name: string, options: {
  108419. type?: number;
  108420. size?: number;
  108421. sizeX?: number;
  108422. sizeY?: number;
  108423. sizeZ?: number;
  108424. custom?: any;
  108425. faceUV?: Vector4[];
  108426. faceColors?: Color4[];
  108427. flat?: boolean;
  108428. updatable?: boolean;
  108429. sideOrientation?: number;
  108430. frontUVs?: Vector4;
  108431. backUVs?: Vector4;
  108432. }, scene?: Nullable<Scene>): Mesh;
  108433. }
  108434. }
  108435. declare module BABYLON {
  108436. /**
  108437. * Gizmo that enables scaling a mesh along 3 axis
  108438. */
  108439. export class ScaleGizmo extends Gizmo {
  108440. /**
  108441. * Internal gizmo used for interactions on the x axis
  108442. */
  108443. xGizmo: AxisScaleGizmo;
  108444. /**
  108445. * Internal gizmo used for interactions on the y axis
  108446. */
  108447. yGizmo: AxisScaleGizmo;
  108448. /**
  108449. * Internal gizmo used for interactions on the z axis
  108450. */
  108451. zGizmo: AxisScaleGizmo;
  108452. /**
  108453. * Internal gizmo used to scale all axis equally
  108454. */
  108455. uniformScaleGizmo: AxisScaleGizmo;
  108456. private _meshAttached;
  108457. private _updateGizmoRotationToMatchAttachedMesh;
  108458. private _snapDistance;
  108459. private _scaleRatio;
  108460. private _uniformScalingMesh;
  108461. private _octahedron;
  108462. /** Fires an event when any of it's sub gizmos are dragged */
  108463. onDragStartObservable: Observable<unknown>;
  108464. /** Fires an event when any of it's sub gizmos are released from dragging */
  108465. onDragEndObservable: Observable<unknown>;
  108466. attachedMesh: Nullable<AbstractMesh>;
  108467. /**
  108468. * Creates a ScaleGizmo
  108469. * @param gizmoLayer The utility layer the gizmo will be added to
  108470. */
  108471. constructor(gizmoLayer?: UtilityLayerRenderer);
  108472. updateGizmoRotationToMatchAttachedMesh: boolean;
  108473. /**
  108474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108475. */
  108476. snapDistance: number;
  108477. /**
  108478. * Ratio for the scale of the gizmo (Default: 1)
  108479. */
  108480. scaleRatio: number;
  108481. /**
  108482. * Disposes of the gizmo
  108483. */
  108484. dispose(): void;
  108485. }
  108486. }
  108487. declare module BABYLON {
  108488. /**
  108489. * Single axis scale gizmo
  108490. */
  108491. export class AxisScaleGizmo extends Gizmo {
  108492. /**
  108493. * Drag behavior responsible for the gizmos dragging interactions
  108494. */
  108495. dragBehavior: PointerDragBehavior;
  108496. private _pointerObserver;
  108497. /**
  108498. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108499. */
  108500. snapDistance: number;
  108501. /**
  108502. * Event that fires each time the gizmo snaps to a new location.
  108503. * * snapDistance is the the change in distance
  108504. */
  108505. onSnapObservable: Observable<{
  108506. snapDistance: number;
  108507. }>;
  108508. /**
  108509. * If the scaling operation should be done on all axis (default: false)
  108510. */
  108511. uniformScaling: boolean;
  108512. private _isEnabled;
  108513. private _parent;
  108514. private _arrow;
  108515. private _coloredMaterial;
  108516. private _hoverMaterial;
  108517. /**
  108518. * Creates an AxisScaleGizmo
  108519. * @param gizmoLayer The utility layer the gizmo will be added to
  108520. * @param dragAxis The axis which the gizmo will be able to scale on
  108521. * @param color The color of the gizmo
  108522. */
  108523. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108525. /**
  108526. * If the gizmo is enabled
  108527. */
  108528. isEnabled: boolean;
  108529. /**
  108530. * Disposes of the gizmo
  108531. */
  108532. dispose(): void;
  108533. /**
  108534. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108535. * @param mesh The mesh to replace the default mesh of the gizmo
  108536. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108537. */
  108538. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * Bounding box gizmo
  108544. */
  108545. export class BoundingBoxGizmo extends Gizmo {
  108546. private _lineBoundingBox;
  108547. private _rotateSpheresParent;
  108548. private _scaleBoxesParent;
  108549. private _boundingDimensions;
  108550. private _renderObserver;
  108551. private _pointerObserver;
  108552. private _scaleDragSpeed;
  108553. private _tmpQuaternion;
  108554. private _tmpVector;
  108555. private _tmpRotationMatrix;
  108556. /**
  108557. * 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)
  108558. */
  108559. ignoreChildren: boolean;
  108560. /**
  108561. * 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)
  108562. */
  108563. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108564. /**
  108565. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108566. */
  108567. rotationSphereSize: number;
  108568. /**
  108569. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108570. */
  108571. scaleBoxSize: number;
  108572. /**
  108573. * 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)
  108574. */
  108575. fixedDragMeshScreenSize: boolean;
  108576. /**
  108577. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108578. */
  108579. fixedDragMeshScreenSizeDistanceFactor: number;
  108580. /**
  108581. * Fired when a rotation sphere or scale box is dragged
  108582. */
  108583. onDragStartObservable: Observable<{}>;
  108584. /**
  108585. * Fired when a scale box is dragged
  108586. */
  108587. onScaleBoxDragObservable: Observable<{}>;
  108588. /**
  108589. * Fired when a scale box drag is ended
  108590. */
  108591. onScaleBoxDragEndObservable: Observable<{}>;
  108592. /**
  108593. * Fired when a rotation sphere is dragged
  108594. */
  108595. onRotationSphereDragObservable: Observable<{}>;
  108596. /**
  108597. * Fired when a rotation sphere drag is ended
  108598. */
  108599. onRotationSphereDragEndObservable: Observable<{}>;
  108600. /**
  108601. * 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)
  108602. */
  108603. scalePivot: Nullable<Vector3>;
  108604. /**
  108605. * Mesh used as a pivot to rotate the attached mesh
  108606. */
  108607. private _anchorMesh;
  108608. private _existingMeshScale;
  108609. private _dragMesh;
  108610. private pointerDragBehavior;
  108611. private coloredMaterial;
  108612. private hoverColoredMaterial;
  108613. /**
  108614. * Sets the color of the bounding box gizmo
  108615. * @param color the color to set
  108616. */
  108617. setColor(color: Color3): void;
  108618. /**
  108619. * Creates an BoundingBoxGizmo
  108620. * @param gizmoLayer The utility layer the gizmo will be added to
  108621. * @param color The color of the gizmo
  108622. */
  108623. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108624. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108625. private _selectNode;
  108626. /**
  108627. * Updates the bounding box information for the Gizmo
  108628. */
  108629. updateBoundingBox(): void;
  108630. private _updateRotationSpheres;
  108631. private _updateScaleBoxes;
  108632. /**
  108633. * Enables rotation on the specified axis and disables rotation on the others
  108634. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108635. */
  108636. setEnabledRotationAxis(axis: string): void;
  108637. /**
  108638. * Enables/disables scaling
  108639. * @param enable if scaling should be enabled
  108640. */
  108641. setEnabledScaling(enable: boolean): void;
  108642. private _updateDummy;
  108643. /**
  108644. * Enables a pointer drag behavior on the bounding box of the gizmo
  108645. */
  108646. enableDragBehavior(): void;
  108647. /**
  108648. * Disposes of the gizmo
  108649. */
  108650. dispose(): void;
  108651. /**
  108652. * 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)
  108653. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108654. * @returns the bounding box mesh with the passed in mesh as a child
  108655. */
  108656. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108657. /**
  108658. * CustomMeshes are not supported by this gizmo
  108659. * @param mesh The mesh to replace the default mesh of the gizmo
  108660. */
  108661. setCustomMesh(mesh: Mesh): void;
  108662. }
  108663. }
  108664. declare module BABYLON {
  108665. /**
  108666. * Single plane rotation gizmo
  108667. */
  108668. export class PlaneRotationGizmo extends Gizmo {
  108669. /**
  108670. * Drag behavior responsible for the gizmos dragging interactions
  108671. */
  108672. dragBehavior: PointerDragBehavior;
  108673. private _pointerObserver;
  108674. /**
  108675. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108676. */
  108677. snapDistance: number;
  108678. /**
  108679. * Event that fires each time the gizmo snaps to a new location.
  108680. * * snapDistance is the the change in distance
  108681. */
  108682. onSnapObservable: Observable<{
  108683. snapDistance: number;
  108684. }>;
  108685. private _isEnabled;
  108686. private _parent;
  108687. /**
  108688. * Creates a PlaneRotationGizmo
  108689. * @param gizmoLayer The utility layer the gizmo will be added to
  108690. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108691. * @param color The color of the gizmo
  108692. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108693. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108694. */
  108695. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  108696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108697. /**
  108698. * If the gizmo is enabled
  108699. */
  108700. isEnabled: boolean;
  108701. /**
  108702. * Disposes of the gizmo
  108703. */
  108704. dispose(): void;
  108705. }
  108706. }
  108707. declare module BABYLON {
  108708. /**
  108709. * Gizmo that enables rotating a mesh along 3 axis
  108710. */
  108711. export class RotationGizmo extends Gizmo {
  108712. /**
  108713. * Internal gizmo used for interactions on the x axis
  108714. */
  108715. xGizmo: PlaneRotationGizmo;
  108716. /**
  108717. * Internal gizmo used for interactions on the y axis
  108718. */
  108719. yGizmo: PlaneRotationGizmo;
  108720. /**
  108721. * Internal gizmo used for interactions on the z axis
  108722. */
  108723. zGizmo: PlaneRotationGizmo;
  108724. /** Fires an event when any of it's sub gizmos are dragged */
  108725. onDragStartObservable: Observable<unknown>;
  108726. /** Fires an event when any of it's sub gizmos are released from dragging */
  108727. onDragEndObservable: Observable<unknown>;
  108728. private _meshAttached;
  108729. attachedMesh: Nullable<AbstractMesh>;
  108730. /**
  108731. * Creates a RotationGizmo
  108732. * @param gizmoLayer The utility layer the gizmo will be added to
  108733. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108734. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108735. */
  108736. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  108737. updateGizmoRotationToMatchAttachedMesh: boolean;
  108738. /**
  108739. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108740. */
  108741. snapDistance: number;
  108742. /**
  108743. * Ratio for the scale of the gizmo (Default: 1)
  108744. */
  108745. scaleRatio: number;
  108746. /**
  108747. * Disposes of the gizmo
  108748. */
  108749. dispose(): void;
  108750. /**
  108751. * CustomMeshes are not supported by this gizmo
  108752. * @param mesh The mesh to replace the default mesh of the gizmo
  108753. */
  108754. setCustomMesh(mesh: Mesh): void;
  108755. }
  108756. }
  108757. declare module BABYLON {
  108758. /**
  108759. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108760. */
  108761. export class GizmoManager implements IDisposable {
  108762. private scene;
  108763. /**
  108764. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108765. */
  108766. gizmos: {
  108767. positionGizmo: Nullable<PositionGizmo>;
  108768. rotationGizmo: Nullable<RotationGizmo>;
  108769. scaleGizmo: Nullable<ScaleGizmo>;
  108770. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108771. };
  108772. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108773. clearGizmoOnEmptyPointerEvent: boolean;
  108774. /** Fires an event when the manager is attached to a mesh */
  108775. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108776. private _gizmosEnabled;
  108777. private _pointerObserver;
  108778. private _attachedMesh;
  108779. private _boundingBoxColor;
  108780. private _defaultUtilityLayer;
  108781. private _defaultKeepDepthUtilityLayer;
  108782. /**
  108783. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108784. */
  108785. boundingBoxDragBehavior: SixDofDragBehavior;
  108786. /**
  108787. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108788. */
  108789. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108790. /**
  108791. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108792. */
  108793. usePointerToAttachGizmos: boolean;
  108794. /**
  108795. * Utility layer that the bounding box gizmo belongs to
  108796. */
  108797. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108798. /**
  108799. * Utility layer that all gizmos besides bounding box belong to
  108800. */
  108801. readonly utilityLayer: UtilityLayerRenderer;
  108802. /**
  108803. * Instatiates a gizmo manager
  108804. * @param scene the scene to overlay the gizmos on top of
  108805. */
  108806. constructor(scene: Scene);
  108807. /**
  108808. * Attaches a set of gizmos to the specified mesh
  108809. * @param mesh The mesh the gizmo's should be attached to
  108810. */
  108811. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108812. /**
  108813. * If the position gizmo is enabled
  108814. */
  108815. positionGizmoEnabled: boolean;
  108816. /**
  108817. * If the rotation gizmo is enabled
  108818. */
  108819. rotationGizmoEnabled: boolean;
  108820. /**
  108821. * If the scale gizmo is enabled
  108822. */
  108823. scaleGizmoEnabled: boolean;
  108824. /**
  108825. * If the boundingBox gizmo is enabled
  108826. */
  108827. boundingBoxGizmoEnabled: boolean;
  108828. /**
  108829. * Disposes of the gizmo manager
  108830. */
  108831. dispose(): void;
  108832. }
  108833. }
  108834. declare module BABYLON {
  108835. /**
  108836. * A directional light is defined by a direction (what a surprise!).
  108837. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108838. * 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.
  108839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108840. */
  108841. export class DirectionalLight extends ShadowLight {
  108842. private _shadowFrustumSize;
  108843. /**
  108844. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108845. */
  108846. /**
  108847. * Specifies a fix frustum size for the shadow generation.
  108848. */
  108849. shadowFrustumSize: number;
  108850. private _shadowOrthoScale;
  108851. /**
  108852. * Gets the shadow projection scale against the optimal computed one.
  108853. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108854. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108855. */
  108856. /**
  108857. * Sets the shadow projection scale against the optimal computed one.
  108858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108860. */
  108861. shadowOrthoScale: number;
  108862. /**
  108863. * Automatically compute the projection matrix to best fit (including all the casters)
  108864. * on each frame.
  108865. */
  108866. autoUpdateExtends: boolean;
  108867. private _orthoLeft;
  108868. private _orthoRight;
  108869. private _orthoTop;
  108870. private _orthoBottom;
  108871. /**
  108872. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108873. * The directional light is emitted from everywhere in the given direction.
  108874. * It can cast shadows.
  108875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108876. * @param name The friendly name of the light
  108877. * @param direction The direction of the light
  108878. * @param scene The scene the light belongs to
  108879. */
  108880. constructor(name: string, direction: Vector3, scene: Scene);
  108881. /**
  108882. * Returns the string "DirectionalLight".
  108883. * @return The class name
  108884. */
  108885. getClassName(): string;
  108886. /**
  108887. * Returns the integer 1.
  108888. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108889. */
  108890. getTypeID(): number;
  108891. /**
  108892. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108893. * Returns the DirectionalLight Shadow projection matrix.
  108894. */
  108895. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108896. /**
  108897. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108898. * Returns the DirectionalLight Shadow projection matrix.
  108899. */
  108900. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108901. /**
  108902. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108903. * Returns the DirectionalLight Shadow projection matrix.
  108904. */
  108905. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108906. protected _buildUniformLayout(): void;
  108907. /**
  108908. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108909. * @param effect The effect to update
  108910. * @param lightIndex The index of the light in the effect to update
  108911. * @returns The directional light
  108912. */
  108913. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108914. /**
  108915. * Gets the minZ used for shadow according to both the scene and the light.
  108916. *
  108917. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108918. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108919. * @param activeCamera The camera we are returning the min for
  108920. * @returns the depth min z
  108921. */
  108922. getDepthMinZ(activeCamera: Camera): number;
  108923. /**
  108924. * Gets the maxZ used for shadow according to both the scene and the light.
  108925. *
  108926. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108927. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108928. * @param activeCamera The camera we are returning the max for
  108929. * @returns the depth max z
  108930. */
  108931. getDepthMaxZ(activeCamera: Camera): number;
  108932. /**
  108933. * Prepares the list of defines specific to the light type.
  108934. * @param defines the list of defines
  108935. * @param lightIndex defines the index of the light for the effect
  108936. */
  108937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108938. }
  108939. }
  108940. declare module BABYLON {
  108941. /**
  108942. * Class containing static functions to help procedurally build meshes
  108943. */
  108944. export class HemisphereBuilder {
  108945. /**
  108946. * Creates a hemisphere mesh
  108947. * @param name defines the name of the mesh
  108948. * @param options defines the options used to create the mesh
  108949. * @param scene defines the hosting scene
  108950. * @returns the hemisphere mesh
  108951. */
  108952. static CreateHemisphere(name: string, options: {
  108953. segments?: number;
  108954. diameter?: number;
  108955. sideOrientation?: number;
  108956. }, scene: any): Mesh;
  108957. }
  108958. }
  108959. declare module BABYLON {
  108960. /**
  108961. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108962. * These values define a cone of light starting from the position, emitting toward the direction.
  108963. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108964. * and the exponent defines the speed of the decay of the light with distance (reach).
  108965. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108966. */
  108967. export class SpotLight extends ShadowLight {
  108968. private _angle;
  108969. private _innerAngle;
  108970. private _cosHalfAngle;
  108971. private _lightAngleScale;
  108972. private _lightAngleOffset;
  108973. /**
  108974. * Gets the cone angle of the spot light in Radians.
  108975. */
  108976. /**
  108977. * Sets the cone angle of the spot light in Radians.
  108978. */
  108979. angle: number;
  108980. /**
  108981. * Only used in gltf falloff mode, this defines the angle where
  108982. * the directional falloff will start before cutting at angle which could be seen
  108983. * as outer angle.
  108984. */
  108985. /**
  108986. * Only used in gltf falloff mode, this defines the angle where
  108987. * the directional falloff will start before cutting at angle which could be seen
  108988. * as outer angle.
  108989. */
  108990. innerAngle: number;
  108991. private _shadowAngleScale;
  108992. /**
  108993. * Allows scaling the angle of the light for shadow generation only.
  108994. */
  108995. /**
  108996. * Allows scaling the angle of the light for shadow generation only.
  108997. */
  108998. shadowAngleScale: number;
  108999. /**
  109000. * The light decay speed with the distance from the emission spot.
  109001. */
  109002. exponent: number;
  109003. private _projectionTextureMatrix;
  109004. /**
  109005. * Allows reading the projecton texture
  109006. */
  109007. readonly projectionTextureMatrix: Matrix;
  109008. protected _projectionTextureLightNear: number;
  109009. /**
  109010. * Gets the near clip of the Spotlight for texture projection.
  109011. */
  109012. /**
  109013. * Sets the near clip of the Spotlight for texture projection.
  109014. */
  109015. projectionTextureLightNear: number;
  109016. protected _projectionTextureLightFar: number;
  109017. /**
  109018. * Gets the far clip of the Spotlight for texture projection.
  109019. */
  109020. /**
  109021. * Sets the far clip of the Spotlight for texture projection.
  109022. */
  109023. projectionTextureLightFar: number;
  109024. protected _projectionTextureUpDirection: Vector3;
  109025. /**
  109026. * Gets the Up vector of the Spotlight for texture projection.
  109027. */
  109028. /**
  109029. * Sets the Up vector of the Spotlight for texture projection.
  109030. */
  109031. projectionTextureUpDirection: Vector3;
  109032. private _projectionTexture;
  109033. /**
  109034. * Gets the projection texture of the light.
  109035. */
  109036. /**
  109037. * Sets the projection texture of the light.
  109038. */
  109039. projectionTexture: Nullable<BaseTexture>;
  109040. private _projectionTextureViewLightDirty;
  109041. private _projectionTextureProjectionLightDirty;
  109042. private _projectionTextureDirty;
  109043. private _projectionTextureViewTargetVector;
  109044. private _projectionTextureViewLightMatrix;
  109045. private _projectionTextureProjectionLightMatrix;
  109046. private _projectionTextureScalingMatrix;
  109047. /**
  109048. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109049. * It can cast shadows.
  109050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109051. * @param name The light friendly name
  109052. * @param position The position of the spot light in the scene
  109053. * @param direction The direction of the light in the scene
  109054. * @param angle The cone angle of the light in Radians
  109055. * @param exponent The light decay speed with the distance from the emission spot
  109056. * @param scene The scene the lights belongs to
  109057. */
  109058. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109059. /**
  109060. * Returns the string "SpotLight".
  109061. * @returns the class name
  109062. */
  109063. getClassName(): string;
  109064. /**
  109065. * Returns the integer 2.
  109066. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109067. */
  109068. getTypeID(): number;
  109069. /**
  109070. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109071. */
  109072. protected _setDirection(value: Vector3): void;
  109073. /**
  109074. * Overrides the position setter to recompute the projection texture view light Matrix.
  109075. */
  109076. protected _setPosition(value: Vector3): void;
  109077. /**
  109078. * 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.
  109079. * Returns the SpotLight.
  109080. */
  109081. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109082. protected _computeProjectionTextureViewLightMatrix(): void;
  109083. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109084. /**
  109085. * Main function for light texture projection matrix computing.
  109086. */
  109087. protected _computeProjectionTextureMatrix(): void;
  109088. protected _buildUniformLayout(): void;
  109089. private _computeAngleValues;
  109090. /**
  109091. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109092. * @param effect The effect to update
  109093. * @param lightIndex The index of the light in the effect to update
  109094. * @returns The spot light
  109095. */
  109096. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109097. /**
  109098. * Disposes the light and the associated resources.
  109099. */
  109100. dispose(): void;
  109101. /**
  109102. * Prepares the list of defines specific to the light type.
  109103. * @param defines the list of defines
  109104. * @param lightIndex defines the index of the light for the effect
  109105. */
  109106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109107. }
  109108. }
  109109. declare module BABYLON {
  109110. /**
  109111. * Gizmo that enables viewing a light
  109112. */
  109113. export class LightGizmo extends Gizmo {
  109114. private _lightMesh;
  109115. private _material;
  109116. private cachedPosition;
  109117. private cachedForward;
  109118. /**
  109119. * Creates a LightGizmo
  109120. * @param gizmoLayer The utility layer the gizmo will be added to
  109121. */
  109122. constructor(gizmoLayer?: UtilityLayerRenderer);
  109123. private _light;
  109124. /**
  109125. * The light that the gizmo is attached to
  109126. */
  109127. light: Nullable<Light>;
  109128. /**
  109129. * Gets the material used to render the light gizmo
  109130. */
  109131. readonly material: StandardMaterial;
  109132. /**
  109133. * @hidden
  109134. * Updates the gizmo to match the attached mesh's position/rotation
  109135. */
  109136. protected _update(): void;
  109137. private static _Scale;
  109138. /**
  109139. * Creates the lines for a light mesh
  109140. */
  109141. private static _createLightLines;
  109142. /**
  109143. * Disposes of the light gizmo
  109144. */
  109145. dispose(): void;
  109146. private static _CreateHemisphericLightMesh;
  109147. private static _CreatePointLightMesh;
  109148. private static _CreateSpotLightMesh;
  109149. private static _CreateDirectionalLightMesh;
  109150. }
  109151. }
  109152. declare module BABYLON {
  109153. /** @hidden */
  109154. export var backgroundFragmentDeclaration: {
  109155. name: string;
  109156. shader: string;
  109157. };
  109158. }
  109159. declare module BABYLON {
  109160. /** @hidden */
  109161. export var backgroundUboDeclaration: {
  109162. name: string;
  109163. shader: string;
  109164. };
  109165. }
  109166. declare module BABYLON {
  109167. /** @hidden */
  109168. export var backgroundPixelShader: {
  109169. name: string;
  109170. shader: string;
  109171. };
  109172. }
  109173. declare module BABYLON {
  109174. /** @hidden */
  109175. export var backgroundVertexDeclaration: {
  109176. name: string;
  109177. shader: string;
  109178. };
  109179. }
  109180. declare module BABYLON {
  109181. /** @hidden */
  109182. export var backgroundVertexShader: {
  109183. name: string;
  109184. shader: string;
  109185. };
  109186. }
  109187. declare module BABYLON {
  109188. /**
  109189. * Background material used to create an efficient environement around your scene.
  109190. */
  109191. export class BackgroundMaterial extends PushMaterial {
  109192. /**
  109193. * Standard reflectance value at parallel view angle.
  109194. */
  109195. static StandardReflectance0: number;
  109196. /**
  109197. * Standard reflectance value at grazing angle.
  109198. */
  109199. static StandardReflectance90: number;
  109200. protected _primaryColor: Color3;
  109201. /**
  109202. * Key light Color (multiply against the environement texture)
  109203. */
  109204. primaryColor: Color3;
  109205. protected __perceptualColor: Nullable<Color3>;
  109206. /**
  109207. * Experimental Internal Use Only.
  109208. *
  109209. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109210. * This acts as a helper to set the primary color to a more "human friendly" value.
  109211. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109212. * output color as close as possible from the chosen value.
  109213. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109214. * part of lighting setup.)
  109215. */
  109216. _perceptualColor: Nullable<Color3>;
  109217. protected _primaryColorShadowLevel: float;
  109218. /**
  109219. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109220. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109221. */
  109222. primaryColorShadowLevel: float;
  109223. protected _primaryColorHighlightLevel: float;
  109224. /**
  109225. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109226. * The primary color is used at the level chosen to define what the white area would look.
  109227. */
  109228. primaryColorHighlightLevel: float;
  109229. protected _reflectionTexture: Nullable<BaseTexture>;
  109230. /**
  109231. * Reflection Texture used in the material.
  109232. * Should be author in a specific way for the best result (refer to the documentation).
  109233. */
  109234. reflectionTexture: Nullable<BaseTexture>;
  109235. protected _reflectionBlur: float;
  109236. /**
  109237. * Reflection Texture level of blur.
  109238. *
  109239. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109240. * texture twice.
  109241. */
  109242. reflectionBlur: float;
  109243. protected _diffuseTexture: Nullable<BaseTexture>;
  109244. /**
  109245. * Diffuse Texture used in the material.
  109246. * Should be author in a specific way for the best result (refer to the documentation).
  109247. */
  109248. diffuseTexture: Nullable<BaseTexture>;
  109249. protected _shadowLights: Nullable<IShadowLight[]>;
  109250. /**
  109251. * Specify the list of lights casting shadow on the material.
  109252. * All scene shadow lights will be included if null.
  109253. */
  109254. shadowLights: Nullable<IShadowLight[]>;
  109255. protected _shadowLevel: float;
  109256. /**
  109257. * Helps adjusting the shadow to a softer level if required.
  109258. * 0 means black shadows and 1 means no shadows.
  109259. */
  109260. shadowLevel: float;
  109261. protected _sceneCenter: Vector3;
  109262. /**
  109263. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109264. * It is usually zero but might be interesting to modify according to your setup.
  109265. */
  109266. sceneCenter: Vector3;
  109267. protected _opacityFresnel: boolean;
  109268. /**
  109269. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109270. * This helps ensuring a nice transition when the camera goes under the ground.
  109271. */
  109272. opacityFresnel: boolean;
  109273. protected _reflectionFresnel: boolean;
  109274. /**
  109275. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109276. * This helps adding a mirror texture on the ground.
  109277. */
  109278. reflectionFresnel: boolean;
  109279. protected _reflectionFalloffDistance: number;
  109280. /**
  109281. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109282. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109283. */
  109284. reflectionFalloffDistance: number;
  109285. protected _reflectionAmount: number;
  109286. /**
  109287. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109288. */
  109289. reflectionAmount: number;
  109290. protected _reflectionReflectance0: number;
  109291. /**
  109292. * This specifies the weight of the reflection at grazing angle.
  109293. */
  109294. reflectionReflectance0: number;
  109295. protected _reflectionReflectance90: number;
  109296. /**
  109297. * This specifies the weight of the reflection at a perpendicular point of view.
  109298. */
  109299. reflectionReflectance90: number;
  109300. /**
  109301. * Sets the reflection reflectance fresnel values according to the default standard
  109302. * empirically know to work well :-)
  109303. */
  109304. reflectionStandardFresnelWeight: number;
  109305. protected _useRGBColor: boolean;
  109306. /**
  109307. * Helps to directly use the maps channels instead of their level.
  109308. */
  109309. useRGBColor: boolean;
  109310. protected _enableNoise: boolean;
  109311. /**
  109312. * This helps reducing the banding effect that could occur on the background.
  109313. */
  109314. enableNoise: boolean;
  109315. /**
  109316. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109317. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109318. * Recommended to be keep at 1.0 except for special cases.
  109319. */
  109320. fovMultiplier: number;
  109321. private _fovMultiplier;
  109322. /**
  109323. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109324. */
  109325. useEquirectangularFOV: boolean;
  109326. private _maxSimultaneousLights;
  109327. /**
  109328. * Number of Simultaneous lights allowed on the material.
  109329. */
  109330. maxSimultaneousLights: int;
  109331. /**
  109332. * Default configuration related to image processing available in the Background Material.
  109333. */
  109334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109335. /**
  109336. * Keep track of the image processing observer to allow dispose and replace.
  109337. */
  109338. private _imageProcessingObserver;
  109339. /**
  109340. * Attaches a new image processing configuration to the PBR Material.
  109341. * @param configuration (if null the scene configuration will be use)
  109342. */
  109343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109344. /**
  109345. * Gets the image processing configuration used either in this material.
  109346. */
  109347. /**
  109348. * Sets the Default image processing configuration used either in the this material.
  109349. *
  109350. * If sets to null, the scene one is in use.
  109351. */
  109352. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109353. /**
  109354. * Gets wether the color curves effect is enabled.
  109355. */
  109356. /**
  109357. * Sets wether the color curves effect is enabled.
  109358. */
  109359. cameraColorCurvesEnabled: boolean;
  109360. /**
  109361. * Gets wether the color grading effect is enabled.
  109362. */
  109363. /**
  109364. * Gets wether the color grading effect is enabled.
  109365. */
  109366. cameraColorGradingEnabled: boolean;
  109367. /**
  109368. * Gets wether tonemapping is enabled or not.
  109369. */
  109370. /**
  109371. * Sets wether tonemapping is enabled or not
  109372. */
  109373. cameraToneMappingEnabled: boolean;
  109374. /**
  109375. * The camera exposure used on this material.
  109376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109377. * This corresponds to a photographic exposure.
  109378. */
  109379. /**
  109380. * The camera exposure used on this material.
  109381. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109382. * This corresponds to a photographic exposure.
  109383. */
  109384. cameraExposure: float;
  109385. /**
  109386. * Gets The camera contrast used on this material.
  109387. */
  109388. /**
  109389. * Sets The camera contrast used on this material.
  109390. */
  109391. cameraContrast: float;
  109392. /**
  109393. * Gets the Color Grading 2D Lookup Texture.
  109394. */
  109395. /**
  109396. * Sets the Color Grading 2D Lookup Texture.
  109397. */
  109398. cameraColorGradingTexture: Nullable<BaseTexture>;
  109399. /**
  109400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109402. * 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;
  109403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109404. */
  109405. /**
  109406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109408. * 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;
  109409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109410. */
  109411. cameraColorCurves: Nullable<ColorCurves>;
  109412. /**
  109413. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109414. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109415. */
  109416. switchToBGR: boolean;
  109417. private _renderTargets;
  109418. private _reflectionControls;
  109419. private _white;
  109420. private _primaryShadowColor;
  109421. private _primaryHighlightColor;
  109422. /**
  109423. * Instantiates a Background Material in the given scene
  109424. * @param name The friendly name of the material
  109425. * @param scene The scene to add the material to
  109426. */
  109427. constructor(name: string, scene: Scene);
  109428. /**
  109429. * Gets a boolean indicating that current material needs to register RTT
  109430. */
  109431. readonly hasRenderTargetTextures: boolean;
  109432. /**
  109433. * The entire material has been created in order to prevent overdraw.
  109434. * @returns false
  109435. */
  109436. needAlphaTesting(): boolean;
  109437. /**
  109438. * The entire material has been created in order to prevent overdraw.
  109439. * @returns true if blending is enable
  109440. */
  109441. needAlphaBlending(): boolean;
  109442. /**
  109443. * Checks wether the material is ready to be rendered for a given mesh.
  109444. * @param mesh The mesh to render
  109445. * @param subMesh The submesh to check against
  109446. * @param useInstances Specify wether or not the material is used with instances
  109447. * @returns true if all the dependencies are ready (Textures, Effects...)
  109448. */
  109449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109450. /**
  109451. * Compute the primary color according to the chosen perceptual color.
  109452. */
  109453. private _computePrimaryColorFromPerceptualColor;
  109454. /**
  109455. * Compute the highlights and shadow colors according to their chosen levels.
  109456. */
  109457. private _computePrimaryColors;
  109458. /**
  109459. * Build the uniform buffer used in the material.
  109460. */
  109461. buildUniformLayout(): void;
  109462. /**
  109463. * Unbind the material.
  109464. */
  109465. unbind(): void;
  109466. /**
  109467. * Bind only the world matrix to the material.
  109468. * @param world The world matrix to bind.
  109469. */
  109470. bindOnlyWorldMatrix(world: Matrix): void;
  109471. /**
  109472. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109473. * @param world The world matrix to bind.
  109474. * @param subMesh The submesh to bind for.
  109475. */
  109476. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109477. /**
  109478. * Dispose the material.
  109479. * @param forceDisposeEffect Force disposal of the associated effect.
  109480. * @param forceDisposeTextures Force disposal of the associated textures.
  109481. */
  109482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109483. /**
  109484. * Clones the material.
  109485. * @param name The cloned name.
  109486. * @returns The cloned material.
  109487. */
  109488. clone(name: string): BackgroundMaterial;
  109489. /**
  109490. * Serializes the current material to its JSON representation.
  109491. * @returns The JSON representation.
  109492. */
  109493. serialize(): any;
  109494. /**
  109495. * Gets the class name of the material
  109496. * @returns "BackgroundMaterial"
  109497. */
  109498. getClassName(): string;
  109499. /**
  109500. * Parse a JSON input to create back a background material.
  109501. * @param source The JSON data to parse
  109502. * @param scene The scene to create the parsed material in
  109503. * @param rootUrl The root url of the assets the material depends upon
  109504. * @returns the instantiated BackgroundMaterial.
  109505. */
  109506. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109507. }
  109508. }
  109509. declare module BABYLON {
  109510. /**
  109511. * Represents the different options available during the creation of
  109512. * a Environment helper.
  109513. *
  109514. * This can control the default ground, skybox and image processing setup of your scene.
  109515. */
  109516. export interface IEnvironmentHelperOptions {
  109517. /**
  109518. * Specifies wether or not to create a ground.
  109519. * True by default.
  109520. */
  109521. createGround: boolean;
  109522. /**
  109523. * Specifies the ground size.
  109524. * 15 by default.
  109525. */
  109526. groundSize: number;
  109527. /**
  109528. * The texture used on the ground for the main color.
  109529. * Comes from the BabylonJS CDN by default.
  109530. *
  109531. * Remarks: Can be either a texture or a url.
  109532. */
  109533. groundTexture: string | BaseTexture;
  109534. /**
  109535. * The color mixed in the ground texture by default.
  109536. * BabylonJS clearColor by default.
  109537. */
  109538. groundColor: Color3;
  109539. /**
  109540. * Specifies the ground opacity.
  109541. * 1 by default.
  109542. */
  109543. groundOpacity: number;
  109544. /**
  109545. * Enables the ground to receive shadows.
  109546. * True by default.
  109547. */
  109548. enableGroundShadow: boolean;
  109549. /**
  109550. * Helps preventing the shadow to be fully black on the ground.
  109551. * 0.5 by default.
  109552. */
  109553. groundShadowLevel: number;
  109554. /**
  109555. * Creates a mirror texture attach to the ground.
  109556. * false by default.
  109557. */
  109558. enableGroundMirror: boolean;
  109559. /**
  109560. * Specifies the ground mirror size ratio.
  109561. * 0.3 by default as the default kernel is 64.
  109562. */
  109563. groundMirrorSizeRatio: number;
  109564. /**
  109565. * Specifies the ground mirror blur kernel size.
  109566. * 64 by default.
  109567. */
  109568. groundMirrorBlurKernel: number;
  109569. /**
  109570. * Specifies the ground mirror visibility amount.
  109571. * 1 by default
  109572. */
  109573. groundMirrorAmount: number;
  109574. /**
  109575. * Specifies the ground mirror reflectance weight.
  109576. * This uses the standard weight of the background material to setup the fresnel effect
  109577. * of the mirror.
  109578. * 1 by default.
  109579. */
  109580. groundMirrorFresnelWeight: number;
  109581. /**
  109582. * Specifies the ground mirror Falloff distance.
  109583. * This can helps reducing the size of the reflection.
  109584. * 0 by Default.
  109585. */
  109586. groundMirrorFallOffDistance: number;
  109587. /**
  109588. * Specifies the ground mirror texture type.
  109589. * Unsigned Int by Default.
  109590. */
  109591. groundMirrorTextureType: number;
  109592. /**
  109593. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109594. * the shown objects.
  109595. */
  109596. groundYBias: number;
  109597. /**
  109598. * Specifies wether or not to create a skybox.
  109599. * True by default.
  109600. */
  109601. createSkybox: boolean;
  109602. /**
  109603. * Specifies the skybox size.
  109604. * 20 by default.
  109605. */
  109606. skyboxSize: number;
  109607. /**
  109608. * The texture used on the skybox for the main color.
  109609. * Comes from the BabylonJS CDN by default.
  109610. *
  109611. * Remarks: Can be either a texture or a url.
  109612. */
  109613. skyboxTexture: string | BaseTexture;
  109614. /**
  109615. * The color mixed in the skybox texture by default.
  109616. * BabylonJS clearColor by default.
  109617. */
  109618. skyboxColor: Color3;
  109619. /**
  109620. * The background rotation around the Y axis of the scene.
  109621. * This helps aligning the key lights of your scene with the background.
  109622. * 0 by default.
  109623. */
  109624. backgroundYRotation: number;
  109625. /**
  109626. * Compute automatically the size of the elements to best fit with the scene.
  109627. */
  109628. sizeAuto: boolean;
  109629. /**
  109630. * Default position of the rootMesh if autoSize is not true.
  109631. */
  109632. rootPosition: Vector3;
  109633. /**
  109634. * Sets up the image processing in the scene.
  109635. * true by default.
  109636. */
  109637. setupImageProcessing: boolean;
  109638. /**
  109639. * The texture used as your environment texture in the scene.
  109640. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109641. *
  109642. * Remarks: Can be either a texture or a url.
  109643. */
  109644. environmentTexture: string | BaseTexture;
  109645. /**
  109646. * The value of the exposure to apply to the scene.
  109647. * 0.6 by default if setupImageProcessing is true.
  109648. */
  109649. cameraExposure: number;
  109650. /**
  109651. * The value of the contrast to apply to the scene.
  109652. * 1.6 by default if setupImageProcessing is true.
  109653. */
  109654. cameraContrast: number;
  109655. /**
  109656. * Specifies wether or not tonemapping should be enabled in the scene.
  109657. * true by default if setupImageProcessing is true.
  109658. */
  109659. toneMappingEnabled: boolean;
  109660. }
  109661. /**
  109662. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109663. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109664. * It also helps with the default setup of your imageProcessing configuration.
  109665. */
  109666. export class EnvironmentHelper {
  109667. /**
  109668. * Default ground texture URL.
  109669. */
  109670. private static _groundTextureCDNUrl;
  109671. /**
  109672. * Default skybox texture URL.
  109673. */
  109674. private static _skyboxTextureCDNUrl;
  109675. /**
  109676. * Default environment texture URL.
  109677. */
  109678. private static _environmentTextureCDNUrl;
  109679. /**
  109680. * Creates the default options for the helper.
  109681. */
  109682. private static _getDefaultOptions;
  109683. private _rootMesh;
  109684. /**
  109685. * Gets the root mesh created by the helper.
  109686. */
  109687. readonly rootMesh: Mesh;
  109688. private _skybox;
  109689. /**
  109690. * Gets the skybox created by the helper.
  109691. */
  109692. readonly skybox: Nullable<Mesh>;
  109693. private _skyboxTexture;
  109694. /**
  109695. * Gets the skybox texture created by the helper.
  109696. */
  109697. readonly skyboxTexture: Nullable<BaseTexture>;
  109698. private _skyboxMaterial;
  109699. /**
  109700. * Gets the skybox material created by the helper.
  109701. */
  109702. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109703. private _ground;
  109704. /**
  109705. * Gets the ground mesh created by the helper.
  109706. */
  109707. readonly ground: Nullable<Mesh>;
  109708. private _groundTexture;
  109709. /**
  109710. * Gets the ground texture created by the helper.
  109711. */
  109712. readonly groundTexture: Nullable<BaseTexture>;
  109713. private _groundMirror;
  109714. /**
  109715. * Gets the ground mirror created by the helper.
  109716. */
  109717. readonly groundMirror: Nullable<MirrorTexture>;
  109718. /**
  109719. * Gets the ground mirror render list to helps pushing the meshes
  109720. * you wish in the ground reflection.
  109721. */
  109722. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109723. private _groundMaterial;
  109724. /**
  109725. * Gets the ground material created by the helper.
  109726. */
  109727. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109728. /**
  109729. * Stores the creation options.
  109730. */
  109731. private readonly _scene;
  109732. private _options;
  109733. /**
  109734. * This observable will be notified with any error during the creation of the environment,
  109735. * mainly texture creation errors.
  109736. */
  109737. onErrorObservable: Observable<{
  109738. message?: string;
  109739. exception?: any;
  109740. }>;
  109741. /**
  109742. * constructor
  109743. * @param options Defines the options we want to customize the helper
  109744. * @param scene The scene to add the material to
  109745. */
  109746. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109747. /**
  109748. * Updates the background according to the new options
  109749. * @param options
  109750. */
  109751. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109752. /**
  109753. * Sets the primary color of all the available elements.
  109754. * @param color the main color to affect to the ground and the background
  109755. */
  109756. setMainColor(color: Color3): void;
  109757. /**
  109758. * Setup the image processing according to the specified options.
  109759. */
  109760. private _setupImageProcessing;
  109761. /**
  109762. * Setup the environment texture according to the specified options.
  109763. */
  109764. private _setupEnvironmentTexture;
  109765. /**
  109766. * Setup the background according to the specified options.
  109767. */
  109768. private _setupBackground;
  109769. /**
  109770. * Get the scene sizes according to the setup.
  109771. */
  109772. private _getSceneSize;
  109773. /**
  109774. * Setup the ground according to the specified options.
  109775. */
  109776. private _setupGround;
  109777. /**
  109778. * Setup the ground material according to the specified options.
  109779. */
  109780. private _setupGroundMaterial;
  109781. /**
  109782. * Setup the ground diffuse texture according to the specified options.
  109783. */
  109784. private _setupGroundDiffuseTexture;
  109785. /**
  109786. * Setup the ground mirror texture according to the specified options.
  109787. */
  109788. private _setupGroundMirrorTexture;
  109789. /**
  109790. * Setup the ground to receive the mirror texture.
  109791. */
  109792. private _setupMirrorInGroundMaterial;
  109793. /**
  109794. * Setup the skybox according to the specified options.
  109795. */
  109796. private _setupSkybox;
  109797. /**
  109798. * Setup the skybox material according to the specified options.
  109799. */
  109800. private _setupSkyboxMaterial;
  109801. /**
  109802. * Setup the skybox reflection texture according to the specified options.
  109803. */
  109804. private _setupSkyboxReflectionTexture;
  109805. private _errorHandler;
  109806. /**
  109807. * Dispose all the elements created by the Helper.
  109808. */
  109809. dispose(): void;
  109810. }
  109811. }
  109812. declare module BABYLON {
  109813. /**
  109814. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109815. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109816. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109817. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109818. */
  109819. export class PhotoDome extends TransformNode {
  109820. /**
  109821. * Define the image as a Monoscopic panoramic 360 image.
  109822. */
  109823. static readonly MODE_MONOSCOPIC: number;
  109824. /**
  109825. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109826. */
  109827. static readonly MODE_TOPBOTTOM: number;
  109828. /**
  109829. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109830. */
  109831. static readonly MODE_SIDEBYSIDE: number;
  109832. private _useDirectMapping;
  109833. /**
  109834. * The texture being displayed on the sphere
  109835. */
  109836. protected _photoTexture: Texture;
  109837. /**
  109838. * Gets or sets the texture being displayed on the sphere
  109839. */
  109840. photoTexture: Texture;
  109841. /**
  109842. * Observable raised when an error occured while loading the 360 image
  109843. */
  109844. onLoadErrorObservable: Observable<string>;
  109845. /**
  109846. * The skybox material
  109847. */
  109848. protected _material: BackgroundMaterial;
  109849. /**
  109850. * The surface used for the skybox
  109851. */
  109852. protected _mesh: Mesh;
  109853. /**
  109854. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109855. * Also see the options.resolution property.
  109856. */
  109857. fovMultiplier: number;
  109858. private _imageMode;
  109859. /**
  109860. * Gets or set the current video mode for the video. It can be:
  109861. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109862. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109863. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109864. */
  109865. imageMode: number;
  109866. /**
  109867. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109868. * @param name Element's name, child elements will append suffixes for their own names.
  109869. * @param urlsOfPhoto defines the url of the photo to display
  109870. * @param options defines an object containing optional or exposed sub element properties
  109871. * @param onError defines a callback called when an error occured while loading the texture
  109872. */
  109873. constructor(name: string, urlOfPhoto: string, options: {
  109874. resolution?: number;
  109875. size?: number;
  109876. useDirectMapping?: boolean;
  109877. faceForward?: boolean;
  109878. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109879. private _onBeforeCameraRenderObserver;
  109880. private _changeImageMode;
  109881. /**
  109882. * Releases resources associated with this node.
  109883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109885. */
  109886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109887. }
  109888. }
  109889. declare module BABYLON {
  109890. /** @hidden */
  109891. export var rgbdDecodePixelShader: {
  109892. name: string;
  109893. shader: string;
  109894. };
  109895. }
  109896. declare module BABYLON {
  109897. /**
  109898. * Class used to host texture specific utilities
  109899. */
  109900. export class BRDFTextureTools {
  109901. /**
  109902. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109903. * @param texture the texture to expand.
  109904. */
  109905. private static _ExpandDefaultBRDFTexture;
  109906. /**
  109907. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109908. * @param scene defines the hosting scene
  109909. * @returns the environment BRDF texture
  109910. */
  109911. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109912. private static _environmentBRDFBase64Texture;
  109913. }
  109914. }
  109915. declare module BABYLON {
  109916. /**
  109917. * @hidden
  109918. */
  109919. export interface IMaterialClearCoatDefines {
  109920. CLEARCOAT: boolean;
  109921. CLEARCOAT_DEFAULTIOR: boolean;
  109922. CLEARCOAT_TEXTURE: boolean;
  109923. CLEARCOAT_TEXTUREDIRECTUV: number;
  109924. CLEARCOAT_BUMP: boolean;
  109925. CLEARCOAT_BUMPDIRECTUV: number;
  109926. CLEARCOAT_TINT: boolean;
  109927. CLEARCOAT_TINT_TEXTURE: boolean;
  109928. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109929. /** @hidden */
  109930. _areTexturesDirty: boolean;
  109931. }
  109932. /**
  109933. * Define the code related to the clear coat parameters of the pbr material.
  109934. */
  109935. export class PBRClearCoatConfiguration {
  109936. /**
  109937. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109938. * The default fits with a polyurethane material.
  109939. */
  109940. private static readonly _DefaultIndexOfRefraction;
  109941. private _isEnabled;
  109942. /**
  109943. * Defines if the clear coat is enabled in the material.
  109944. */
  109945. isEnabled: boolean;
  109946. /**
  109947. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109948. */
  109949. intensity: number;
  109950. /**
  109951. * Defines the clear coat layer roughness.
  109952. */
  109953. roughness: number;
  109954. private _indexOfRefraction;
  109955. /**
  109956. * Defines the index of refraction of the clear coat.
  109957. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109958. * The default fits with a polyurethane material.
  109959. * Changing the default value is more performance intensive.
  109960. */
  109961. indexOfRefraction: number;
  109962. private _texture;
  109963. /**
  109964. * Stores the clear coat values in a texture.
  109965. */
  109966. texture: Nullable<BaseTexture>;
  109967. private _bumpTexture;
  109968. /**
  109969. * Define the clear coat specific bump texture.
  109970. */
  109971. bumpTexture: Nullable<BaseTexture>;
  109972. private _isTintEnabled;
  109973. /**
  109974. * Defines if the clear coat tint is enabled in the material.
  109975. */
  109976. isTintEnabled: boolean;
  109977. /**
  109978. * Defines the clear coat tint of the material.
  109979. * This is only use if tint is enabled
  109980. */
  109981. tintColor: Color3;
  109982. /**
  109983. * Defines the distance at which the tint color should be found in the
  109984. * clear coat media.
  109985. * This is only use if tint is enabled
  109986. */
  109987. tintColorAtDistance: number;
  109988. /**
  109989. * Defines the clear coat layer thickness.
  109990. * This is only use if tint is enabled
  109991. */
  109992. tintThickness: number;
  109993. private _tintTexture;
  109994. /**
  109995. * Stores the clear tint values in a texture.
  109996. * rgb is tint
  109997. * a is a thickness factor
  109998. */
  109999. tintTexture: Nullable<BaseTexture>;
  110000. /** @hidden */
  110001. private _internalMarkAllSubMeshesAsTexturesDirty;
  110002. /** @hidden */
  110003. _markAllSubMeshesAsTexturesDirty(): void;
  110004. /**
  110005. * Instantiate a new istance of clear coat configuration.
  110006. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110007. */
  110008. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110009. /**
  110010. * Gets wehter the submesh is ready to be used or not.
  110011. * @param defines the list of "defines" to update.
  110012. * @param scene defines the scene the material belongs to.
  110013. * @param engine defines the engine the material belongs to.
  110014. * @param disableBumpMap defines wether the material disables bump or not.
  110015. * @returns - boolean indicating that the submesh is ready or not.
  110016. */
  110017. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110018. /**
  110019. * Checks to see if a texture is used in the material.
  110020. * @param defines the list of "defines" to update.
  110021. * @param scene defines the scene to the material belongs to.
  110022. */
  110023. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110024. /**
  110025. * Binds the material data.
  110026. * @param uniformBuffer defines the Uniform buffer to fill in.
  110027. * @param scene defines the scene the material belongs to.
  110028. * @param engine defines the engine the material belongs to.
  110029. * @param disableBumpMap defines wether the material disables bump or not.
  110030. * @param isFrozen defines wether the material is frozen or not.
  110031. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110032. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110033. */
  110034. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110035. /**
  110036. * Checks to see if a texture is used in the material.
  110037. * @param texture - Base texture to use.
  110038. * @returns - Boolean specifying if a texture is used in the material.
  110039. */
  110040. hasTexture(texture: BaseTexture): boolean;
  110041. /**
  110042. * Returns an array of the actively used textures.
  110043. * @param activeTextures Array of BaseTextures
  110044. */
  110045. getActiveTextures(activeTextures: BaseTexture[]): void;
  110046. /**
  110047. * Returns the animatable textures.
  110048. * @param animatables Array of animatable textures.
  110049. */
  110050. getAnimatables(animatables: IAnimatable[]): void;
  110051. /**
  110052. * Disposes the resources of the material.
  110053. * @param forceDisposeTextures - Forces the disposal of all textures.
  110054. */
  110055. dispose(forceDisposeTextures?: boolean): void;
  110056. /**
  110057. * Get the current class name of the texture useful for serialization or dynamic coding.
  110058. * @returns "PBRClearCoatConfiguration"
  110059. */
  110060. getClassName(): string;
  110061. /**
  110062. * Add fallbacks to the effect fallbacks list.
  110063. * @param defines defines the Base texture to use.
  110064. * @param fallbacks defines the current fallback list.
  110065. * @param currentRank defines the current fallback rank.
  110066. * @returns the new fallback rank.
  110067. */
  110068. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110069. /**
  110070. * Add the required uniforms to the current list.
  110071. * @param uniforms defines the current uniform list.
  110072. */
  110073. static AddUniforms(uniforms: string[]): void;
  110074. /**
  110075. * Add the required samplers to the current list.
  110076. * @param samplers defines the current sampler list.
  110077. */
  110078. static AddSamplers(samplers: string[]): void;
  110079. /**
  110080. * Add the required uniforms to the current buffer.
  110081. * @param uniformBuffer defines the current uniform buffer.
  110082. */
  110083. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110084. /**
  110085. * Makes a duplicate of the current configuration into another one.
  110086. * @param clearCoatConfiguration define the config where to copy the info
  110087. */
  110088. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110089. /**
  110090. * Serializes this clear coat configuration.
  110091. * @returns - An object with the serialized config.
  110092. */
  110093. serialize(): any;
  110094. /**
  110095. * Parses a anisotropy Configuration from a serialized object.
  110096. * @param source - Serialized object.
  110097. * @param scene Defines the scene we are parsing for
  110098. * @param rootUrl Defines the rootUrl to load from
  110099. */
  110100. parse(source: any, scene: Scene, rootUrl: string): void;
  110101. }
  110102. }
  110103. declare module BABYLON {
  110104. /**
  110105. * @hidden
  110106. */
  110107. export interface IMaterialAnisotropicDefines {
  110108. ANISOTROPIC: boolean;
  110109. ANISOTROPIC_TEXTURE: boolean;
  110110. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110111. MAINUV1: boolean;
  110112. _areTexturesDirty: boolean;
  110113. _needUVs: boolean;
  110114. }
  110115. /**
  110116. * Define the code related to the anisotropic parameters of the pbr material.
  110117. */
  110118. export class PBRAnisotropicConfiguration {
  110119. private _isEnabled;
  110120. /**
  110121. * Defines if the anisotropy is enabled in the material.
  110122. */
  110123. isEnabled: boolean;
  110124. /**
  110125. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110126. */
  110127. intensity: number;
  110128. /**
  110129. * Defines if the effect is along the tangents, bitangents or in between.
  110130. * By default, the effect is "strectching" the highlights along the tangents.
  110131. */
  110132. direction: Vector2;
  110133. private _texture;
  110134. /**
  110135. * Stores the anisotropy values in a texture.
  110136. * rg is direction (like normal from -1 to 1)
  110137. * b is a intensity
  110138. */
  110139. texture: Nullable<BaseTexture>;
  110140. /** @hidden */
  110141. private _internalMarkAllSubMeshesAsTexturesDirty;
  110142. /** @hidden */
  110143. _markAllSubMeshesAsTexturesDirty(): void;
  110144. /**
  110145. * Instantiate a new istance of anisotropy configuration.
  110146. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110147. */
  110148. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110149. /**
  110150. * Specifies that the submesh is ready to be used.
  110151. * @param defines the list of "defines" to update.
  110152. * @param scene defines the scene the material belongs to.
  110153. * @returns - boolean indicating that the submesh is ready or not.
  110154. */
  110155. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110156. /**
  110157. * Checks to see if a texture is used in the material.
  110158. * @param defines the list of "defines" to update.
  110159. * @param mesh the mesh we are preparing the defines for.
  110160. * @param scene defines the scene the material belongs to.
  110161. */
  110162. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110163. /**
  110164. * Binds the material data.
  110165. * @param uniformBuffer defines the Uniform buffer to fill in.
  110166. * @param scene defines the scene the material belongs to.
  110167. * @param isFrozen defines wether the material is frozen or not.
  110168. */
  110169. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110170. /**
  110171. * Checks to see if a texture is used in the material.
  110172. * @param texture - Base texture to use.
  110173. * @returns - Boolean specifying if a texture is used in the material.
  110174. */
  110175. hasTexture(texture: BaseTexture): boolean;
  110176. /**
  110177. * Returns an array of the actively used textures.
  110178. * @param activeTextures Array of BaseTextures
  110179. */
  110180. getActiveTextures(activeTextures: BaseTexture[]): void;
  110181. /**
  110182. * Returns the animatable textures.
  110183. * @param animatables Array of animatable textures.
  110184. */
  110185. getAnimatables(animatables: IAnimatable[]): void;
  110186. /**
  110187. * Disposes the resources of the material.
  110188. * @param forceDisposeTextures - Forces the disposal of all textures.
  110189. */
  110190. dispose(forceDisposeTextures?: boolean): void;
  110191. /**
  110192. * Get the current class name of the texture useful for serialization or dynamic coding.
  110193. * @returns "PBRAnisotropicConfiguration"
  110194. */
  110195. getClassName(): string;
  110196. /**
  110197. * Add fallbacks to the effect fallbacks list.
  110198. * @param defines defines the Base texture to use.
  110199. * @param fallbacks defines the current fallback list.
  110200. * @param currentRank defines the current fallback rank.
  110201. * @returns the new fallback rank.
  110202. */
  110203. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110204. /**
  110205. * Add the required uniforms to the current list.
  110206. * @param uniforms defines the current uniform list.
  110207. */
  110208. static AddUniforms(uniforms: string[]): void;
  110209. /**
  110210. * Add the required uniforms to the current buffer.
  110211. * @param uniformBuffer defines the current uniform buffer.
  110212. */
  110213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110214. /**
  110215. * Add the required samplers to the current list.
  110216. * @param samplers defines the current sampler list.
  110217. */
  110218. static AddSamplers(samplers: string[]): void;
  110219. /**
  110220. * Makes a duplicate of the current configuration into another one.
  110221. * @param anisotropicConfiguration define the config where to copy the info
  110222. */
  110223. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110224. /**
  110225. * Serializes this anisotropy configuration.
  110226. * @returns - An object with the serialized config.
  110227. */
  110228. serialize(): any;
  110229. /**
  110230. * Parses a anisotropy Configuration from a serialized object.
  110231. * @param source - Serialized object.
  110232. * @param scene Defines the scene we are parsing for
  110233. * @param rootUrl Defines the rootUrl to load from
  110234. */
  110235. parse(source: any, scene: Scene, rootUrl: string): void;
  110236. }
  110237. }
  110238. declare module BABYLON {
  110239. /**
  110240. * @hidden
  110241. */
  110242. export interface IMaterialBRDFDefines {
  110243. BRDF_V_HEIGHT_CORRELATED: boolean;
  110244. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110245. SPHERICAL_HARMONICS: boolean;
  110246. /** @hidden */
  110247. _areMiscDirty: boolean;
  110248. }
  110249. /**
  110250. * Define the code related to the BRDF parameters of the pbr material.
  110251. */
  110252. export class PBRBRDFConfiguration {
  110253. /**
  110254. * Default value used for the energy conservation.
  110255. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110256. */
  110257. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110258. /**
  110259. * Default value used for the Smith Visibility Height Correlated mode.
  110260. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110261. */
  110262. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110263. /**
  110264. * Default value used for the IBL diffuse part.
  110265. * This can help switching back to the polynomials mode globally which is a tiny bit
  110266. * less GPU intensive at the drawback of a lower quality.
  110267. */
  110268. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110269. private _useEnergyConservation;
  110270. /**
  110271. * Defines if the material uses energy conservation.
  110272. */
  110273. useEnergyConservation: boolean;
  110274. private _useSmithVisibilityHeightCorrelated;
  110275. /**
  110276. * LEGACY Mode set to false
  110277. * Defines if the material uses height smith correlated visibility term.
  110278. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110279. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110280. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110281. * Not relying on height correlated will also disable energy conservation.
  110282. */
  110283. useSmithVisibilityHeightCorrelated: boolean;
  110284. private _useSphericalHarmonics;
  110285. /**
  110286. * LEGACY Mode set to false
  110287. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110288. * diffuse part of the IBL.
  110289. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110290. * to the ground truth.
  110291. */
  110292. useSphericalHarmonics: boolean;
  110293. /** @hidden */
  110294. private _internalMarkAllSubMeshesAsMiscDirty;
  110295. /** @hidden */
  110296. _markAllSubMeshesAsMiscDirty(): void;
  110297. /**
  110298. * Instantiate a new istance of clear coat configuration.
  110299. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110300. */
  110301. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110302. /**
  110303. * Checks to see if a texture is used in the material.
  110304. * @param defines the list of "defines" to update.
  110305. */
  110306. prepareDefines(defines: IMaterialBRDFDefines): void;
  110307. /**
  110308. * Get the current class name of the texture useful for serialization or dynamic coding.
  110309. * @returns "PBRClearCoatConfiguration"
  110310. */
  110311. getClassName(): string;
  110312. /**
  110313. * Makes a duplicate of the current configuration into another one.
  110314. * @param brdfConfiguration define the config where to copy the info
  110315. */
  110316. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110317. /**
  110318. * Serializes this BRDF configuration.
  110319. * @returns - An object with the serialized config.
  110320. */
  110321. serialize(): any;
  110322. /**
  110323. * Parses a anisotropy Configuration from a serialized object.
  110324. * @param source - Serialized object.
  110325. * @param scene Defines the scene we are parsing for
  110326. * @param rootUrl Defines the rootUrl to load from
  110327. */
  110328. parse(source: any, scene: Scene, rootUrl: string): void;
  110329. }
  110330. }
  110331. declare module BABYLON {
  110332. /**
  110333. * @hidden
  110334. */
  110335. export interface IMaterialSheenDefines {
  110336. SHEEN: boolean;
  110337. SHEEN_TEXTURE: boolean;
  110338. SHEEN_TEXTUREDIRECTUV: number;
  110339. SHEEN_LINKWITHALBEDO: boolean;
  110340. /** @hidden */
  110341. _areTexturesDirty: boolean;
  110342. }
  110343. /**
  110344. * Define the code related to the Sheen parameters of the pbr material.
  110345. */
  110346. export class PBRSheenConfiguration {
  110347. private _isEnabled;
  110348. /**
  110349. * Defines if the material uses sheen.
  110350. */
  110351. isEnabled: boolean;
  110352. private _linkSheenWithAlbedo;
  110353. /**
  110354. * Defines if the sheen is linked to the sheen color.
  110355. */
  110356. linkSheenWithAlbedo: boolean;
  110357. /**
  110358. * Defines the sheen intensity.
  110359. */
  110360. intensity: number;
  110361. /**
  110362. * Defines the sheen color.
  110363. */
  110364. color: Color3;
  110365. private _texture;
  110366. /**
  110367. * Stores the sheen tint values in a texture.
  110368. * rgb is tint
  110369. * a is a intensity
  110370. */
  110371. texture: Nullable<BaseTexture>;
  110372. /** @hidden */
  110373. private _internalMarkAllSubMeshesAsTexturesDirty;
  110374. /** @hidden */
  110375. _markAllSubMeshesAsTexturesDirty(): void;
  110376. /**
  110377. * Instantiate a new istance of clear coat configuration.
  110378. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110379. */
  110380. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110381. /**
  110382. * Specifies that the submesh is ready to be used.
  110383. * @param defines the list of "defines" to update.
  110384. * @param scene defines the scene the material belongs to.
  110385. * @returns - boolean indicating that the submesh is ready or not.
  110386. */
  110387. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110388. /**
  110389. * Checks to see if a texture is used in the material.
  110390. * @param defines the list of "defines" to update.
  110391. * @param scene defines the scene the material belongs to.
  110392. */
  110393. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110394. /**
  110395. * Binds the material data.
  110396. * @param uniformBuffer defines the Uniform buffer to fill in.
  110397. * @param scene defines the scene the material belongs to.
  110398. * @param isFrozen defines wether the material is frozen or not.
  110399. */
  110400. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110401. /**
  110402. * Checks to see if a texture is used in the material.
  110403. * @param texture - Base texture to use.
  110404. * @returns - Boolean specifying if a texture is used in the material.
  110405. */
  110406. hasTexture(texture: BaseTexture): boolean;
  110407. /**
  110408. * Returns an array of the actively used textures.
  110409. * @param activeTextures Array of BaseTextures
  110410. */
  110411. getActiveTextures(activeTextures: BaseTexture[]): void;
  110412. /**
  110413. * Returns the animatable textures.
  110414. * @param animatables Array of animatable textures.
  110415. */
  110416. getAnimatables(animatables: IAnimatable[]): void;
  110417. /**
  110418. * Disposes the resources of the material.
  110419. * @param forceDisposeTextures - Forces the disposal of all textures.
  110420. */
  110421. dispose(forceDisposeTextures?: boolean): void;
  110422. /**
  110423. * Get the current class name of the texture useful for serialization or dynamic coding.
  110424. * @returns "PBRSheenConfiguration"
  110425. */
  110426. getClassName(): string;
  110427. /**
  110428. * Add fallbacks to the effect fallbacks list.
  110429. * @param defines defines the Base texture to use.
  110430. * @param fallbacks defines the current fallback list.
  110431. * @param currentRank defines the current fallback rank.
  110432. * @returns the new fallback rank.
  110433. */
  110434. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110435. /**
  110436. * Add the required uniforms to the current list.
  110437. * @param uniforms defines the current uniform list.
  110438. */
  110439. static AddUniforms(uniforms: string[]): void;
  110440. /**
  110441. * Add the required uniforms to the current buffer.
  110442. * @param uniformBuffer defines the current uniform buffer.
  110443. */
  110444. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110445. /**
  110446. * Add the required samplers to the current list.
  110447. * @param samplers defines the current sampler list.
  110448. */
  110449. static AddSamplers(samplers: string[]): void;
  110450. /**
  110451. * Makes a duplicate of the current configuration into another one.
  110452. * @param sheenConfiguration define the config where to copy the info
  110453. */
  110454. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110455. /**
  110456. * Serializes this BRDF configuration.
  110457. * @returns - An object with the serialized config.
  110458. */
  110459. serialize(): any;
  110460. /**
  110461. * Parses a anisotropy Configuration from a serialized object.
  110462. * @param source - Serialized object.
  110463. * @param scene Defines the scene we are parsing for
  110464. * @param rootUrl Defines the rootUrl to load from
  110465. */
  110466. parse(source: any, scene: Scene, rootUrl: string): void;
  110467. }
  110468. }
  110469. declare module BABYLON {
  110470. /**
  110471. * @hidden
  110472. */
  110473. export interface IMaterialSubSurfaceDefines {
  110474. SUBSURFACE: boolean;
  110475. SS_REFRACTION: boolean;
  110476. SS_TRANSLUCENCY: boolean;
  110477. SS_SCATERRING: boolean;
  110478. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110479. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110480. SS_REFRACTIONMAP_3D: boolean;
  110481. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110482. SS_LODINREFRACTIONALPHA: boolean;
  110483. SS_GAMMAREFRACTION: boolean;
  110484. SS_RGBDREFRACTION: boolean;
  110485. SS_LINEARSPECULARREFRACTION: boolean;
  110486. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110487. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110488. /** @hidden */
  110489. _areTexturesDirty: boolean;
  110490. }
  110491. /**
  110492. * Define the code related to the sub surface parameters of the pbr material.
  110493. */
  110494. export class PBRSubSurfaceConfiguration {
  110495. private _isRefractionEnabled;
  110496. /**
  110497. * Defines if the refraction is enabled in the material.
  110498. */
  110499. isRefractionEnabled: boolean;
  110500. private _isTranslucencyEnabled;
  110501. /**
  110502. * Defines if the translucency is enabled in the material.
  110503. */
  110504. isTranslucencyEnabled: boolean;
  110505. private _isScatteringEnabled;
  110506. /**
  110507. * Defines the refraction intensity of the material.
  110508. * The refraction when enabled replaces the Diffuse part of the material.
  110509. * The intensity helps transitionning between diffuse and refraction.
  110510. */
  110511. refractionIntensity: number;
  110512. /**
  110513. * Defines the translucency intensity of the material.
  110514. * When translucency has been enabled, this defines how much of the "translucency"
  110515. * is addded to the diffuse part of the material.
  110516. */
  110517. translucencyIntensity: number;
  110518. /**
  110519. * Defines the scattering intensity of the material.
  110520. * When scattering has been enabled, this defines how much of the "scattered light"
  110521. * is addded to the diffuse part of the material.
  110522. */
  110523. scatteringIntensity: number;
  110524. private _thicknessTexture;
  110525. /**
  110526. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110527. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110528. * 0 would mean minimumThickness
  110529. * 1 would mean maximumThickness
  110530. * The other channels might be use as a mask to vary the different effects intensity.
  110531. */
  110532. thicknessTexture: Nullable<BaseTexture>;
  110533. private _refractionTexture;
  110534. /**
  110535. * Defines the texture to use for refraction.
  110536. */
  110537. refractionTexture: Nullable<BaseTexture>;
  110538. private _indexOfRefraction;
  110539. /**
  110540. * Defines the index of refraction used in the material.
  110541. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110542. */
  110543. indexOfRefraction: number;
  110544. private _invertRefractionY;
  110545. /**
  110546. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110547. */
  110548. invertRefractionY: boolean;
  110549. private _linkRefractionWithTransparency;
  110550. /**
  110551. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110552. * Materials half opaque for instance using refraction could benefit from this control.
  110553. */
  110554. linkRefractionWithTransparency: boolean;
  110555. /**
  110556. * Defines the minimum thickness stored in the thickness map.
  110557. * If no thickness map is defined, this value will be used to simulate thickness.
  110558. */
  110559. minimumThickness: number;
  110560. /**
  110561. * Defines the maximum thickness stored in the thickness map.
  110562. */
  110563. maximumThickness: number;
  110564. /**
  110565. * Defines the volume tint of the material.
  110566. * This is used for both translucency and scattering.
  110567. */
  110568. tintColor: Color3;
  110569. /**
  110570. * Defines the distance at which the tint color should be found in the media.
  110571. * This is used for refraction only.
  110572. */
  110573. tintColorAtDistance: number;
  110574. /**
  110575. * Defines how far each channel transmit through the media.
  110576. * It is defined as a color to simplify it selection.
  110577. */
  110578. diffusionDistance: Color3;
  110579. private _useMaskFromThicknessTexture;
  110580. /**
  110581. * Stores the intensity of the different subsurface effects in the thickness texture.
  110582. * * the green channel is the translucency intensity.
  110583. * * the blue channel is the scattering intensity.
  110584. * * the alpha channel is the refraction intensity.
  110585. */
  110586. useMaskFromThicknessTexture: boolean;
  110587. /** @hidden */
  110588. private _internalMarkAllSubMeshesAsTexturesDirty;
  110589. /** @hidden */
  110590. _markAllSubMeshesAsTexturesDirty(): void;
  110591. /**
  110592. * Instantiate a new istance of sub surface configuration.
  110593. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110594. */
  110595. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110596. /**
  110597. * Gets wehter the submesh is ready to be used or not.
  110598. * @param defines the list of "defines" to update.
  110599. * @param scene defines the scene the material belongs to.
  110600. * @returns - boolean indicating that the submesh is ready or not.
  110601. */
  110602. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110603. /**
  110604. * Checks to see if a texture is used in the material.
  110605. * @param defines the list of "defines" to update.
  110606. * @param scene defines the scene to the material belongs to.
  110607. */
  110608. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110609. /**
  110610. * Binds the material data.
  110611. * @param uniformBuffer defines the Uniform buffer to fill in.
  110612. * @param scene defines the scene the material belongs to.
  110613. * @param engine defines the engine the material belongs to.
  110614. * @param isFrozen defines wether the material is frozen or not.
  110615. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110616. */
  110617. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110618. /**
  110619. * Unbinds the material from the mesh.
  110620. * @param activeEffect defines the effect that should be unbound from.
  110621. * @returns true if unbound, otherwise false
  110622. */
  110623. unbind(activeEffect: Effect): boolean;
  110624. /**
  110625. * Returns the texture used for refraction or null if none is used.
  110626. * @param scene defines the scene the material belongs to.
  110627. * @returns - Refraction texture if present. If no refraction texture and refraction
  110628. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110629. */
  110630. private _getRefractionTexture;
  110631. /**
  110632. * Returns true if alpha blending should be disabled.
  110633. */
  110634. readonly disableAlphaBlending: boolean;
  110635. /**
  110636. * Fills the list of render target textures.
  110637. * @param renderTargets the list of render targets to update
  110638. */
  110639. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110640. /**
  110641. * Checks to see if a texture is used in the material.
  110642. * @param texture - Base texture to use.
  110643. * @returns - Boolean specifying if a texture is used in the material.
  110644. */
  110645. hasTexture(texture: BaseTexture): boolean;
  110646. /**
  110647. * Gets a boolean indicating that current material needs to register RTT
  110648. * @returns true if this uses a render target otherwise false.
  110649. */
  110650. hasRenderTargetTextures(): boolean;
  110651. /**
  110652. * Returns an array of the actively used textures.
  110653. * @param activeTextures Array of BaseTextures
  110654. */
  110655. getActiveTextures(activeTextures: BaseTexture[]): void;
  110656. /**
  110657. * Returns the animatable textures.
  110658. * @param animatables Array of animatable textures.
  110659. */
  110660. getAnimatables(animatables: IAnimatable[]): void;
  110661. /**
  110662. * Disposes the resources of the material.
  110663. * @param forceDisposeTextures - Forces the disposal of all textures.
  110664. */
  110665. dispose(forceDisposeTextures?: boolean): void;
  110666. /**
  110667. * Get the current class name of the texture useful for serialization or dynamic coding.
  110668. * @returns "PBRSubSurfaceConfiguration"
  110669. */
  110670. getClassName(): string;
  110671. /**
  110672. * Add fallbacks to the effect fallbacks list.
  110673. * @param defines defines the Base texture to use.
  110674. * @param fallbacks defines the current fallback list.
  110675. * @param currentRank defines the current fallback rank.
  110676. * @returns the new fallback rank.
  110677. */
  110678. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110679. /**
  110680. * Add the required uniforms to the current list.
  110681. * @param uniforms defines the current uniform list.
  110682. */
  110683. static AddUniforms(uniforms: string[]): void;
  110684. /**
  110685. * Add the required samplers to the current list.
  110686. * @param samplers defines the current sampler list.
  110687. */
  110688. static AddSamplers(samplers: string[]): void;
  110689. /**
  110690. * Add the required uniforms to the current buffer.
  110691. * @param uniformBuffer defines the current uniform buffer.
  110692. */
  110693. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110694. /**
  110695. * Makes a duplicate of the current configuration into another one.
  110696. * @param configuration define the config where to copy the info
  110697. */
  110698. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110699. /**
  110700. * Serializes this Sub Surface configuration.
  110701. * @returns - An object with the serialized config.
  110702. */
  110703. serialize(): any;
  110704. /**
  110705. * Parses a anisotropy Configuration from a serialized object.
  110706. * @param source - Serialized object.
  110707. * @param scene Defines the scene we are parsing for
  110708. * @param rootUrl Defines the rootUrl to load from
  110709. */
  110710. parse(source: any, scene: Scene, rootUrl: string): void;
  110711. }
  110712. }
  110713. declare module BABYLON {
  110714. /** @hidden */
  110715. export var pbrFragmentDeclaration: {
  110716. name: string;
  110717. shader: string;
  110718. };
  110719. }
  110720. declare module BABYLON {
  110721. /** @hidden */
  110722. export var pbrUboDeclaration: {
  110723. name: string;
  110724. shader: string;
  110725. };
  110726. }
  110727. declare module BABYLON {
  110728. /** @hidden */
  110729. export var pbrFragmentExtraDeclaration: {
  110730. name: string;
  110731. shader: string;
  110732. };
  110733. }
  110734. declare module BABYLON {
  110735. /** @hidden */
  110736. export var pbrFragmentSamplersDeclaration: {
  110737. name: string;
  110738. shader: string;
  110739. };
  110740. }
  110741. declare module BABYLON {
  110742. /** @hidden */
  110743. export var pbrHelperFunctions: {
  110744. name: string;
  110745. shader: string;
  110746. };
  110747. }
  110748. declare module BABYLON {
  110749. /** @hidden */
  110750. export var harmonicsFunctions: {
  110751. name: string;
  110752. shader: string;
  110753. };
  110754. }
  110755. declare module BABYLON {
  110756. /** @hidden */
  110757. export var pbrDirectLightingSetupFunctions: {
  110758. name: string;
  110759. shader: string;
  110760. };
  110761. }
  110762. declare module BABYLON {
  110763. /** @hidden */
  110764. export var pbrDirectLightingFalloffFunctions: {
  110765. name: string;
  110766. shader: string;
  110767. };
  110768. }
  110769. declare module BABYLON {
  110770. /** @hidden */
  110771. export var pbrBRDFFunctions: {
  110772. name: string;
  110773. shader: string;
  110774. };
  110775. }
  110776. declare module BABYLON {
  110777. /** @hidden */
  110778. export var pbrDirectLightingFunctions: {
  110779. name: string;
  110780. shader: string;
  110781. };
  110782. }
  110783. declare module BABYLON {
  110784. /** @hidden */
  110785. export var pbrIBLFunctions: {
  110786. name: string;
  110787. shader: string;
  110788. };
  110789. }
  110790. declare module BABYLON {
  110791. /** @hidden */
  110792. export var pbrDebug: {
  110793. name: string;
  110794. shader: string;
  110795. };
  110796. }
  110797. declare module BABYLON {
  110798. /** @hidden */
  110799. export var pbrPixelShader: {
  110800. name: string;
  110801. shader: string;
  110802. };
  110803. }
  110804. declare module BABYLON {
  110805. /** @hidden */
  110806. export var pbrVertexDeclaration: {
  110807. name: string;
  110808. shader: string;
  110809. };
  110810. }
  110811. declare module BABYLON {
  110812. /** @hidden */
  110813. export var pbrVertexShader: {
  110814. name: string;
  110815. shader: string;
  110816. };
  110817. }
  110818. declare module BABYLON {
  110819. /**
  110820. * Manages the defines for the PBR Material.
  110821. * @hidden
  110822. */
  110823. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110824. PBR: boolean;
  110825. MAINUV1: boolean;
  110826. MAINUV2: boolean;
  110827. UV1: boolean;
  110828. UV2: boolean;
  110829. ALBEDO: boolean;
  110830. ALBEDODIRECTUV: number;
  110831. VERTEXCOLOR: boolean;
  110832. AMBIENT: boolean;
  110833. AMBIENTDIRECTUV: number;
  110834. AMBIENTINGRAYSCALE: boolean;
  110835. OPACITY: boolean;
  110836. VERTEXALPHA: boolean;
  110837. OPACITYDIRECTUV: number;
  110838. OPACITYRGB: boolean;
  110839. ALPHATEST: boolean;
  110840. DEPTHPREPASS: boolean;
  110841. ALPHABLEND: boolean;
  110842. ALPHAFROMALBEDO: boolean;
  110843. ALPHATESTVALUE: string;
  110844. SPECULAROVERALPHA: boolean;
  110845. RADIANCEOVERALPHA: boolean;
  110846. ALPHAFRESNEL: boolean;
  110847. LINEARALPHAFRESNEL: boolean;
  110848. PREMULTIPLYALPHA: boolean;
  110849. EMISSIVE: boolean;
  110850. EMISSIVEDIRECTUV: number;
  110851. REFLECTIVITY: boolean;
  110852. REFLECTIVITYDIRECTUV: number;
  110853. SPECULARTERM: boolean;
  110854. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110855. MICROSURFACEAUTOMATIC: boolean;
  110856. LODBASEDMICROSFURACE: boolean;
  110857. MICROSURFACEMAP: boolean;
  110858. MICROSURFACEMAPDIRECTUV: number;
  110859. METALLICWORKFLOW: boolean;
  110860. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110861. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110862. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110863. AOSTOREINMETALMAPRED: boolean;
  110864. ENVIRONMENTBRDF: boolean;
  110865. ENVIRONMENTBRDF_RGBD: boolean;
  110866. NORMAL: boolean;
  110867. TANGENT: boolean;
  110868. BUMP: boolean;
  110869. BUMPDIRECTUV: number;
  110870. OBJECTSPACE_NORMALMAP: boolean;
  110871. PARALLAX: boolean;
  110872. PARALLAXOCCLUSION: boolean;
  110873. NORMALXYSCALE: boolean;
  110874. LIGHTMAP: boolean;
  110875. LIGHTMAPDIRECTUV: number;
  110876. USELIGHTMAPASSHADOWMAP: boolean;
  110877. GAMMALIGHTMAP: boolean;
  110878. REFLECTION: boolean;
  110879. REFLECTIONMAP_3D: boolean;
  110880. REFLECTIONMAP_SPHERICAL: boolean;
  110881. REFLECTIONMAP_PLANAR: boolean;
  110882. REFLECTIONMAP_CUBIC: boolean;
  110883. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110884. REFLECTIONMAP_PROJECTION: boolean;
  110885. REFLECTIONMAP_SKYBOX: boolean;
  110886. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110887. REFLECTIONMAP_EXPLICIT: boolean;
  110888. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110889. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110890. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110891. INVERTCUBICMAP: boolean;
  110892. USESPHERICALFROMREFLECTIONMAP: boolean;
  110893. USEIRRADIANCEMAP: boolean;
  110894. SPHERICAL_HARMONICS: boolean;
  110895. USESPHERICALINVERTEX: boolean;
  110896. REFLECTIONMAP_OPPOSITEZ: boolean;
  110897. LODINREFLECTIONALPHA: boolean;
  110898. GAMMAREFLECTION: boolean;
  110899. RGBDREFLECTION: boolean;
  110900. LINEARSPECULARREFLECTION: boolean;
  110901. RADIANCEOCCLUSION: boolean;
  110902. HORIZONOCCLUSION: boolean;
  110903. INSTANCES: boolean;
  110904. NUM_BONE_INFLUENCERS: number;
  110905. BonesPerMesh: number;
  110906. BONETEXTURE: boolean;
  110907. NONUNIFORMSCALING: boolean;
  110908. MORPHTARGETS: boolean;
  110909. MORPHTARGETS_NORMAL: boolean;
  110910. MORPHTARGETS_TANGENT: boolean;
  110911. MORPHTARGETS_UV: boolean;
  110912. NUM_MORPH_INFLUENCERS: number;
  110913. IMAGEPROCESSING: boolean;
  110914. VIGNETTE: boolean;
  110915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110916. VIGNETTEBLENDMODEOPAQUE: boolean;
  110917. TONEMAPPING: boolean;
  110918. TONEMAPPING_ACES: boolean;
  110919. CONTRAST: boolean;
  110920. COLORCURVES: boolean;
  110921. COLORGRADING: boolean;
  110922. COLORGRADING3D: boolean;
  110923. SAMPLER3DGREENDEPTH: boolean;
  110924. SAMPLER3DBGRMAP: boolean;
  110925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110926. EXPOSURE: boolean;
  110927. MULTIVIEW: boolean;
  110928. USEPHYSICALLIGHTFALLOFF: boolean;
  110929. USEGLTFLIGHTFALLOFF: boolean;
  110930. TWOSIDEDLIGHTING: boolean;
  110931. SHADOWFLOAT: boolean;
  110932. CLIPPLANE: boolean;
  110933. CLIPPLANE2: boolean;
  110934. CLIPPLANE3: boolean;
  110935. CLIPPLANE4: boolean;
  110936. POINTSIZE: boolean;
  110937. FOG: boolean;
  110938. LOGARITHMICDEPTH: boolean;
  110939. FORCENORMALFORWARD: boolean;
  110940. SPECULARAA: boolean;
  110941. CLEARCOAT: boolean;
  110942. CLEARCOAT_DEFAULTIOR: boolean;
  110943. CLEARCOAT_TEXTURE: boolean;
  110944. CLEARCOAT_TEXTUREDIRECTUV: number;
  110945. CLEARCOAT_BUMP: boolean;
  110946. CLEARCOAT_BUMPDIRECTUV: number;
  110947. CLEARCOAT_TINT: boolean;
  110948. CLEARCOAT_TINT_TEXTURE: boolean;
  110949. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110950. ANISOTROPIC: boolean;
  110951. ANISOTROPIC_TEXTURE: boolean;
  110952. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110953. BRDF_V_HEIGHT_CORRELATED: boolean;
  110954. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110955. SHEEN: boolean;
  110956. SHEEN_TEXTURE: boolean;
  110957. SHEEN_TEXTUREDIRECTUV: number;
  110958. SHEEN_LINKWITHALBEDO: boolean;
  110959. SUBSURFACE: boolean;
  110960. SS_REFRACTION: boolean;
  110961. SS_TRANSLUCENCY: boolean;
  110962. SS_SCATERRING: boolean;
  110963. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110964. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110965. SS_REFRACTIONMAP_3D: boolean;
  110966. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110967. SS_LODINREFRACTIONALPHA: boolean;
  110968. SS_GAMMAREFRACTION: boolean;
  110969. SS_RGBDREFRACTION: boolean;
  110970. SS_LINEARSPECULARREFRACTION: boolean;
  110971. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110972. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110973. UNLIT: boolean;
  110974. DEBUGMODE: number;
  110975. /**
  110976. * Initializes the PBR Material defines.
  110977. */
  110978. constructor();
  110979. /**
  110980. * Resets the PBR Material defines.
  110981. */
  110982. reset(): void;
  110983. }
  110984. /**
  110985. * The Physically based material base class of BJS.
  110986. *
  110987. * This offers the main features of a standard PBR material.
  110988. * For more information, please refer to the documentation :
  110989. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110990. */
  110991. export abstract class PBRBaseMaterial extends PushMaterial {
  110992. /**
  110993. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110994. */
  110995. static readonly PBRMATERIAL_OPAQUE: number;
  110996. /**
  110997. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110998. */
  110999. static readonly PBRMATERIAL_ALPHATEST: number;
  111000. /**
  111001. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111002. */
  111003. static readonly PBRMATERIAL_ALPHABLEND: number;
  111004. /**
  111005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111006. * They are also discarded below the alpha cutoff threshold to improve performances.
  111007. */
  111008. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111009. /**
  111010. * Defines the default value of how much AO map is occluding the analytical lights
  111011. * (point spot...).
  111012. */
  111013. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111014. /**
  111015. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111016. */
  111017. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111018. /**
  111019. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111020. * to enhance interoperability with other engines.
  111021. */
  111022. static readonly LIGHTFALLOFF_GLTF: number;
  111023. /**
  111024. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111025. * to enhance interoperability with other materials.
  111026. */
  111027. static readonly LIGHTFALLOFF_STANDARD: number;
  111028. /**
  111029. * Intensity of the direct lights e.g. the four lights available in your scene.
  111030. * This impacts both the direct diffuse and specular highlights.
  111031. */
  111032. protected _directIntensity: number;
  111033. /**
  111034. * Intensity of the emissive part of the material.
  111035. * This helps controlling the emissive effect without modifying the emissive color.
  111036. */
  111037. protected _emissiveIntensity: number;
  111038. /**
  111039. * Intensity of the environment e.g. how much the environment will light the object
  111040. * either through harmonics for rough material or through the refelction for shiny ones.
  111041. */
  111042. protected _environmentIntensity: number;
  111043. /**
  111044. * This is a special control allowing the reduction of the specular highlights coming from the
  111045. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111046. */
  111047. protected _specularIntensity: number;
  111048. /**
  111049. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111050. */
  111051. private _lightingInfos;
  111052. /**
  111053. * Debug Control allowing disabling the bump map on this material.
  111054. */
  111055. protected _disableBumpMap: boolean;
  111056. /**
  111057. * AKA Diffuse Texture in standard nomenclature.
  111058. */
  111059. protected _albedoTexture: Nullable<BaseTexture>;
  111060. /**
  111061. * AKA Occlusion Texture in other nomenclature.
  111062. */
  111063. protected _ambientTexture: Nullable<BaseTexture>;
  111064. /**
  111065. * AKA Occlusion Texture Intensity in other nomenclature.
  111066. */
  111067. protected _ambientTextureStrength: number;
  111068. /**
  111069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111070. * 1 means it completely occludes it
  111071. * 0 mean it has no impact
  111072. */
  111073. protected _ambientTextureImpactOnAnalyticalLights: number;
  111074. /**
  111075. * Stores the alpha values in a texture.
  111076. */
  111077. protected _opacityTexture: Nullable<BaseTexture>;
  111078. /**
  111079. * Stores the reflection values in a texture.
  111080. */
  111081. protected _reflectionTexture: Nullable<BaseTexture>;
  111082. /**
  111083. * Stores the emissive values in a texture.
  111084. */
  111085. protected _emissiveTexture: Nullable<BaseTexture>;
  111086. /**
  111087. * AKA Specular texture in other nomenclature.
  111088. */
  111089. protected _reflectivityTexture: Nullable<BaseTexture>;
  111090. /**
  111091. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111092. */
  111093. protected _metallicTexture: Nullable<BaseTexture>;
  111094. /**
  111095. * Specifies the metallic scalar of the metallic/roughness workflow.
  111096. * Can also be used to scale the metalness values of the metallic texture.
  111097. */
  111098. protected _metallic: Nullable<number>;
  111099. /**
  111100. * Specifies the roughness scalar of the metallic/roughness workflow.
  111101. * Can also be used to scale the roughness values of the metallic texture.
  111102. */
  111103. protected _roughness: Nullable<number>;
  111104. /**
  111105. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111106. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111107. */
  111108. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111109. /**
  111110. * Stores surface normal data used to displace a mesh in a texture.
  111111. */
  111112. protected _bumpTexture: Nullable<BaseTexture>;
  111113. /**
  111114. * Stores the pre-calculated light information of a mesh in a texture.
  111115. */
  111116. protected _lightmapTexture: Nullable<BaseTexture>;
  111117. /**
  111118. * The color of a material in ambient lighting.
  111119. */
  111120. protected _ambientColor: Color3;
  111121. /**
  111122. * AKA Diffuse Color in other nomenclature.
  111123. */
  111124. protected _albedoColor: Color3;
  111125. /**
  111126. * AKA Specular Color in other nomenclature.
  111127. */
  111128. protected _reflectivityColor: Color3;
  111129. /**
  111130. * The color applied when light is reflected from a material.
  111131. */
  111132. protected _reflectionColor: Color3;
  111133. /**
  111134. * The color applied when light is emitted from a material.
  111135. */
  111136. protected _emissiveColor: Color3;
  111137. /**
  111138. * AKA Glossiness in other nomenclature.
  111139. */
  111140. protected _microSurface: number;
  111141. /**
  111142. * Specifies that the material will use the light map as a show map.
  111143. */
  111144. protected _useLightmapAsShadowmap: boolean;
  111145. /**
  111146. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111147. * makes the reflect vector face the model (under horizon).
  111148. */
  111149. protected _useHorizonOcclusion: boolean;
  111150. /**
  111151. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111152. * too much the area relying on ambient texture to define their ambient occlusion.
  111153. */
  111154. protected _useRadianceOcclusion: boolean;
  111155. /**
  111156. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111157. */
  111158. protected _useAlphaFromAlbedoTexture: boolean;
  111159. /**
  111160. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111161. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111162. */
  111163. protected _useSpecularOverAlpha: boolean;
  111164. /**
  111165. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111166. */
  111167. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111168. /**
  111169. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111170. */
  111171. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111172. /**
  111173. * Specifies if the metallic texture contains the roughness information in its green channel.
  111174. */
  111175. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111176. /**
  111177. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111178. */
  111179. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111180. /**
  111181. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111182. */
  111183. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111184. /**
  111185. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111186. */
  111187. protected _useAmbientInGrayScale: boolean;
  111188. /**
  111189. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111190. * The material will try to infer what glossiness each pixel should be.
  111191. */
  111192. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111193. /**
  111194. * Defines the falloff type used in this material.
  111195. * It by default is Physical.
  111196. */
  111197. protected _lightFalloff: number;
  111198. /**
  111199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111201. */
  111202. protected _useRadianceOverAlpha: boolean;
  111203. /**
  111204. * Allows using an object space normal map (instead of tangent space).
  111205. */
  111206. protected _useObjectSpaceNormalMap: boolean;
  111207. /**
  111208. * Allows using the bump map in parallax mode.
  111209. */
  111210. protected _useParallax: boolean;
  111211. /**
  111212. * Allows using the bump map in parallax occlusion mode.
  111213. */
  111214. protected _useParallaxOcclusion: boolean;
  111215. /**
  111216. * Controls the scale bias of the parallax mode.
  111217. */
  111218. protected _parallaxScaleBias: number;
  111219. /**
  111220. * If sets to true, disables all the lights affecting the material.
  111221. */
  111222. protected _disableLighting: boolean;
  111223. /**
  111224. * Number of Simultaneous lights allowed on the material.
  111225. */
  111226. protected _maxSimultaneousLights: number;
  111227. /**
  111228. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111229. */
  111230. protected _invertNormalMapX: boolean;
  111231. /**
  111232. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111233. */
  111234. protected _invertNormalMapY: boolean;
  111235. /**
  111236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111237. */
  111238. protected _twoSidedLighting: boolean;
  111239. /**
  111240. * Defines the alpha limits in alpha test mode.
  111241. */
  111242. protected _alphaCutOff: number;
  111243. /**
  111244. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111245. */
  111246. protected _forceAlphaTest: boolean;
  111247. /**
  111248. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111249. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111250. */
  111251. protected _useAlphaFresnel: boolean;
  111252. /**
  111253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111254. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111255. */
  111256. protected _useLinearAlphaFresnel: boolean;
  111257. /**
  111258. * The transparency mode of the material.
  111259. */
  111260. protected _transparencyMode: Nullable<number>;
  111261. /**
  111262. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111263. * from cos thetav and roughness:
  111264. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111265. */
  111266. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111267. /**
  111268. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111269. */
  111270. protected _forceIrradianceInFragment: boolean;
  111271. /**
  111272. * Force normal to face away from face.
  111273. */
  111274. protected _forceNormalForward: boolean;
  111275. /**
  111276. * Enables specular anti aliasing in the PBR shader.
  111277. * It will both interacts on the Geometry for analytical and IBL lighting.
  111278. * It also prefilter the roughness map based on the bump values.
  111279. */
  111280. protected _enableSpecularAntiAliasing: boolean;
  111281. /**
  111282. * Default configuration related to image processing available in the PBR Material.
  111283. */
  111284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111285. /**
  111286. * Keep track of the image processing observer to allow dispose and replace.
  111287. */
  111288. private _imageProcessingObserver;
  111289. /**
  111290. * Attaches a new image processing configuration to the PBR Material.
  111291. * @param configuration
  111292. */
  111293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111294. /**
  111295. * Stores the available render targets.
  111296. */
  111297. private _renderTargets;
  111298. /**
  111299. * Sets the global ambient color for the material used in lighting calculations.
  111300. */
  111301. private _globalAmbientColor;
  111302. /**
  111303. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111304. */
  111305. private _useLogarithmicDepth;
  111306. /**
  111307. * If set to true, no lighting calculations will be applied.
  111308. */
  111309. private _unlit;
  111310. private _debugMode;
  111311. /**
  111312. * @hidden
  111313. * This is reserved for the inspector.
  111314. * Defines the material debug mode.
  111315. * It helps seeing only some components of the material while troubleshooting.
  111316. */
  111317. debugMode: number;
  111318. /**
  111319. * @hidden
  111320. * This is reserved for the inspector.
  111321. * Specify from where on screen the debug mode should start.
  111322. * The value goes from -1 (full screen) to 1 (not visible)
  111323. * It helps with side by side comparison against the final render
  111324. * This defaults to -1
  111325. */
  111326. private debugLimit;
  111327. /**
  111328. * @hidden
  111329. * This is reserved for the inspector.
  111330. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111331. * You can use the factor to better multiply the final value.
  111332. */
  111333. private debugFactor;
  111334. /**
  111335. * Defines the clear coat layer parameters for the material.
  111336. */
  111337. readonly clearCoat: PBRClearCoatConfiguration;
  111338. /**
  111339. * Defines the anisotropic parameters for the material.
  111340. */
  111341. readonly anisotropy: PBRAnisotropicConfiguration;
  111342. /**
  111343. * Defines the BRDF parameters for the material.
  111344. */
  111345. readonly brdf: PBRBRDFConfiguration;
  111346. /**
  111347. * Defines the Sheen parameters for the material.
  111348. */
  111349. readonly sheen: PBRSheenConfiguration;
  111350. /**
  111351. * Defines the SubSurface parameters for the material.
  111352. */
  111353. readonly subSurface: PBRSubSurfaceConfiguration;
  111354. /**
  111355. * Custom callback helping to override the default shader used in the material.
  111356. */
  111357. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111358. /**
  111359. * Instantiates a new PBRMaterial instance.
  111360. *
  111361. * @param name The material name
  111362. * @param scene The scene the material will be use in.
  111363. */
  111364. constructor(name: string, scene: Scene);
  111365. /**
  111366. * Gets a boolean indicating that current material needs to register RTT
  111367. */
  111368. readonly hasRenderTargetTextures: boolean;
  111369. /**
  111370. * Gets the name of the material class.
  111371. */
  111372. getClassName(): string;
  111373. /**
  111374. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111375. */
  111376. /**
  111377. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111378. */
  111379. useLogarithmicDepth: boolean;
  111380. /**
  111381. * Gets the current transparency mode.
  111382. */
  111383. /**
  111384. * Sets the transparency mode of the material.
  111385. *
  111386. * | Value | Type | Description |
  111387. * | ----- | ----------------------------------- | ----------- |
  111388. * | 0 | OPAQUE | |
  111389. * | 1 | ALPHATEST | |
  111390. * | 2 | ALPHABLEND | |
  111391. * | 3 | ALPHATESTANDBLEND | |
  111392. *
  111393. */
  111394. transparencyMode: Nullable<number>;
  111395. /**
  111396. * Returns true if alpha blending should be disabled.
  111397. */
  111398. private readonly _disableAlphaBlending;
  111399. /**
  111400. * Specifies whether or not this material should be rendered in alpha blend mode.
  111401. */
  111402. needAlphaBlending(): boolean;
  111403. /**
  111404. * Specifies if the mesh will require alpha blending.
  111405. * @param mesh - BJS mesh.
  111406. */
  111407. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111408. /**
  111409. * Specifies whether or not this material should be rendered in alpha test mode.
  111410. */
  111411. needAlphaTesting(): boolean;
  111412. /**
  111413. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111414. */
  111415. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111416. /**
  111417. * Gets the texture used for the alpha test.
  111418. */
  111419. getAlphaTestTexture(): Nullable<BaseTexture>;
  111420. /**
  111421. * Specifies that the submesh is ready to be used.
  111422. * @param mesh - BJS mesh.
  111423. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111424. * @param useInstances - Specifies that instances should be used.
  111425. * @returns - boolean indicating that the submesh is ready or not.
  111426. */
  111427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111428. /**
  111429. * Specifies if the material uses metallic roughness workflow.
  111430. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111431. */
  111432. isMetallicWorkflow(): boolean;
  111433. private _prepareEffect;
  111434. private _prepareDefines;
  111435. /**
  111436. * Force shader compilation
  111437. */
  111438. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111439. clipPlane: boolean;
  111440. }>): void;
  111441. /**
  111442. * Initializes the uniform buffer layout for the shader.
  111443. */
  111444. buildUniformLayout(): void;
  111445. /**
  111446. * Unbinds the material from the mesh
  111447. */
  111448. unbind(): void;
  111449. /**
  111450. * Binds the submesh data.
  111451. * @param world - The world matrix.
  111452. * @param mesh - The BJS mesh.
  111453. * @param subMesh - A submesh of the BJS mesh.
  111454. */
  111455. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111456. /**
  111457. * Returns the animatable textures.
  111458. * @returns - Array of animatable textures.
  111459. */
  111460. getAnimatables(): IAnimatable[];
  111461. /**
  111462. * Returns the texture used for reflections.
  111463. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111464. */
  111465. private _getReflectionTexture;
  111466. /**
  111467. * Returns an array of the actively used textures.
  111468. * @returns - Array of BaseTextures
  111469. */
  111470. getActiveTextures(): BaseTexture[];
  111471. /**
  111472. * Checks to see if a texture is used in the material.
  111473. * @param texture - Base texture to use.
  111474. * @returns - Boolean specifying if a texture is used in the material.
  111475. */
  111476. hasTexture(texture: BaseTexture): boolean;
  111477. /**
  111478. * Disposes the resources of the material.
  111479. * @param forceDisposeEffect - Forces the disposal of effects.
  111480. * @param forceDisposeTextures - Forces the disposal of all textures.
  111481. */
  111482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111483. }
  111484. }
  111485. declare module BABYLON {
  111486. /**
  111487. * The Physically based material of BJS.
  111488. *
  111489. * This offers the main features of a standard PBR material.
  111490. * For more information, please refer to the documentation :
  111491. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111492. */
  111493. export class PBRMaterial extends PBRBaseMaterial {
  111494. /**
  111495. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111496. */
  111497. static readonly PBRMATERIAL_OPAQUE: number;
  111498. /**
  111499. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111500. */
  111501. static readonly PBRMATERIAL_ALPHATEST: number;
  111502. /**
  111503. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111504. */
  111505. static readonly PBRMATERIAL_ALPHABLEND: number;
  111506. /**
  111507. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111508. * They are also discarded below the alpha cutoff threshold to improve performances.
  111509. */
  111510. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111511. /**
  111512. * Defines the default value of how much AO map is occluding the analytical lights
  111513. * (point spot...).
  111514. */
  111515. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111516. /**
  111517. * Intensity of the direct lights e.g. the four lights available in your scene.
  111518. * This impacts both the direct diffuse and specular highlights.
  111519. */
  111520. directIntensity: number;
  111521. /**
  111522. * Intensity of the emissive part of the material.
  111523. * This helps controlling the emissive effect without modifying the emissive color.
  111524. */
  111525. emissiveIntensity: number;
  111526. /**
  111527. * Intensity of the environment e.g. how much the environment will light the object
  111528. * either through harmonics for rough material or through the refelction for shiny ones.
  111529. */
  111530. environmentIntensity: number;
  111531. /**
  111532. * This is a special control allowing the reduction of the specular highlights coming from the
  111533. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111534. */
  111535. specularIntensity: number;
  111536. /**
  111537. * Debug Control allowing disabling the bump map on this material.
  111538. */
  111539. disableBumpMap: boolean;
  111540. /**
  111541. * AKA Diffuse Texture in standard nomenclature.
  111542. */
  111543. albedoTexture: BaseTexture;
  111544. /**
  111545. * AKA Occlusion Texture in other nomenclature.
  111546. */
  111547. ambientTexture: BaseTexture;
  111548. /**
  111549. * AKA Occlusion Texture Intensity in other nomenclature.
  111550. */
  111551. ambientTextureStrength: number;
  111552. /**
  111553. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111554. * 1 means it completely occludes it
  111555. * 0 mean it has no impact
  111556. */
  111557. ambientTextureImpactOnAnalyticalLights: number;
  111558. /**
  111559. * Stores the alpha values in a texture.
  111560. */
  111561. opacityTexture: BaseTexture;
  111562. /**
  111563. * Stores the reflection values in a texture.
  111564. */
  111565. reflectionTexture: Nullable<BaseTexture>;
  111566. /**
  111567. * Stores the emissive values in a texture.
  111568. */
  111569. emissiveTexture: BaseTexture;
  111570. /**
  111571. * AKA Specular texture in other nomenclature.
  111572. */
  111573. reflectivityTexture: BaseTexture;
  111574. /**
  111575. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111576. */
  111577. metallicTexture: BaseTexture;
  111578. /**
  111579. * Specifies the metallic scalar of the metallic/roughness workflow.
  111580. * Can also be used to scale the metalness values of the metallic texture.
  111581. */
  111582. metallic: Nullable<number>;
  111583. /**
  111584. * Specifies the roughness scalar of the metallic/roughness workflow.
  111585. * Can also be used to scale the roughness values of the metallic texture.
  111586. */
  111587. roughness: Nullable<number>;
  111588. /**
  111589. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111590. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111591. */
  111592. microSurfaceTexture: BaseTexture;
  111593. /**
  111594. * Stores surface normal data used to displace a mesh in a texture.
  111595. */
  111596. bumpTexture: BaseTexture;
  111597. /**
  111598. * Stores the pre-calculated light information of a mesh in a texture.
  111599. */
  111600. lightmapTexture: BaseTexture;
  111601. /**
  111602. * Stores the refracted light information in a texture.
  111603. */
  111604. refractionTexture: Nullable<BaseTexture>;
  111605. /**
  111606. * The color of a material in ambient lighting.
  111607. */
  111608. ambientColor: Color3;
  111609. /**
  111610. * AKA Diffuse Color in other nomenclature.
  111611. */
  111612. albedoColor: Color3;
  111613. /**
  111614. * AKA Specular Color in other nomenclature.
  111615. */
  111616. reflectivityColor: Color3;
  111617. /**
  111618. * The color reflected from the material.
  111619. */
  111620. reflectionColor: Color3;
  111621. /**
  111622. * The color emitted from the material.
  111623. */
  111624. emissiveColor: Color3;
  111625. /**
  111626. * AKA Glossiness in other nomenclature.
  111627. */
  111628. microSurface: number;
  111629. /**
  111630. * source material index of refraction (IOR)' / 'destination material IOR.
  111631. */
  111632. indexOfRefraction: number;
  111633. /**
  111634. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111635. */
  111636. invertRefractionY: boolean;
  111637. /**
  111638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111639. * Materials half opaque for instance using refraction could benefit from this control.
  111640. */
  111641. linkRefractionWithTransparency: boolean;
  111642. /**
  111643. * If true, the light map contains occlusion information instead of lighting info.
  111644. */
  111645. useLightmapAsShadowmap: boolean;
  111646. /**
  111647. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111648. */
  111649. useAlphaFromAlbedoTexture: boolean;
  111650. /**
  111651. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111652. */
  111653. forceAlphaTest: boolean;
  111654. /**
  111655. * Defines the alpha limits in alpha test mode.
  111656. */
  111657. alphaCutOff: number;
  111658. /**
  111659. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111661. */
  111662. useSpecularOverAlpha: boolean;
  111663. /**
  111664. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111665. */
  111666. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111667. /**
  111668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111669. */
  111670. useRoughnessFromMetallicTextureAlpha: boolean;
  111671. /**
  111672. * Specifies if the metallic texture contains the roughness information in its green channel.
  111673. */
  111674. useRoughnessFromMetallicTextureGreen: boolean;
  111675. /**
  111676. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111677. */
  111678. useMetallnessFromMetallicTextureBlue: boolean;
  111679. /**
  111680. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111681. */
  111682. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111683. /**
  111684. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111685. */
  111686. useAmbientInGrayScale: boolean;
  111687. /**
  111688. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111689. * The material will try to infer what glossiness each pixel should be.
  111690. */
  111691. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111692. /**
  111693. * BJS is using an harcoded light falloff based on a manually sets up range.
  111694. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111695. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111696. */
  111697. /**
  111698. * BJS is using an harcoded light falloff based on a manually sets up range.
  111699. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111700. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111701. */
  111702. usePhysicalLightFalloff: boolean;
  111703. /**
  111704. * In order to support the falloff compatibility with gltf, a special mode has been added
  111705. * to reproduce the gltf light falloff.
  111706. */
  111707. /**
  111708. * In order to support the falloff compatibility with gltf, a special mode has been added
  111709. * to reproduce the gltf light falloff.
  111710. */
  111711. useGLTFLightFalloff: boolean;
  111712. /**
  111713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111715. */
  111716. useRadianceOverAlpha: boolean;
  111717. /**
  111718. * Allows using an object space normal map (instead of tangent space).
  111719. */
  111720. useObjectSpaceNormalMap: boolean;
  111721. /**
  111722. * Allows using the bump map in parallax mode.
  111723. */
  111724. useParallax: boolean;
  111725. /**
  111726. * Allows using the bump map in parallax occlusion mode.
  111727. */
  111728. useParallaxOcclusion: boolean;
  111729. /**
  111730. * Controls the scale bias of the parallax mode.
  111731. */
  111732. parallaxScaleBias: number;
  111733. /**
  111734. * If sets to true, disables all the lights affecting the material.
  111735. */
  111736. disableLighting: boolean;
  111737. /**
  111738. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111739. */
  111740. forceIrradianceInFragment: boolean;
  111741. /**
  111742. * Number of Simultaneous lights allowed on the material.
  111743. */
  111744. maxSimultaneousLights: number;
  111745. /**
  111746. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111747. */
  111748. invertNormalMapX: boolean;
  111749. /**
  111750. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111751. */
  111752. invertNormalMapY: boolean;
  111753. /**
  111754. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111755. */
  111756. twoSidedLighting: boolean;
  111757. /**
  111758. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111759. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111760. */
  111761. useAlphaFresnel: boolean;
  111762. /**
  111763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111764. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111765. */
  111766. useLinearAlphaFresnel: boolean;
  111767. /**
  111768. * Let user defines the brdf lookup texture used for IBL.
  111769. * A default 8bit version is embedded but you could point at :
  111770. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111771. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111772. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111773. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111774. */
  111775. environmentBRDFTexture: Nullable<BaseTexture>;
  111776. /**
  111777. * Force normal to face away from face.
  111778. */
  111779. forceNormalForward: boolean;
  111780. /**
  111781. * Enables specular anti aliasing in the PBR shader.
  111782. * It will both interacts on the Geometry for analytical and IBL lighting.
  111783. * It also prefilter the roughness map based on the bump values.
  111784. */
  111785. enableSpecularAntiAliasing: boolean;
  111786. /**
  111787. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111788. * makes the reflect vector face the model (under horizon).
  111789. */
  111790. useHorizonOcclusion: boolean;
  111791. /**
  111792. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111793. * too much the area relying on ambient texture to define their ambient occlusion.
  111794. */
  111795. useRadianceOcclusion: boolean;
  111796. /**
  111797. * If set to true, no lighting calculations will be applied.
  111798. */
  111799. unlit: boolean;
  111800. /**
  111801. * Gets the image processing configuration used either in this material.
  111802. */
  111803. /**
  111804. * Sets the Default image processing configuration used either in the this material.
  111805. *
  111806. * If sets to null, the scene one is in use.
  111807. */
  111808. imageProcessingConfiguration: ImageProcessingConfiguration;
  111809. /**
  111810. * Gets wether the color curves effect is enabled.
  111811. */
  111812. /**
  111813. * Sets wether the color curves effect is enabled.
  111814. */
  111815. cameraColorCurvesEnabled: boolean;
  111816. /**
  111817. * Gets wether the color grading effect is enabled.
  111818. */
  111819. /**
  111820. * Gets wether the color grading effect is enabled.
  111821. */
  111822. cameraColorGradingEnabled: boolean;
  111823. /**
  111824. * Gets wether tonemapping is enabled or not.
  111825. */
  111826. /**
  111827. * Sets wether tonemapping is enabled or not
  111828. */
  111829. cameraToneMappingEnabled: boolean;
  111830. /**
  111831. * The camera exposure used on this material.
  111832. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111833. * This corresponds to a photographic exposure.
  111834. */
  111835. /**
  111836. * The camera exposure used on this material.
  111837. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111838. * This corresponds to a photographic exposure.
  111839. */
  111840. cameraExposure: number;
  111841. /**
  111842. * Gets The camera contrast used on this material.
  111843. */
  111844. /**
  111845. * Sets The camera contrast used on this material.
  111846. */
  111847. cameraContrast: number;
  111848. /**
  111849. * Gets the Color Grading 2D Lookup Texture.
  111850. */
  111851. /**
  111852. * Sets the Color Grading 2D Lookup Texture.
  111853. */
  111854. cameraColorGradingTexture: Nullable<BaseTexture>;
  111855. /**
  111856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111858. * 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;
  111859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111860. */
  111861. /**
  111862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111864. * 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;
  111865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111866. */
  111867. cameraColorCurves: Nullable<ColorCurves>;
  111868. /**
  111869. * Instantiates a new PBRMaterial instance.
  111870. *
  111871. * @param name The material name
  111872. * @param scene The scene the material will be use in.
  111873. */
  111874. constructor(name: string, scene: Scene);
  111875. /**
  111876. * Returns the name of this material class.
  111877. */
  111878. getClassName(): string;
  111879. /**
  111880. * Makes a duplicate of the current material.
  111881. * @param name - name to use for the new material.
  111882. */
  111883. clone(name: string): PBRMaterial;
  111884. /**
  111885. * Serializes this PBR Material.
  111886. * @returns - An object with the serialized material.
  111887. */
  111888. serialize(): any;
  111889. /**
  111890. * Parses a PBR Material from a serialized object.
  111891. * @param source - Serialized object.
  111892. * @param scene - BJS scene instance.
  111893. * @param rootUrl - url for the scene object
  111894. * @returns - PBRMaterial
  111895. */
  111896. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111897. }
  111898. }
  111899. declare module BABYLON {
  111900. /**
  111901. * Direct draw surface info
  111902. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111903. */
  111904. export interface DDSInfo {
  111905. /**
  111906. * Width of the texture
  111907. */
  111908. width: number;
  111909. /**
  111910. * Width of the texture
  111911. */
  111912. height: number;
  111913. /**
  111914. * Number of Mipmaps for the texture
  111915. * @see https://en.wikipedia.org/wiki/Mipmap
  111916. */
  111917. mipmapCount: number;
  111918. /**
  111919. * If the textures format is a known fourCC format
  111920. * @see https://www.fourcc.org/
  111921. */
  111922. isFourCC: boolean;
  111923. /**
  111924. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111925. */
  111926. isRGB: boolean;
  111927. /**
  111928. * If the texture is a lumincance format
  111929. */
  111930. isLuminance: boolean;
  111931. /**
  111932. * If this is a cube texture
  111933. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111934. */
  111935. isCube: boolean;
  111936. /**
  111937. * If the texture is a compressed format eg. FOURCC_DXT1
  111938. */
  111939. isCompressed: boolean;
  111940. /**
  111941. * The dxgiFormat of the texture
  111942. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111943. */
  111944. dxgiFormat: number;
  111945. /**
  111946. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111947. */
  111948. textureType: number;
  111949. /**
  111950. * Sphericle polynomial created for the dds texture
  111951. */
  111952. sphericalPolynomial?: SphericalPolynomial;
  111953. }
  111954. /**
  111955. * Class used to provide DDS decompression tools
  111956. */
  111957. export class DDSTools {
  111958. /**
  111959. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111960. */
  111961. static StoreLODInAlphaChannel: boolean;
  111962. /**
  111963. * Gets DDS information from an array buffer
  111964. * @param arrayBuffer defines the array buffer to read data from
  111965. * @returns the DDS information
  111966. */
  111967. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111968. private static _FloatView;
  111969. private static _Int32View;
  111970. private static _ToHalfFloat;
  111971. private static _FromHalfFloat;
  111972. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111973. private static _GetHalfFloatRGBAArrayBuffer;
  111974. private static _GetFloatRGBAArrayBuffer;
  111975. private static _GetFloatAsUIntRGBAArrayBuffer;
  111976. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111977. private static _GetRGBAArrayBuffer;
  111978. private static _ExtractLongWordOrder;
  111979. private static _GetRGBArrayBuffer;
  111980. private static _GetLuminanceArrayBuffer;
  111981. /**
  111982. * Uploads DDS Levels to a Babylon Texture
  111983. * @hidden
  111984. */
  111985. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111986. }
  111987. interface Engine {
  111988. /**
  111989. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111990. * @param rootUrl defines the url where the file to load is located
  111991. * @param scene defines the current scene
  111992. * @param lodScale defines scale to apply to the mip map selection
  111993. * @param lodOffset defines offset to apply to the mip map selection
  111994. * @param onLoad defines an optional callback raised when the texture is loaded
  111995. * @param onError defines an optional callback raised if there is an issue to load the texture
  111996. * @param format defines the format of the data
  111997. * @param forcedExtension defines the extension to use to pick the right loader
  111998. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111999. * @returns the cube texture as an InternalTexture
  112000. */
  112001. 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;
  112002. }
  112003. }
  112004. declare module BABYLON {
  112005. /**
  112006. * Implementation of the DDS Texture Loader.
  112007. * @hidden
  112008. */
  112009. export class _DDSTextureLoader implements IInternalTextureLoader {
  112010. /**
  112011. * Defines wether the loader supports cascade loading the different faces.
  112012. */
  112013. readonly supportCascades: boolean;
  112014. /**
  112015. * This returns if the loader support the current file information.
  112016. * @param extension defines the file extension of the file being loaded
  112017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112018. * @param fallback defines the fallback internal texture if any
  112019. * @param isBase64 defines whether the texture is encoded as a base64
  112020. * @param isBuffer defines whether the texture data are stored as a buffer
  112021. * @returns true if the loader can load the specified file
  112022. */
  112023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112024. /**
  112025. * Transform the url before loading if required.
  112026. * @param rootUrl the url of the texture
  112027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112028. * @returns the transformed texture
  112029. */
  112030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112031. /**
  112032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112033. * @param rootUrl the url of the texture
  112034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112035. * @returns the fallback texture
  112036. */
  112037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112038. /**
  112039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112040. * @param data contains the texture data
  112041. * @param texture defines the BabylonJS internal texture
  112042. * @param createPolynomials will be true if polynomials have been requested
  112043. * @param onLoad defines the callback to trigger once the texture is ready
  112044. * @param onError defines the callback to trigger in case of error
  112045. */
  112046. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112047. /**
  112048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112049. * @param data contains the texture data
  112050. * @param texture defines the BabylonJS internal texture
  112051. * @param callback defines the method to call once ready to upload
  112052. */
  112053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112054. }
  112055. }
  112056. declare module BABYLON {
  112057. /** @hidden */
  112058. export var rgbdEncodePixelShader: {
  112059. name: string;
  112060. shader: string;
  112061. };
  112062. }
  112063. declare module BABYLON {
  112064. /**
  112065. * Raw texture data and descriptor sufficient for WebGL texture upload
  112066. */
  112067. export interface EnvironmentTextureInfo {
  112068. /**
  112069. * Version of the environment map
  112070. */
  112071. version: number;
  112072. /**
  112073. * Width of image
  112074. */
  112075. width: number;
  112076. /**
  112077. * Irradiance information stored in the file.
  112078. */
  112079. irradiance: any;
  112080. /**
  112081. * Specular information stored in the file.
  112082. */
  112083. specular: any;
  112084. }
  112085. /**
  112086. * Sets of helpers addressing the serialization and deserialization of environment texture
  112087. * stored in a BabylonJS env file.
  112088. * Those files are usually stored as .env files.
  112089. */
  112090. export class EnvironmentTextureTools {
  112091. /**
  112092. * Magic number identifying the env file.
  112093. */
  112094. private static _MagicBytes;
  112095. /**
  112096. * Gets the environment info from an env file.
  112097. * @param data The array buffer containing the .env bytes.
  112098. * @returns the environment file info (the json header) if successfully parsed.
  112099. */
  112100. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112101. /**
  112102. * Creates an environment texture from a loaded cube texture.
  112103. * @param texture defines the cube texture to convert in env file
  112104. * @return a promise containing the environment data if succesfull.
  112105. */
  112106. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112107. /**
  112108. * Creates a JSON representation of the spherical data.
  112109. * @param texture defines the texture containing the polynomials
  112110. * @return the JSON representation of the spherical info
  112111. */
  112112. private static _CreateEnvTextureIrradiance;
  112113. /**
  112114. * Uploads the texture info contained in the env file to the GPU.
  112115. * @param texture defines the internal texture to upload to
  112116. * @param arrayBuffer defines the buffer cotaining the data to load
  112117. * @param info defines the texture info retrieved through the GetEnvInfo method
  112118. * @returns a promise
  112119. */
  112120. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112121. /**
  112122. * Uploads the levels of image data to the GPU.
  112123. * @param texture defines the internal texture to upload to
  112124. * @param imageData defines the array buffer views of image data [mipmap][face]
  112125. * @returns a promise
  112126. */
  112127. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112128. /**
  112129. * Uploads spherical polynomials information to the texture.
  112130. * @param texture defines the texture we are trying to upload the information to
  112131. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112132. */
  112133. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112134. /** @hidden */
  112135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112136. }
  112137. }
  112138. declare module BABYLON {
  112139. /**
  112140. * Implementation of the ENV Texture Loader.
  112141. * @hidden
  112142. */
  112143. export class _ENVTextureLoader implements IInternalTextureLoader {
  112144. /**
  112145. * Defines wether the loader supports cascade loading the different faces.
  112146. */
  112147. readonly supportCascades: boolean;
  112148. /**
  112149. * This returns if the loader support the current file information.
  112150. * @param extension defines the file extension of the file being loaded
  112151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112152. * @param fallback defines the fallback internal texture if any
  112153. * @param isBase64 defines whether the texture is encoded as a base64
  112154. * @param isBuffer defines whether the texture data are stored as a buffer
  112155. * @returns true if the loader can load the specified file
  112156. */
  112157. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112158. /**
  112159. * Transform the url before loading if required.
  112160. * @param rootUrl the url of the texture
  112161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112162. * @returns the transformed texture
  112163. */
  112164. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112165. /**
  112166. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112167. * @param rootUrl the url of the texture
  112168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112169. * @returns the fallback texture
  112170. */
  112171. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112172. /**
  112173. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112174. * @param data contains the texture data
  112175. * @param texture defines the BabylonJS internal texture
  112176. * @param createPolynomials will be true if polynomials have been requested
  112177. * @param onLoad defines the callback to trigger once the texture is ready
  112178. * @param onError defines the callback to trigger in case of error
  112179. */
  112180. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112181. /**
  112182. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112183. * @param data contains the texture data
  112184. * @param texture defines the BabylonJS internal texture
  112185. * @param callback defines the method to call once ready to upload
  112186. */
  112187. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112188. }
  112189. }
  112190. declare module BABYLON {
  112191. /**
  112192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112194. */
  112195. export class KhronosTextureContainer {
  112196. /** contents of the KTX container file */
  112197. arrayBuffer: any;
  112198. private static HEADER_LEN;
  112199. private static COMPRESSED_2D;
  112200. private static COMPRESSED_3D;
  112201. private static TEX_2D;
  112202. private static TEX_3D;
  112203. /**
  112204. * Gets the openGL type
  112205. */
  112206. glType: number;
  112207. /**
  112208. * Gets the openGL type size
  112209. */
  112210. glTypeSize: number;
  112211. /**
  112212. * Gets the openGL format
  112213. */
  112214. glFormat: number;
  112215. /**
  112216. * Gets the openGL internal format
  112217. */
  112218. glInternalFormat: number;
  112219. /**
  112220. * Gets the base internal format
  112221. */
  112222. glBaseInternalFormat: number;
  112223. /**
  112224. * Gets image width in pixel
  112225. */
  112226. pixelWidth: number;
  112227. /**
  112228. * Gets image height in pixel
  112229. */
  112230. pixelHeight: number;
  112231. /**
  112232. * Gets image depth in pixels
  112233. */
  112234. pixelDepth: number;
  112235. /**
  112236. * Gets the number of array elements
  112237. */
  112238. numberOfArrayElements: number;
  112239. /**
  112240. * Gets the number of faces
  112241. */
  112242. numberOfFaces: number;
  112243. /**
  112244. * Gets the number of mipmap levels
  112245. */
  112246. numberOfMipmapLevels: number;
  112247. /**
  112248. * Gets the bytes of key value data
  112249. */
  112250. bytesOfKeyValueData: number;
  112251. /**
  112252. * Gets the load type
  112253. */
  112254. loadType: number;
  112255. /**
  112256. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112257. */
  112258. isInvalid: boolean;
  112259. /**
  112260. * Creates a new KhronosTextureContainer
  112261. * @param arrayBuffer contents of the KTX container file
  112262. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112263. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112264. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112265. */
  112266. constructor(
  112267. /** contents of the KTX container file */
  112268. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112269. /**
  112270. * Uploads KTX content to a Babylon Texture.
  112271. * It is assumed that the texture has already been created & is currently bound
  112272. * @hidden
  112273. */
  112274. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112275. private _upload2DCompressedLevels;
  112276. }
  112277. }
  112278. declare module BABYLON {
  112279. /**
  112280. * Implementation of the KTX Texture Loader.
  112281. * @hidden
  112282. */
  112283. export class _KTXTextureLoader implements IInternalTextureLoader {
  112284. /**
  112285. * Defines wether the loader supports cascade loading the different faces.
  112286. */
  112287. readonly supportCascades: boolean;
  112288. /**
  112289. * This returns if the loader support the current file information.
  112290. * @param extension defines the file extension of the file being loaded
  112291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112292. * @param fallback defines the fallback internal texture if any
  112293. * @param isBase64 defines whether the texture is encoded as a base64
  112294. * @param isBuffer defines whether the texture data are stored as a buffer
  112295. * @returns true if the loader can load the specified file
  112296. */
  112297. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112298. /**
  112299. * Transform the url before loading if required.
  112300. * @param rootUrl the url of the texture
  112301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112302. * @returns the transformed texture
  112303. */
  112304. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112305. /**
  112306. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112307. * @param rootUrl the url of the texture
  112308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112309. * @returns the fallback texture
  112310. */
  112311. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112312. /**
  112313. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112314. * @param data contains the texture data
  112315. * @param texture defines the BabylonJS internal texture
  112316. * @param createPolynomials will be true if polynomials have been requested
  112317. * @param onLoad defines the callback to trigger once the texture is ready
  112318. * @param onError defines the callback to trigger in case of error
  112319. */
  112320. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112321. /**
  112322. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112323. * @param data contains the texture data
  112324. * @param texture defines the BabylonJS internal texture
  112325. * @param callback defines the method to call once ready to upload
  112326. */
  112327. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112328. }
  112329. }
  112330. declare module BABYLON {
  112331. /**
  112332. * Options for the default xr helper
  112333. */
  112334. export class WebXRDefaultExperienceOptions {
  112335. /**
  112336. * Floor meshes that should be used for teleporting
  112337. */
  112338. floorMeshes: Array<AbstractMesh>;
  112339. }
  112340. /**
  112341. * Default experience which provides a similar setup to the previous webVRExperience
  112342. */
  112343. export class WebXRDefaultExperience {
  112344. /**
  112345. * Base experience
  112346. */
  112347. baseExperience: WebXRExperienceHelper;
  112348. /**
  112349. * Input experience extension
  112350. */
  112351. input: WebXRInput;
  112352. /**
  112353. * Loads the controller models
  112354. */
  112355. controllerModelLoader: WebXRControllerModelLoader;
  112356. /**
  112357. * Enables laser pointer and selection
  112358. */
  112359. pointerSelection: WebXRControllerPointerSelection;
  112360. /**
  112361. * Enables teleportation
  112362. */
  112363. teleportation: WebXRControllerTeleportation;
  112364. /**
  112365. * Enables ui for enetering/exiting xr
  112366. */
  112367. enterExitUI: WebXREnterExitUI;
  112368. /**
  112369. * Default output canvas xr should render to
  112370. */
  112371. outputCanvas: WebXRManagedOutputCanvas;
  112372. /**
  112373. * Creates the default xr experience
  112374. * @param scene scene
  112375. * @param options options for basic configuration
  112376. * @returns resulting WebXRDefaultExperience
  112377. */
  112378. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112379. private constructor();
  112380. /**
  112381. * DIsposes of the experience helper
  112382. */
  112383. dispose(): void;
  112384. }
  112385. }
  112386. declare module BABYLON {
  112387. /** @hidden */
  112388. export var _forceSceneHelpersToBundle: boolean;
  112389. interface Scene {
  112390. /**
  112391. * Creates a default light for the scene.
  112392. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112393. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112394. */
  112395. createDefaultLight(replace?: boolean): void;
  112396. /**
  112397. * Creates a default camera for the scene.
  112398. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112399. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112400. * @param replace has default false, when true replaces the active camera in the scene
  112401. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112402. */
  112403. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112404. /**
  112405. * Creates a default camera and a default light.
  112406. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112407. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112408. * @param replace has the default false, when true replaces the active camera/light in the scene
  112409. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112410. */
  112411. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112412. /**
  112413. * Creates a new sky box
  112414. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112415. * @param environmentTexture defines the texture to use as environment texture
  112416. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112417. * @param scale defines the overall scale of the skybox
  112418. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112419. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112420. * @returns a new mesh holding the sky box
  112421. */
  112422. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112423. /**
  112424. * Creates a new environment
  112425. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112426. * @param options defines the options you can use to configure the environment
  112427. * @returns the new EnvironmentHelper
  112428. */
  112429. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112430. /**
  112431. * Creates a new VREXperienceHelper
  112432. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112433. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112434. * @returns a new VREXperienceHelper
  112435. */
  112436. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112437. /**
  112438. * Creates a new WebXRDefaultExperience
  112439. * @see http://doc.babylonjs.com/how_to/webxr
  112440. * @param options experience options
  112441. * @returns a promise for a new WebXRDefaultExperience
  112442. */
  112443. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112444. }
  112445. }
  112446. declare module BABYLON {
  112447. /**
  112448. * Contains position and normal vectors for a vertex
  112449. */
  112450. export class PositionNormalVertex {
  112451. /** the position of the vertex (defaut: 0,0,0) */
  112452. position: Vector3;
  112453. /** the normal of the vertex (defaut: 0,1,0) */
  112454. normal: Vector3;
  112455. /**
  112456. * Creates a PositionNormalVertex
  112457. * @param position the position of the vertex (defaut: 0,0,0)
  112458. * @param normal the normal of the vertex (defaut: 0,1,0)
  112459. */
  112460. constructor(
  112461. /** the position of the vertex (defaut: 0,0,0) */
  112462. position?: Vector3,
  112463. /** the normal of the vertex (defaut: 0,1,0) */
  112464. normal?: Vector3);
  112465. /**
  112466. * Clones the PositionNormalVertex
  112467. * @returns the cloned PositionNormalVertex
  112468. */
  112469. clone(): PositionNormalVertex;
  112470. }
  112471. /**
  112472. * Contains position, normal and uv vectors for a vertex
  112473. */
  112474. export class PositionNormalTextureVertex {
  112475. /** the position of the vertex (defaut: 0,0,0) */
  112476. position: Vector3;
  112477. /** the normal of the vertex (defaut: 0,1,0) */
  112478. normal: Vector3;
  112479. /** the uv of the vertex (default: 0,0) */
  112480. uv: Vector2;
  112481. /**
  112482. * Creates a PositionNormalTextureVertex
  112483. * @param position the position of the vertex (defaut: 0,0,0)
  112484. * @param normal the normal of the vertex (defaut: 0,1,0)
  112485. * @param uv the uv of the vertex (default: 0,0)
  112486. */
  112487. constructor(
  112488. /** the position of the vertex (defaut: 0,0,0) */
  112489. position?: Vector3,
  112490. /** the normal of the vertex (defaut: 0,1,0) */
  112491. normal?: Vector3,
  112492. /** the uv of the vertex (default: 0,0) */
  112493. uv?: Vector2);
  112494. /**
  112495. * Clones the PositionNormalTextureVertex
  112496. * @returns the cloned PositionNormalTextureVertex
  112497. */
  112498. clone(): PositionNormalTextureVertex;
  112499. }
  112500. }
  112501. declare module BABYLON {
  112502. /**
  112503. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112504. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112505. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112506. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112507. */
  112508. export class VideoDome extends TransformNode {
  112509. /**
  112510. * Define the video source as a Monoscopic panoramic 360 video.
  112511. */
  112512. static readonly MODE_MONOSCOPIC: number;
  112513. /**
  112514. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112515. */
  112516. static readonly MODE_TOPBOTTOM: number;
  112517. /**
  112518. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112519. */
  112520. static readonly MODE_SIDEBYSIDE: number;
  112521. private _halfDome;
  112522. private _useDirectMapping;
  112523. /**
  112524. * The video texture being displayed on the sphere
  112525. */
  112526. protected _videoTexture: VideoTexture;
  112527. /**
  112528. * Gets the video texture being displayed on the sphere
  112529. */
  112530. readonly videoTexture: VideoTexture;
  112531. /**
  112532. * The skybox material
  112533. */
  112534. protected _material: BackgroundMaterial;
  112535. /**
  112536. * The surface used for the skybox
  112537. */
  112538. protected _mesh: Mesh;
  112539. /**
  112540. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  112541. */
  112542. private _halfDomeMask;
  112543. /**
  112544. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112545. * Also see the options.resolution property.
  112546. */
  112547. fovMultiplier: number;
  112548. private _videoMode;
  112549. /**
  112550. * Gets or set the current video mode for the video. It can be:
  112551. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112552. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112553. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112554. */
  112555. videoMode: number;
  112556. /**
  112557. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  112558. *
  112559. */
  112560. /**
  112561. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  112562. */
  112563. halfDome: boolean;
  112564. /**
  112565. * Oberserver used in Stereoscopic VR Mode.
  112566. */
  112567. private _onBeforeCameraRenderObserver;
  112568. /**
  112569. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112570. * @param name Element's name, child elements will append suffixes for their own names.
  112571. * @param urlsOrVideo defines the url(s) or the video element to use
  112572. * @param options An object containing optional or exposed sub element properties
  112573. */
  112574. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112575. resolution?: number;
  112576. clickToPlay?: boolean;
  112577. autoPlay?: boolean;
  112578. loop?: boolean;
  112579. size?: number;
  112580. poster?: string;
  112581. faceForward?: boolean;
  112582. useDirectMapping?: boolean;
  112583. halfDomeMode?: boolean;
  112584. }, scene: Scene);
  112585. private _changeVideoMode;
  112586. /**
  112587. * Releases resources associated with this node.
  112588. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112589. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112590. */
  112591. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112592. }
  112593. }
  112594. declare module BABYLON {
  112595. /**
  112596. * This class can be used to get instrumentation data from a Babylon engine
  112597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112598. */
  112599. export class EngineInstrumentation implements IDisposable {
  112600. /**
  112601. * Define the instrumented engine.
  112602. */
  112603. engine: Engine;
  112604. private _captureGPUFrameTime;
  112605. private _gpuFrameTimeToken;
  112606. private _gpuFrameTime;
  112607. private _captureShaderCompilationTime;
  112608. private _shaderCompilationTime;
  112609. private _onBeginFrameObserver;
  112610. private _onEndFrameObserver;
  112611. private _onBeforeShaderCompilationObserver;
  112612. private _onAfterShaderCompilationObserver;
  112613. /**
  112614. * Gets the perf counter used for GPU frame time
  112615. */
  112616. readonly gpuFrameTimeCounter: PerfCounter;
  112617. /**
  112618. * Gets the GPU frame time capture status
  112619. */
  112620. /**
  112621. * Enable or disable the GPU frame time capture
  112622. */
  112623. captureGPUFrameTime: boolean;
  112624. /**
  112625. * Gets the perf counter used for shader compilation time
  112626. */
  112627. readonly shaderCompilationTimeCounter: PerfCounter;
  112628. /**
  112629. * Gets the shader compilation time capture status
  112630. */
  112631. /**
  112632. * Enable or disable the shader compilation time capture
  112633. */
  112634. captureShaderCompilationTime: boolean;
  112635. /**
  112636. * Instantiates a new engine instrumentation.
  112637. * This class can be used to get instrumentation data from a Babylon engine
  112638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112639. * @param engine Defines the engine to instrument
  112640. */
  112641. constructor(
  112642. /**
  112643. * Define the instrumented engine.
  112644. */
  112645. engine: Engine);
  112646. /**
  112647. * Dispose and release associated resources.
  112648. */
  112649. dispose(): void;
  112650. }
  112651. }
  112652. declare module BABYLON {
  112653. /**
  112654. * This class can be used to get instrumentation data from a Babylon engine
  112655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112656. */
  112657. export class SceneInstrumentation implements IDisposable {
  112658. /**
  112659. * Defines the scene to instrument
  112660. */
  112661. scene: Scene;
  112662. private _captureActiveMeshesEvaluationTime;
  112663. private _activeMeshesEvaluationTime;
  112664. private _captureRenderTargetsRenderTime;
  112665. private _renderTargetsRenderTime;
  112666. private _captureFrameTime;
  112667. private _frameTime;
  112668. private _captureRenderTime;
  112669. private _renderTime;
  112670. private _captureInterFrameTime;
  112671. private _interFrameTime;
  112672. private _captureParticlesRenderTime;
  112673. private _particlesRenderTime;
  112674. private _captureSpritesRenderTime;
  112675. private _spritesRenderTime;
  112676. private _capturePhysicsTime;
  112677. private _physicsTime;
  112678. private _captureAnimationsTime;
  112679. private _animationsTime;
  112680. private _captureCameraRenderTime;
  112681. private _cameraRenderTime;
  112682. private _onBeforeActiveMeshesEvaluationObserver;
  112683. private _onAfterActiveMeshesEvaluationObserver;
  112684. private _onBeforeRenderTargetsRenderObserver;
  112685. private _onAfterRenderTargetsRenderObserver;
  112686. private _onAfterRenderObserver;
  112687. private _onBeforeDrawPhaseObserver;
  112688. private _onAfterDrawPhaseObserver;
  112689. private _onBeforeAnimationsObserver;
  112690. private _onBeforeParticlesRenderingObserver;
  112691. private _onAfterParticlesRenderingObserver;
  112692. private _onBeforeSpritesRenderingObserver;
  112693. private _onAfterSpritesRenderingObserver;
  112694. private _onBeforePhysicsObserver;
  112695. private _onAfterPhysicsObserver;
  112696. private _onAfterAnimationsObserver;
  112697. private _onBeforeCameraRenderObserver;
  112698. private _onAfterCameraRenderObserver;
  112699. /**
  112700. * Gets the perf counter used for active meshes evaluation time
  112701. */
  112702. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112703. /**
  112704. * Gets the active meshes evaluation time capture status
  112705. */
  112706. /**
  112707. * Enable or disable the active meshes evaluation time capture
  112708. */
  112709. captureActiveMeshesEvaluationTime: boolean;
  112710. /**
  112711. * Gets the perf counter used for render targets render time
  112712. */
  112713. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112714. /**
  112715. * Gets the render targets render time capture status
  112716. */
  112717. /**
  112718. * Enable or disable the render targets render time capture
  112719. */
  112720. captureRenderTargetsRenderTime: boolean;
  112721. /**
  112722. * Gets the perf counter used for particles render time
  112723. */
  112724. readonly particlesRenderTimeCounter: PerfCounter;
  112725. /**
  112726. * Gets the particles render time capture status
  112727. */
  112728. /**
  112729. * Enable or disable the particles render time capture
  112730. */
  112731. captureParticlesRenderTime: boolean;
  112732. /**
  112733. * Gets the perf counter used for sprites render time
  112734. */
  112735. readonly spritesRenderTimeCounter: PerfCounter;
  112736. /**
  112737. * Gets the sprites render time capture status
  112738. */
  112739. /**
  112740. * Enable or disable the sprites render time capture
  112741. */
  112742. captureSpritesRenderTime: boolean;
  112743. /**
  112744. * Gets the perf counter used for physics time
  112745. */
  112746. readonly physicsTimeCounter: PerfCounter;
  112747. /**
  112748. * Gets the physics time capture status
  112749. */
  112750. /**
  112751. * Enable or disable the physics time capture
  112752. */
  112753. capturePhysicsTime: boolean;
  112754. /**
  112755. * Gets the perf counter used for animations time
  112756. */
  112757. readonly animationsTimeCounter: PerfCounter;
  112758. /**
  112759. * Gets the animations time capture status
  112760. */
  112761. /**
  112762. * Enable or disable the animations time capture
  112763. */
  112764. captureAnimationsTime: boolean;
  112765. /**
  112766. * Gets the perf counter used for frame time capture
  112767. */
  112768. readonly frameTimeCounter: PerfCounter;
  112769. /**
  112770. * Gets the frame time capture status
  112771. */
  112772. /**
  112773. * Enable or disable the frame time capture
  112774. */
  112775. captureFrameTime: boolean;
  112776. /**
  112777. * Gets the perf counter used for inter-frames time capture
  112778. */
  112779. readonly interFrameTimeCounter: PerfCounter;
  112780. /**
  112781. * Gets the inter-frames time capture status
  112782. */
  112783. /**
  112784. * Enable or disable the inter-frames time capture
  112785. */
  112786. captureInterFrameTime: boolean;
  112787. /**
  112788. * Gets the perf counter used for render time capture
  112789. */
  112790. readonly renderTimeCounter: PerfCounter;
  112791. /**
  112792. * Gets the render time capture status
  112793. */
  112794. /**
  112795. * Enable or disable the render time capture
  112796. */
  112797. captureRenderTime: boolean;
  112798. /**
  112799. * Gets the perf counter used for camera render time capture
  112800. */
  112801. readonly cameraRenderTimeCounter: PerfCounter;
  112802. /**
  112803. * Gets the camera render time capture status
  112804. */
  112805. /**
  112806. * Enable or disable the camera render time capture
  112807. */
  112808. captureCameraRenderTime: boolean;
  112809. /**
  112810. * Gets the perf counter used for draw calls
  112811. */
  112812. readonly drawCallsCounter: PerfCounter;
  112813. /**
  112814. * Instantiates a new scene instrumentation.
  112815. * This class can be used to get instrumentation data from a Babylon engine
  112816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112817. * @param scene Defines the scene to instrument
  112818. */
  112819. constructor(
  112820. /**
  112821. * Defines the scene to instrument
  112822. */
  112823. scene: Scene);
  112824. /**
  112825. * Dispose and release associated resources.
  112826. */
  112827. dispose(): void;
  112828. }
  112829. }
  112830. declare module BABYLON {
  112831. /** @hidden */
  112832. export var glowMapGenerationPixelShader: {
  112833. name: string;
  112834. shader: string;
  112835. };
  112836. }
  112837. declare module BABYLON {
  112838. /** @hidden */
  112839. export var glowMapGenerationVertexShader: {
  112840. name: string;
  112841. shader: string;
  112842. };
  112843. }
  112844. declare module BABYLON {
  112845. /**
  112846. * Effect layer options. This helps customizing the behaviour
  112847. * of the effect layer.
  112848. */
  112849. export interface IEffectLayerOptions {
  112850. /**
  112851. * Multiplication factor apply to the canvas size to compute the render target size
  112852. * used to generated the objects (the smaller the faster).
  112853. */
  112854. mainTextureRatio: number;
  112855. /**
  112856. * Enforces a fixed size texture to ensure effect stability across devices.
  112857. */
  112858. mainTextureFixedSize?: number;
  112859. /**
  112860. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  112861. */
  112862. alphaBlendingMode: number;
  112863. /**
  112864. * The camera attached to the layer.
  112865. */
  112866. camera: Nullable<Camera>;
  112867. /**
  112868. * The rendering group to draw the layer in.
  112869. */
  112870. renderingGroupId: number;
  112871. }
  112872. /**
  112873. * The effect layer Helps adding post process effect blended with the main pass.
  112874. *
  112875. * This can be for instance use to generate glow or higlight effects on the scene.
  112876. *
  112877. * The effect layer class can not be used directly and is intented to inherited from to be
  112878. * customized per effects.
  112879. */
  112880. export abstract class EffectLayer {
  112881. private _vertexBuffers;
  112882. private _indexBuffer;
  112883. private _cachedDefines;
  112884. private _effectLayerMapGenerationEffect;
  112885. private _effectLayerOptions;
  112886. private _mergeEffect;
  112887. protected _scene: Scene;
  112888. protected _engine: Engine;
  112889. protected _maxSize: number;
  112890. protected _mainTextureDesiredSize: ISize;
  112891. protected _mainTexture: RenderTargetTexture;
  112892. protected _shouldRender: boolean;
  112893. protected _postProcesses: PostProcess[];
  112894. protected _textures: BaseTexture[];
  112895. protected _emissiveTextureAndColor: {
  112896. texture: Nullable<BaseTexture>;
  112897. color: Color4;
  112898. };
  112899. /**
  112900. * The name of the layer
  112901. */
  112902. name: string;
  112903. /**
  112904. * The clear color of the texture used to generate the glow map.
  112905. */
  112906. neutralColor: Color4;
  112907. /**
  112908. * Specifies wether the highlight layer is enabled or not.
  112909. */
  112910. isEnabled: boolean;
  112911. /**
  112912. * Gets the camera attached to the layer.
  112913. */
  112914. readonly camera: Nullable<Camera>;
  112915. /**
  112916. * Gets the rendering group id the layer should render in.
  112917. */
  112918. renderingGroupId: number;
  112919. /**
  112920. * An event triggered when the effect layer has been disposed.
  112921. */
  112922. onDisposeObservable: Observable<EffectLayer>;
  112923. /**
  112924. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112925. */
  112926. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112927. /**
  112928. * An event triggered when the generated texture is being merged in the scene.
  112929. */
  112930. onBeforeComposeObservable: Observable<EffectLayer>;
  112931. /**
  112932. * An event triggered when the generated texture has been merged in the scene.
  112933. */
  112934. onAfterComposeObservable: Observable<EffectLayer>;
  112935. /**
  112936. * An event triggered when the efffect layer changes its size.
  112937. */
  112938. onSizeChangedObservable: Observable<EffectLayer>;
  112939. /** @hidden */
  112940. static _SceneComponentInitialization: (scene: Scene) => void;
  112941. /**
  112942. * Instantiates a new effect Layer and references it in the scene.
  112943. * @param name The name of the layer
  112944. * @param scene The scene to use the layer in
  112945. */
  112946. constructor(
  112947. /** The Friendly of the effect in the scene */
  112948. name: string, scene: Scene);
  112949. /**
  112950. * Get the effect name of the layer.
  112951. * @return The effect name
  112952. */
  112953. abstract getEffectName(): string;
  112954. /**
  112955. * Checks for the readiness of the element composing the layer.
  112956. * @param subMesh the mesh to check for
  112957. * @param useInstances specify wether or not to use instances to render the mesh
  112958. * @return true if ready otherwise, false
  112959. */
  112960. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112961. /**
  112962. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112963. * @returns true if the effect requires stencil during the main canvas render pass.
  112964. */
  112965. abstract needStencil(): boolean;
  112966. /**
  112967. * Create the merge effect. This is the shader use to blit the information back
  112968. * to the main canvas at the end of the scene rendering.
  112969. * @returns The effect containing the shader used to merge the effect on the main canvas
  112970. */
  112971. protected abstract _createMergeEffect(): Effect;
  112972. /**
  112973. * Creates the render target textures and post processes used in the effect layer.
  112974. */
  112975. protected abstract _createTextureAndPostProcesses(): void;
  112976. /**
  112977. * Implementation specific of rendering the generating effect on the main canvas.
  112978. * @param effect The effect used to render through
  112979. */
  112980. protected abstract _internalRender(effect: Effect): void;
  112981. /**
  112982. * Sets the required values for both the emissive texture and and the main color.
  112983. */
  112984. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112985. /**
  112986. * Free any resources and references associated to a mesh.
  112987. * Internal use
  112988. * @param mesh The mesh to free.
  112989. */
  112990. abstract _disposeMesh(mesh: Mesh): void;
  112991. /**
  112992. * Serializes this layer (Glow or Highlight for example)
  112993. * @returns a serialized layer object
  112994. */
  112995. abstract serialize?(): any;
  112996. /**
  112997. * Initializes the effect layer with the required options.
  112998. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112999. */
  113000. protected _init(options: Partial<IEffectLayerOptions>): void;
  113001. /**
  113002. * Generates the index buffer of the full screen quad blending to the main canvas.
  113003. */
  113004. private _generateIndexBuffer;
  113005. /**
  113006. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113007. */
  113008. private _generateVertexBuffer;
  113009. /**
  113010. * Sets the main texture desired size which is the closest power of two
  113011. * of the engine canvas size.
  113012. */
  113013. private _setMainTextureSize;
  113014. /**
  113015. * Creates the main texture for the effect layer.
  113016. */
  113017. protected _createMainTexture(): void;
  113018. /**
  113019. * Adds specific effects defines.
  113020. * @param defines The defines to add specifics to.
  113021. */
  113022. protected _addCustomEffectDefines(defines: string[]): void;
  113023. /**
  113024. * Checks for the readiness of the element composing the layer.
  113025. * @param subMesh the mesh to check for
  113026. * @param useInstances specify wether or not to use instances to render the mesh
  113027. * @param emissiveTexture the associated emissive texture used to generate the glow
  113028. * @return true if ready otherwise, false
  113029. */
  113030. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113031. /**
  113032. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113033. */
  113034. render(): void;
  113035. /**
  113036. * Determine if a given mesh will be used in the current effect.
  113037. * @param mesh mesh to test
  113038. * @returns true if the mesh will be used
  113039. */
  113040. hasMesh(mesh: AbstractMesh): boolean;
  113041. /**
  113042. * Returns true if the layer contains information to display, otherwise false.
  113043. * @returns true if the glow layer should be rendered
  113044. */
  113045. shouldRender(): boolean;
  113046. /**
  113047. * Returns true if the mesh should render, otherwise false.
  113048. * @param mesh The mesh to render
  113049. * @returns true if it should render otherwise false
  113050. */
  113051. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113052. /**
  113053. * Returns true if the mesh can be rendered, otherwise false.
  113054. * @param mesh The mesh to render
  113055. * @param material The material used on the mesh
  113056. * @returns true if it can be rendered otherwise false
  113057. */
  113058. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113059. /**
  113060. * Returns true if the mesh should render, otherwise false.
  113061. * @param mesh The mesh to render
  113062. * @returns true if it should render otherwise false
  113063. */
  113064. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113065. /**
  113066. * Renders the submesh passed in parameter to the generation map.
  113067. */
  113068. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113069. /**
  113070. * Rebuild the required buffers.
  113071. * @hidden Internal use only.
  113072. */
  113073. _rebuild(): void;
  113074. /**
  113075. * Dispose only the render target textures and post process.
  113076. */
  113077. private _disposeTextureAndPostProcesses;
  113078. /**
  113079. * Dispose the highlight layer and free resources.
  113080. */
  113081. dispose(): void;
  113082. /**
  113083. * Gets the class name of the effect layer
  113084. * @returns the string with the class name of the effect layer
  113085. */
  113086. getClassName(): string;
  113087. /**
  113088. * Creates an effect layer from parsed effect layer data
  113089. * @param parsedEffectLayer defines effect layer data
  113090. * @param scene defines the current scene
  113091. * @param rootUrl defines the root URL containing the effect layer information
  113092. * @returns a parsed effect Layer
  113093. */
  113094. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113095. }
  113096. }
  113097. declare module BABYLON {
  113098. interface AbstractScene {
  113099. /**
  113100. * The list of effect layers (highlights/glow) added to the scene
  113101. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113102. * @see http://doc.babylonjs.com/how_to/glow_layer
  113103. */
  113104. effectLayers: Array<EffectLayer>;
  113105. /**
  113106. * Removes the given effect layer from this scene.
  113107. * @param toRemove defines the effect layer to remove
  113108. * @returns the index of the removed effect layer
  113109. */
  113110. removeEffectLayer(toRemove: EffectLayer): number;
  113111. /**
  113112. * Adds the given effect layer to this scene
  113113. * @param newEffectLayer defines the effect layer to add
  113114. */
  113115. addEffectLayer(newEffectLayer: EffectLayer): void;
  113116. }
  113117. /**
  113118. * Defines the layer scene component responsible to manage any effect layers
  113119. * in a given scene.
  113120. */
  113121. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113122. /**
  113123. * The component name helpfull to identify the component in the list of scene components.
  113124. */
  113125. readonly name: string;
  113126. /**
  113127. * The scene the component belongs to.
  113128. */
  113129. scene: Scene;
  113130. private _engine;
  113131. private _renderEffects;
  113132. private _needStencil;
  113133. private _previousStencilState;
  113134. /**
  113135. * Creates a new instance of the component for the given scene
  113136. * @param scene Defines the scene to register the component in
  113137. */
  113138. constructor(scene: Scene);
  113139. /**
  113140. * Registers the component in a given scene
  113141. */
  113142. register(): void;
  113143. /**
  113144. * Rebuilds the elements related to this component in case of
  113145. * context lost for instance.
  113146. */
  113147. rebuild(): void;
  113148. /**
  113149. * Serializes the component data to the specified json object
  113150. * @param serializationObject The object to serialize to
  113151. */
  113152. serialize(serializationObject: any): void;
  113153. /**
  113154. * Adds all the elements from the container to the scene
  113155. * @param container the container holding the elements
  113156. */
  113157. addFromContainer(container: AbstractScene): void;
  113158. /**
  113159. * Removes all the elements in the container from the scene
  113160. * @param container contains the elements to remove
  113161. * @param dispose if the removed element should be disposed (default: false)
  113162. */
  113163. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113164. /**
  113165. * Disposes the component and the associated ressources.
  113166. */
  113167. dispose(): void;
  113168. private _isReadyForMesh;
  113169. private _renderMainTexture;
  113170. private _setStencil;
  113171. private _setStencilBack;
  113172. private _draw;
  113173. private _drawCamera;
  113174. private _drawRenderingGroup;
  113175. }
  113176. }
  113177. declare module BABYLON {
  113178. /** @hidden */
  113179. export var glowMapMergePixelShader: {
  113180. name: string;
  113181. shader: string;
  113182. };
  113183. }
  113184. declare module BABYLON {
  113185. /** @hidden */
  113186. export var glowMapMergeVertexShader: {
  113187. name: string;
  113188. shader: string;
  113189. };
  113190. }
  113191. declare module BABYLON {
  113192. interface AbstractScene {
  113193. /**
  113194. * Return a the first highlight layer of the scene with a given name.
  113195. * @param name The name of the highlight layer to look for.
  113196. * @return The highlight layer if found otherwise null.
  113197. */
  113198. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113199. }
  113200. /**
  113201. * Glow layer options. This helps customizing the behaviour
  113202. * of the glow layer.
  113203. */
  113204. export interface IGlowLayerOptions {
  113205. /**
  113206. * Multiplication factor apply to the canvas size to compute the render target size
  113207. * used to generated the glowing objects (the smaller the faster).
  113208. */
  113209. mainTextureRatio: number;
  113210. /**
  113211. * Enforces a fixed size texture to ensure resize independant blur.
  113212. */
  113213. mainTextureFixedSize?: number;
  113214. /**
  113215. * How big is the kernel of the blur texture.
  113216. */
  113217. blurKernelSize: number;
  113218. /**
  113219. * The camera attached to the layer.
  113220. */
  113221. camera: Nullable<Camera>;
  113222. /**
  113223. * Enable MSAA by chosing the number of samples.
  113224. */
  113225. mainTextureSamples?: number;
  113226. /**
  113227. * The rendering group to draw the layer in.
  113228. */
  113229. renderingGroupId: number;
  113230. }
  113231. /**
  113232. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113233. *
  113234. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113235. * glowy meshes to your scene.
  113236. *
  113237. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113238. */
  113239. export class GlowLayer extends EffectLayer {
  113240. /**
  113241. * Effect Name of the layer.
  113242. */
  113243. static readonly EffectName: string;
  113244. /**
  113245. * The default blur kernel size used for the glow.
  113246. */
  113247. static DefaultBlurKernelSize: number;
  113248. /**
  113249. * The default texture size ratio used for the glow.
  113250. */
  113251. static DefaultTextureRatio: number;
  113252. /**
  113253. * Sets the kernel size of the blur.
  113254. */
  113255. /**
  113256. * Gets the kernel size of the blur.
  113257. */
  113258. blurKernelSize: number;
  113259. /**
  113260. * Sets the glow intensity.
  113261. */
  113262. /**
  113263. * Gets the glow intensity.
  113264. */
  113265. intensity: number;
  113266. private _options;
  113267. private _intensity;
  113268. private _horizontalBlurPostprocess1;
  113269. private _verticalBlurPostprocess1;
  113270. private _horizontalBlurPostprocess2;
  113271. private _verticalBlurPostprocess2;
  113272. private _blurTexture1;
  113273. private _blurTexture2;
  113274. private _postProcesses1;
  113275. private _postProcesses2;
  113276. private _includedOnlyMeshes;
  113277. private _excludedMeshes;
  113278. /**
  113279. * Callback used to let the user override the color selection on a per mesh basis
  113280. */
  113281. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113282. /**
  113283. * Callback used to let the user override the texture selection on a per mesh basis
  113284. */
  113285. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113286. /**
  113287. * Instantiates a new glow Layer and references it to the scene.
  113288. * @param name The name of the layer
  113289. * @param scene The scene to use the layer in
  113290. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113291. */
  113292. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113293. /**
  113294. * Get the effect name of the layer.
  113295. * @return The effect name
  113296. */
  113297. getEffectName(): string;
  113298. /**
  113299. * Create the merge effect. This is the shader use to blit the information back
  113300. * to the main canvas at the end of the scene rendering.
  113301. */
  113302. protected _createMergeEffect(): Effect;
  113303. /**
  113304. * Creates the render target textures and post processes used in the glow layer.
  113305. */
  113306. protected _createTextureAndPostProcesses(): void;
  113307. /**
  113308. * Checks for the readiness of the element composing the layer.
  113309. * @param subMesh the mesh to check for
  113310. * @param useInstances specify wether or not to use instances to render the mesh
  113311. * @param emissiveTexture the associated emissive texture used to generate the glow
  113312. * @return true if ready otherwise, false
  113313. */
  113314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113315. /**
  113316. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113317. */
  113318. needStencil(): boolean;
  113319. /**
  113320. * Returns true if the mesh can be rendered, otherwise false.
  113321. * @param mesh The mesh to render
  113322. * @param material The material used on the mesh
  113323. * @returns true if it can be rendered otherwise false
  113324. */
  113325. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113326. /**
  113327. * Implementation specific of rendering the generating effect on the main canvas.
  113328. * @param effect The effect used to render through
  113329. */
  113330. protected _internalRender(effect: Effect): void;
  113331. /**
  113332. * Sets the required values for both the emissive texture and and the main color.
  113333. */
  113334. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113335. /**
  113336. * Returns true if the mesh should render, otherwise false.
  113337. * @param mesh The mesh to render
  113338. * @returns true if it should render otherwise false
  113339. */
  113340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113341. /**
  113342. * Adds specific effects defines.
  113343. * @param defines The defines to add specifics to.
  113344. */
  113345. protected _addCustomEffectDefines(defines: string[]): void;
  113346. /**
  113347. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113348. * @param mesh The mesh to exclude from the glow layer
  113349. */
  113350. addExcludedMesh(mesh: Mesh): void;
  113351. /**
  113352. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113353. * @param mesh The mesh to remove
  113354. */
  113355. removeExcludedMesh(mesh: Mesh): void;
  113356. /**
  113357. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113358. * @param mesh The mesh to include in the glow layer
  113359. */
  113360. addIncludedOnlyMesh(mesh: Mesh): void;
  113361. /**
  113362. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113363. * @param mesh The mesh to remove
  113364. */
  113365. removeIncludedOnlyMesh(mesh: Mesh): void;
  113366. /**
  113367. * Determine if a given mesh will be used in the glow layer
  113368. * @param mesh The mesh to test
  113369. * @returns true if the mesh will be highlighted by the current glow layer
  113370. */
  113371. hasMesh(mesh: AbstractMesh): boolean;
  113372. /**
  113373. * Free any resources and references associated to a mesh.
  113374. * Internal use
  113375. * @param mesh The mesh to free.
  113376. * @hidden
  113377. */
  113378. _disposeMesh(mesh: Mesh): void;
  113379. /**
  113380. * Gets the class name of the effect layer
  113381. * @returns the string with the class name of the effect layer
  113382. */
  113383. getClassName(): string;
  113384. /**
  113385. * Serializes this glow layer
  113386. * @returns a serialized glow layer object
  113387. */
  113388. serialize(): any;
  113389. /**
  113390. * Creates a Glow Layer from parsed glow layer data
  113391. * @param parsedGlowLayer defines glow layer data
  113392. * @param scene defines the current scene
  113393. * @param rootUrl defines the root URL containing the glow layer information
  113394. * @returns a parsed Glow Layer
  113395. */
  113396. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113397. }
  113398. }
  113399. declare module BABYLON {
  113400. /** @hidden */
  113401. export var glowBlurPostProcessPixelShader: {
  113402. name: string;
  113403. shader: string;
  113404. };
  113405. }
  113406. declare module BABYLON {
  113407. interface AbstractScene {
  113408. /**
  113409. * Return a the first highlight layer of the scene with a given name.
  113410. * @param name The name of the highlight layer to look for.
  113411. * @return The highlight layer if found otherwise null.
  113412. */
  113413. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113414. }
  113415. /**
  113416. * Highlight layer options. This helps customizing the behaviour
  113417. * of the highlight layer.
  113418. */
  113419. export interface IHighlightLayerOptions {
  113420. /**
  113421. * Multiplication factor apply to the canvas size to compute the render target size
  113422. * used to generated the glowing objects (the smaller the faster).
  113423. */
  113424. mainTextureRatio: number;
  113425. /**
  113426. * Enforces a fixed size texture to ensure resize independant blur.
  113427. */
  113428. mainTextureFixedSize?: number;
  113429. /**
  113430. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113431. * of the picture to blur (the smaller the faster).
  113432. */
  113433. blurTextureSizeRatio: number;
  113434. /**
  113435. * How big in texel of the blur texture is the vertical blur.
  113436. */
  113437. blurVerticalSize: number;
  113438. /**
  113439. * How big in texel of the blur texture is the horizontal blur.
  113440. */
  113441. blurHorizontalSize: number;
  113442. /**
  113443. * Alpha blending mode used to apply the blur. Default is combine.
  113444. */
  113445. alphaBlendingMode: number;
  113446. /**
  113447. * The camera attached to the layer.
  113448. */
  113449. camera: Nullable<Camera>;
  113450. /**
  113451. * Should we display highlight as a solid stroke?
  113452. */
  113453. isStroke?: boolean;
  113454. /**
  113455. * The rendering group to draw the layer in.
  113456. */
  113457. renderingGroupId: number;
  113458. }
  113459. /**
  113460. * The highlight layer Helps adding a glow effect around a mesh.
  113461. *
  113462. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113463. * glowy meshes to your scene.
  113464. *
  113465. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113466. */
  113467. export class HighlightLayer extends EffectLayer {
  113468. name: string;
  113469. /**
  113470. * Effect Name of the highlight layer.
  113471. */
  113472. static readonly EffectName: string;
  113473. /**
  113474. * The neutral color used during the preparation of the glow effect.
  113475. * This is black by default as the blend operation is a blend operation.
  113476. */
  113477. static NeutralColor: Color4;
  113478. /**
  113479. * Stencil value used for glowing meshes.
  113480. */
  113481. static GlowingMeshStencilReference: number;
  113482. /**
  113483. * Stencil value used for the other meshes in the scene.
  113484. */
  113485. static NormalMeshStencilReference: number;
  113486. /**
  113487. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113488. */
  113489. innerGlow: boolean;
  113490. /**
  113491. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113492. */
  113493. outerGlow: boolean;
  113494. /**
  113495. * Specifies the horizontal size of the blur.
  113496. */
  113497. /**
  113498. * Gets the horizontal size of the blur.
  113499. */
  113500. blurHorizontalSize: number;
  113501. /**
  113502. * Specifies the vertical size of the blur.
  113503. */
  113504. /**
  113505. * Gets the vertical size of the blur.
  113506. */
  113507. blurVerticalSize: number;
  113508. /**
  113509. * An event triggered when the highlight layer is being blurred.
  113510. */
  113511. onBeforeBlurObservable: Observable<HighlightLayer>;
  113512. /**
  113513. * An event triggered when the highlight layer has been blurred.
  113514. */
  113515. onAfterBlurObservable: Observable<HighlightLayer>;
  113516. private _instanceGlowingMeshStencilReference;
  113517. private _options;
  113518. private _downSamplePostprocess;
  113519. private _horizontalBlurPostprocess;
  113520. private _verticalBlurPostprocess;
  113521. private _blurTexture;
  113522. private _meshes;
  113523. private _excludedMeshes;
  113524. /**
  113525. * Instantiates a new highlight Layer and references it to the scene..
  113526. * @param name The name of the layer
  113527. * @param scene The scene to use the layer in
  113528. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113529. */
  113530. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113531. /**
  113532. * Get the effect name of the layer.
  113533. * @return The effect name
  113534. */
  113535. getEffectName(): string;
  113536. /**
  113537. * Create the merge effect. This is the shader use to blit the information back
  113538. * to the main canvas at the end of the scene rendering.
  113539. */
  113540. protected _createMergeEffect(): Effect;
  113541. /**
  113542. * Creates the render target textures and post processes used in the highlight layer.
  113543. */
  113544. protected _createTextureAndPostProcesses(): void;
  113545. /**
  113546. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113547. */
  113548. needStencil(): boolean;
  113549. /**
  113550. * Checks for the readiness of the element composing the layer.
  113551. * @param subMesh the mesh to check for
  113552. * @param useInstances specify wether or not to use instances to render the mesh
  113553. * @param emissiveTexture the associated emissive texture used to generate the glow
  113554. * @return true if ready otherwise, false
  113555. */
  113556. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113557. /**
  113558. * Implementation specific of rendering the generating effect on the main canvas.
  113559. * @param effect The effect used to render through
  113560. */
  113561. protected _internalRender(effect: Effect): void;
  113562. /**
  113563. * Returns true if the layer contains information to display, otherwise false.
  113564. */
  113565. shouldRender(): boolean;
  113566. /**
  113567. * Returns true if the mesh should render, otherwise false.
  113568. * @param mesh The mesh to render
  113569. * @returns true if it should render otherwise false
  113570. */
  113571. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113572. /**
  113573. * Sets the required values for both the emissive texture and and the main color.
  113574. */
  113575. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113576. /**
  113577. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113578. * @param mesh The mesh to exclude from the highlight layer
  113579. */
  113580. addExcludedMesh(mesh: Mesh): void;
  113581. /**
  113582. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113583. * @param mesh The mesh to highlight
  113584. */
  113585. removeExcludedMesh(mesh: Mesh): void;
  113586. /**
  113587. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113588. * @param mesh mesh to test
  113589. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113590. */
  113591. hasMesh(mesh: AbstractMesh): boolean;
  113592. /**
  113593. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113594. * @param mesh The mesh to highlight
  113595. * @param color The color of the highlight
  113596. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113597. */
  113598. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113599. /**
  113600. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113601. * @param mesh The mesh to highlight
  113602. */
  113603. removeMesh(mesh: Mesh): void;
  113604. /**
  113605. * Force the stencil to the normal expected value for none glowing parts
  113606. */
  113607. private _defaultStencilReference;
  113608. /**
  113609. * Free any resources and references associated to a mesh.
  113610. * Internal use
  113611. * @param mesh The mesh to free.
  113612. * @hidden
  113613. */
  113614. _disposeMesh(mesh: Mesh): void;
  113615. /**
  113616. * Dispose the highlight layer and free resources.
  113617. */
  113618. dispose(): void;
  113619. /**
  113620. * Gets the class name of the effect layer
  113621. * @returns the string with the class name of the effect layer
  113622. */
  113623. getClassName(): string;
  113624. /**
  113625. * Serializes this Highlight layer
  113626. * @returns a serialized Highlight layer object
  113627. */
  113628. serialize(): any;
  113629. /**
  113630. * Creates a Highlight layer from parsed Highlight layer data
  113631. * @param parsedHightlightLayer defines the Highlight layer data
  113632. * @param scene defines the current scene
  113633. * @param rootUrl defines the root URL containing the Highlight layer information
  113634. * @returns a parsed Highlight layer
  113635. */
  113636. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113637. }
  113638. }
  113639. declare module BABYLON {
  113640. interface AbstractScene {
  113641. /**
  113642. * The list of layers (background and foreground) of the scene
  113643. */
  113644. layers: Array<Layer>;
  113645. }
  113646. /**
  113647. * Defines the layer scene component responsible to manage any layers
  113648. * in a given scene.
  113649. */
  113650. export class LayerSceneComponent implements ISceneComponent {
  113651. /**
  113652. * The component name helpfull to identify the component in the list of scene components.
  113653. */
  113654. readonly name: string;
  113655. /**
  113656. * The scene the component belongs to.
  113657. */
  113658. scene: Scene;
  113659. private _engine;
  113660. /**
  113661. * Creates a new instance of the component for the given scene
  113662. * @param scene Defines the scene to register the component in
  113663. */
  113664. constructor(scene: Scene);
  113665. /**
  113666. * Registers the component in a given scene
  113667. */
  113668. register(): void;
  113669. /**
  113670. * Rebuilds the elements related to this component in case of
  113671. * context lost for instance.
  113672. */
  113673. rebuild(): void;
  113674. /**
  113675. * Disposes the component and the associated ressources.
  113676. */
  113677. dispose(): void;
  113678. private _draw;
  113679. private _drawCameraPredicate;
  113680. private _drawCameraBackground;
  113681. private _drawCameraForeground;
  113682. private _drawRenderTargetPredicate;
  113683. private _drawRenderTargetBackground;
  113684. private _drawRenderTargetForeground;
  113685. /**
  113686. * Adds all the elements from the container to the scene
  113687. * @param container the container holding the elements
  113688. */
  113689. addFromContainer(container: AbstractScene): void;
  113690. /**
  113691. * Removes all the elements in the container from the scene
  113692. * @param container contains the elements to remove
  113693. * @param dispose if the removed element should be disposed (default: false)
  113694. */
  113695. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113696. }
  113697. }
  113698. declare module BABYLON {
  113699. /** @hidden */
  113700. export var layerPixelShader: {
  113701. name: string;
  113702. shader: string;
  113703. };
  113704. }
  113705. declare module BABYLON {
  113706. /** @hidden */
  113707. export var layerVertexShader: {
  113708. name: string;
  113709. shader: string;
  113710. };
  113711. }
  113712. declare module BABYLON {
  113713. /**
  113714. * This represents a full screen 2d layer.
  113715. * This can be useful to display a picture in the background of your scene for instance.
  113716. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113717. */
  113718. export class Layer {
  113719. /**
  113720. * Define the name of the layer.
  113721. */
  113722. name: string;
  113723. /**
  113724. * Define the texture the layer should display.
  113725. */
  113726. texture: Nullable<Texture>;
  113727. /**
  113728. * Is the layer in background or foreground.
  113729. */
  113730. isBackground: boolean;
  113731. /**
  113732. * Define the color of the layer (instead of texture).
  113733. */
  113734. color: Color4;
  113735. /**
  113736. * Define the scale of the layer in order to zoom in out of the texture.
  113737. */
  113738. scale: Vector2;
  113739. /**
  113740. * Define an offset for the layer in order to shift the texture.
  113741. */
  113742. offset: Vector2;
  113743. /**
  113744. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113745. */
  113746. alphaBlendingMode: number;
  113747. /**
  113748. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113749. * Alpha test will not mix with the background color in case of transparency.
  113750. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113751. */
  113752. alphaTest: boolean;
  113753. /**
  113754. * Define a mask to restrict the layer to only some of the scene cameras.
  113755. */
  113756. layerMask: number;
  113757. /**
  113758. * Define the list of render target the layer is visible into.
  113759. */
  113760. renderTargetTextures: RenderTargetTexture[];
  113761. /**
  113762. * Define if the layer is only used in renderTarget or if it also
  113763. * renders in the main frame buffer of the canvas.
  113764. */
  113765. renderOnlyInRenderTargetTextures: boolean;
  113766. private _scene;
  113767. private _vertexBuffers;
  113768. private _indexBuffer;
  113769. private _effect;
  113770. private _alphaTestEffect;
  113771. /**
  113772. * An event triggered when the layer is disposed.
  113773. */
  113774. onDisposeObservable: Observable<Layer>;
  113775. private _onDisposeObserver;
  113776. /**
  113777. * Back compatibility with callback before the onDisposeObservable existed.
  113778. * The set callback will be triggered when the layer has been disposed.
  113779. */
  113780. onDispose: () => void;
  113781. /**
  113782. * An event triggered before rendering the scene
  113783. */
  113784. onBeforeRenderObservable: Observable<Layer>;
  113785. private _onBeforeRenderObserver;
  113786. /**
  113787. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113788. * The set callback will be triggered just before rendering the layer.
  113789. */
  113790. onBeforeRender: () => void;
  113791. /**
  113792. * An event triggered after rendering the scene
  113793. */
  113794. onAfterRenderObservable: Observable<Layer>;
  113795. private _onAfterRenderObserver;
  113796. /**
  113797. * Back compatibility with callback before the onAfterRenderObservable existed.
  113798. * The set callback will be triggered just after rendering the layer.
  113799. */
  113800. onAfterRender: () => void;
  113801. /**
  113802. * Instantiates a new layer.
  113803. * This represents a full screen 2d layer.
  113804. * This can be useful to display a picture in the background of your scene for instance.
  113805. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113806. * @param name Define the name of the layer in the scene
  113807. * @param imgUrl Define the url of the texture to display in the layer
  113808. * @param scene Define the scene the layer belongs to
  113809. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113810. * @param color Defines a color for the layer
  113811. */
  113812. constructor(
  113813. /**
  113814. * Define the name of the layer.
  113815. */
  113816. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113817. private _createIndexBuffer;
  113818. /** @hidden */
  113819. _rebuild(): void;
  113820. /**
  113821. * Renders the layer in the scene.
  113822. */
  113823. render(): void;
  113824. /**
  113825. * Disposes and releases the associated ressources.
  113826. */
  113827. dispose(): void;
  113828. }
  113829. }
  113830. declare module BABYLON {
  113831. /** @hidden */
  113832. export var lensFlarePixelShader: {
  113833. name: string;
  113834. shader: string;
  113835. };
  113836. }
  113837. declare module BABYLON {
  113838. /** @hidden */
  113839. export var lensFlareVertexShader: {
  113840. name: string;
  113841. shader: string;
  113842. };
  113843. }
  113844. declare module BABYLON {
  113845. /**
  113846. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113847. * It is usually composed of several `lensFlare`.
  113848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113849. */
  113850. export class LensFlareSystem {
  113851. /**
  113852. * Define the name of the lens flare system
  113853. */
  113854. name: string;
  113855. /**
  113856. * List of lens flares used in this system.
  113857. */
  113858. lensFlares: LensFlare[];
  113859. /**
  113860. * Define a limit from the border the lens flare can be visible.
  113861. */
  113862. borderLimit: number;
  113863. /**
  113864. * Define a viewport border we do not want to see the lens flare in.
  113865. */
  113866. viewportBorder: number;
  113867. /**
  113868. * Define a predicate which could limit the list of meshes able to occlude the effect.
  113869. */
  113870. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113871. /**
  113872. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  113873. */
  113874. layerMask: number;
  113875. /**
  113876. * Define the id of the lens flare system in the scene.
  113877. * (equal to name by default)
  113878. */
  113879. id: string;
  113880. private _scene;
  113881. private _emitter;
  113882. private _vertexBuffers;
  113883. private _indexBuffer;
  113884. private _effect;
  113885. private _positionX;
  113886. private _positionY;
  113887. private _isEnabled;
  113888. /** @hidden */
  113889. static _SceneComponentInitialization: (scene: Scene) => void;
  113890. /**
  113891. * Instantiates a lens flare system.
  113892. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113893. * It is usually composed of several `lensFlare`.
  113894. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113895. * @param name Define the name of the lens flare system in the scene
  113896. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  113897. * @param scene Define the scene the lens flare system belongs to
  113898. */
  113899. constructor(
  113900. /**
  113901. * Define the name of the lens flare system
  113902. */
  113903. name: string, emitter: any, scene: Scene);
  113904. /**
  113905. * Define if the lens flare system is enabled.
  113906. */
  113907. isEnabled: boolean;
  113908. /**
  113909. * Get the scene the effects belongs to.
  113910. * @returns the scene holding the lens flare system
  113911. */
  113912. getScene(): Scene;
  113913. /**
  113914. * Get the emitter of the lens flare system.
  113915. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113916. * @returns the emitter of the lens flare system
  113917. */
  113918. getEmitter(): any;
  113919. /**
  113920. * Set the emitter of the lens flare system.
  113921. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113922. * @param newEmitter Define the new emitter of the system
  113923. */
  113924. setEmitter(newEmitter: any): void;
  113925. /**
  113926. * Get the lens flare system emitter position.
  113927. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113928. * @returns the position
  113929. */
  113930. getEmitterPosition(): Vector3;
  113931. /**
  113932. * @hidden
  113933. */
  113934. computeEffectivePosition(globalViewport: Viewport): boolean;
  113935. /** @hidden */
  113936. _isVisible(): boolean;
  113937. /**
  113938. * @hidden
  113939. */
  113940. render(): boolean;
  113941. /**
  113942. * Dispose and release the lens flare with its associated resources.
  113943. */
  113944. dispose(): void;
  113945. /**
  113946. * Parse a lens flare system from a JSON repressentation
  113947. * @param parsedLensFlareSystem Define the JSON to parse
  113948. * @param scene Define the scene the parsed system should be instantiated in
  113949. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113950. * @returns the parsed system
  113951. */
  113952. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113953. /**
  113954. * Serialize the current Lens Flare System into a JSON representation.
  113955. * @returns the serialized JSON
  113956. */
  113957. serialize(): any;
  113958. }
  113959. }
  113960. declare module BABYLON {
  113961. /**
  113962. * This represents one of the lens effect in a `lensFlareSystem`.
  113963. * It controls one of the indiviual texture used in the effect.
  113964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113965. */
  113966. export class LensFlare {
  113967. /**
  113968. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113969. */
  113970. size: number;
  113971. /**
  113972. * 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.
  113973. */
  113974. position: number;
  113975. /**
  113976. * Define the lens color.
  113977. */
  113978. color: Color3;
  113979. /**
  113980. * Define the lens texture.
  113981. */
  113982. texture: Nullable<Texture>;
  113983. /**
  113984. * Define the alpha mode to render this particular lens.
  113985. */
  113986. alphaMode: number;
  113987. private _system;
  113988. /**
  113989. * Creates a new Lens Flare.
  113990. * This represents one of the lens effect in a `lensFlareSystem`.
  113991. * It controls one of the indiviual texture used in the effect.
  113992. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113993. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113994. * @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.
  113995. * @param color Define the lens color
  113996. * @param imgUrl Define the lens texture url
  113997. * @param system Define the `lensFlareSystem` this flare is part of
  113998. * @returns The newly created Lens Flare
  113999. */
  114000. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114001. /**
  114002. * Instantiates a new Lens Flare.
  114003. * This represents one of the lens effect in a `lensFlareSystem`.
  114004. * It controls one of the indiviual texture used in the effect.
  114005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114006. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114007. * @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.
  114008. * @param color Define the lens color
  114009. * @param imgUrl Define the lens texture url
  114010. * @param system Define the `lensFlareSystem` this flare is part of
  114011. */
  114012. constructor(
  114013. /**
  114014. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114015. */
  114016. size: number,
  114017. /**
  114018. * 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.
  114019. */
  114020. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114021. /**
  114022. * Dispose and release the lens flare with its associated resources.
  114023. */
  114024. dispose(): void;
  114025. }
  114026. }
  114027. declare module BABYLON {
  114028. interface AbstractScene {
  114029. /**
  114030. * The list of lens flare system added to the scene
  114031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114032. */
  114033. lensFlareSystems: Array<LensFlareSystem>;
  114034. /**
  114035. * Removes the given lens flare system from this scene.
  114036. * @param toRemove The lens flare system to remove
  114037. * @returns The index of the removed lens flare system
  114038. */
  114039. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114040. /**
  114041. * Adds the given lens flare system to this scene
  114042. * @param newLensFlareSystem The lens flare system to add
  114043. */
  114044. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114045. /**
  114046. * Gets a lens flare system using its name
  114047. * @param name defines the name to look for
  114048. * @returns the lens flare system or null if not found
  114049. */
  114050. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114051. /**
  114052. * Gets a lens flare system using its id
  114053. * @param id defines the id to look for
  114054. * @returns the lens flare system or null if not found
  114055. */
  114056. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114057. }
  114058. /**
  114059. * Defines the lens flare scene component responsible to manage any lens flares
  114060. * in a given scene.
  114061. */
  114062. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114063. /**
  114064. * The component name helpfull to identify the component in the list of scene components.
  114065. */
  114066. readonly name: string;
  114067. /**
  114068. * The scene the component belongs to.
  114069. */
  114070. scene: Scene;
  114071. /**
  114072. * Creates a new instance of the component for the given scene
  114073. * @param scene Defines the scene to register the component in
  114074. */
  114075. constructor(scene: Scene);
  114076. /**
  114077. * Registers the component in a given scene
  114078. */
  114079. register(): void;
  114080. /**
  114081. * Rebuilds the elements related to this component in case of
  114082. * context lost for instance.
  114083. */
  114084. rebuild(): void;
  114085. /**
  114086. * Adds all the elements from the container to the scene
  114087. * @param container the container holding the elements
  114088. */
  114089. addFromContainer(container: AbstractScene): void;
  114090. /**
  114091. * Removes all the elements in the container from the scene
  114092. * @param container contains the elements to remove
  114093. * @param dispose if the removed element should be disposed (default: false)
  114094. */
  114095. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114096. /**
  114097. * Serializes the component data to the specified json object
  114098. * @param serializationObject The object to serialize to
  114099. */
  114100. serialize(serializationObject: any): void;
  114101. /**
  114102. * Disposes the component and the associated ressources.
  114103. */
  114104. dispose(): void;
  114105. private _draw;
  114106. }
  114107. }
  114108. declare module BABYLON {
  114109. /**
  114110. * Defines the shadow generator component responsible to manage any shadow generators
  114111. * in a given scene.
  114112. */
  114113. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114114. /**
  114115. * The component name helpfull to identify the component in the list of scene components.
  114116. */
  114117. readonly name: string;
  114118. /**
  114119. * The scene the component belongs to.
  114120. */
  114121. scene: Scene;
  114122. /**
  114123. * Creates a new instance of the component for the given scene
  114124. * @param scene Defines the scene to register the component in
  114125. */
  114126. constructor(scene: Scene);
  114127. /**
  114128. * Registers the component in a given scene
  114129. */
  114130. register(): void;
  114131. /**
  114132. * Rebuilds the elements related to this component in case of
  114133. * context lost for instance.
  114134. */
  114135. rebuild(): void;
  114136. /**
  114137. * Serializes the component data to the specified json object
  114138. * @param serializationObject The object to serialize to
  114139. */
  114140. serialize(serializationObject: any): void;
  114141. /**
  114142. * Adds all the elements from the container to the scene
  114143. * @param container the container holding the elements
  114144. */
  114145. addFromContainer(container: AbstractScene): void;
  114146. /**
  114147. * Removes all the elements in the container from the scene
  114148. * @param container contains the elements to remove
  114149. * @param dispose if the removed element should be disposed (default: false)
  114150. */
  114151. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114152. /**
  114153. * Rebuilds the elements related to this component in case of
  114154. * context lost for instance.
  114155. */
  114156. dispose(): void;
  114157. private _gatherRenderTargets;
  114158. }
  114159. }
  114160. declare module BABYLON {
  114161. /**
  114162. * A point light is a light defined by an unique point in world space.
  114163. * The light is emitted in every direction from this point.
  114164. * A good example of a point light is a standard light bulb.
  114165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114166. */
  114167. export class PointLight extends ShadowLight {
  114168. private _shadowAngle;
  114169. /**
  114170. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114171. * This specifies what angle the shadow will use to be created.
  114172. *
  114173. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114174. */
  114175. /**
  114176. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114177. * This specifies what angle the shadow will use to be created.
  114178. *
  114179. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114180. */
  114181. shadowAngle: number;
  114182. /**
  114183. * Gets the direction if it has been set.
  114184. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114185. */
  114186. /**
  114187. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114188. */
  114189. direction: Vector3;
  114190. /**
  114191. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114192. * A PointLight emits the light in every direction.
  114193. * It can cast shadows.
  114194. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114195. * ```javascript
  114196. * var pointLight = new PointLight("pl", camera.position, scene);
  114197. * ```
  114198. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114199. * @param name The light friendly name
  114200. * @param position The position of the point light in the scene
  114201. * @param scene The scene the lights belongs to
  114202. */
  114203. constructor(name: string, position: Vector3, scene: Scene);
  114204. /**
  114205. * Returns the string "PointLight"
  114206. * @returns the class name
  114207. */
  114208. getClassName(): string;
  114209. /**
  114210. * Returns the integer 0.
  114211. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114212. */
  114213. getTypeID(): number;
  114214. /**
  114215. * Specifies wether or not the shadowmap should be a cube texture.
  114216. * @returns true if the shadowmap needs to be a cube texture.
  114217. */
  114218. needCube(): boolean;
  114219. /**
  114220. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114223. */
  114224. getShadowDirection(faceIndex?: number): Vector3;
  114225. /**
  114226. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114227. * - fov = PI / 2
  114228. * - aspect ratio : 1.0
  114229. * - z-near and far equal to the active camera minZ and maxZ.
  114230. * Returns the PointLight.
  114231. */
  114232. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114233. protected _buildUniformLayout(): void;
  114234. /**
  114235. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114236. * @param effect The effect to update
  114237. * @param lightIndex The index of the light in the effect to update
  114238. * @returns The point light
  114239. */
  114240. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114241. /**
  114242. * Prepares the list of defines specific to the light type.
  114243. * @param defines the list of defines
  114244. * @param lightIndex defines the index of the light for the effect
  114245. */
  114246. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114247. }
  114248. }
  114249. declare module BABYLON {
  114250. /**
  114251. * Header information of HDR texture files.
  114252. */
  114253. export interface HDRInfo {
  114254. /**
  114255. * The height of the texture in pixels.
  114256. */
  114257. height: number;
  114258. /**
  114259. * The width of the texture in pixels.
  114260. */
  114261. width: number;
  114262. /**
  114263. * The index of the beginning of the data in the binary file.
  114264. */
  114265. dataPosition: number;
  114266. }
  114267. /**
  114268. * This groups tools to convert HDR texture to native colors array.
  114269. */
  114270. export class HDRTools {
  114271. private static Ldexp;
  114272. private static Rgbe2float;
  114273. private static readStringLine;
  114274. /**
  114275. * Reads header information from an RGBE texture stored in a native array.
  114276. * More information on this format are available here:
  114277. * https://en.wikipedia.org/wiki/RGBE_image_format
  114278. *
  114279. * @param uint8array The binary file stored in native array.
  114280. * @return The header information.
  114281. */
  114282. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114283. /**
  114284. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114285. * This RGBE texture needs to store the information as a panorama.
  114286. *
  114287. * More information on this format are available here:
  114288. * https://en.wikipedia.org/wiki/RGBE_image_format
  114289. *
  114290. * @param buffer The binary file stored in an array buffer.
  114291. * @param size The expected size of the extracted cubemap.
  114292. * @return The Cube Map information.
  114293. */
  114294. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114295. /**
  114296. * Returns the pixels data extracted from an RGBE texture.
  114297. * This pixels will be stored left to right up to down in the R G B order in one array.
  114298. *
  114299. * More information on this format are available here:
  114300. * https://en.wikipedia.org/wiki/RGBE_image_format
  114301. *
  114302. * @param uint8array The binary file stored in an array buffer.
  114303. * @param hdrInfo The header information of the file.
  114304. * @return The pixels data in RGB right to left up to down order.
  114305. */
  114306. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114307. private static RGBE_ReadPixels_RLE;
  114308. }
  114309. }
  114310. declare module BABYLON {
  114311. /**
  114312. * This represents a texture coming from an HDR input.
  114313. *
  114314. * The only supported format is currently panorama picture stored in RGBE format.
  114315. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114316. */
  114317. export class HDRCubeTexture extends BaseTexture {
  114318. private static _facesMapping;
  114319. private _generateHarmonics;
  114320. private _noMipmap;
  114321. private _textureMatrix;
  114322. private _size;
  114323. private _onLoad;
  114324. private _onError;
  114325. /**
  114326. * The texture URL.
  114327. */
  114328. url: string;
  114329. /**
  114330. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114331. */
  114332. coordinatesMode: number;
  114333. protected _isBlocking: boolean;
  114334. /**
  114335. * Sets wether or not the texture is blocking during loading.
  114336. */
  114337. /**
  114338. * Gets wether or not the texture is blocking during loading.
  114339. */
  114340. isBlocking: boolean;
  114341. protected _rotationY: number;
  114342. /**
  114343. * Sets texture matrix rotation angle around Y axis in radians.
  114344. */
  114345. /**
  114346. * Gets texture matrix rotation angle around Y axis radians.
  114347. */
  114348. rotationY: number;
  114349. /**
  114350. * Gets or sets the center of the bounding box associated with the cube texture
  114351. * It must define where the camera used to render the texture was set
  114352. */
  114353. boundingBoxPosition: Vector3;
  114354. private _boundingBoxSize;
  114355. /**
  114356. * Gets or sets the size of the bounding box associated with the cube texture
  114357. * When defined, the cubemap will switch to local mode
  114358. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114359. * @example https://www.babylonjs-playground.com/#RNASML
  114360. */
  114361. boundingBoxSize: Vector3;
  114362. /**
  114363. * Instantiates an HDRTexture from the following parameters.
  114364. *
  114365. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114366. * @param scene The scene the texture will be used in
  114367. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114368. * @param noMipmap Forces to not generate the mipmap if true
  114369. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114370. * @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)
  114371. * @param reserved Reserved flag for internal use.
  114372. */
  114373. 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>);
  114374. /**
  114375. * Get the current class name of the texture useful for serialization or dynamic coding.
  114376. * @returns "HDRCubeTexture"
  114377. */
  114378. getClassName(): string;
  114379. /**
  114380. * Occurs when the file is raw .hdr file.
  114381. */
  114382. private loadTexture;
  114383. clone(): HDRCubeTexture;
  114384. delayLoad(): void;
  114385. /**
  114386. * Get the texture reflection matrix used to rotate/transform the reflection.
  114387. * @returns the reflection matrix
  114388. */
  114389. getReflectionTextureMatrix(): Matrix;
  114390. /**
  114391. * Set the texture reflection matrix used to rotate/transform the reflection.
  114392. * @param value Define the reflection matrix to set
  114393. */
  114394. setReflectionTextureMatrix(value: Matrix): void;
  114395. /**
  114396. * Parses a JSON representation of an HDR Texture in order to create the texture
  114397. * @param parsedTexture Define the JSON representation
  114398. * @param scene Define the scene the texture should be created in
  114399. * @param rootUrl Define the root url in case we need to load relative dependencies
  114400. * @returns the newly created texture after parsing
  114401. */
  114402. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114403. serialize(): any;
  114404. }
  114405. }
  114406. declare module BABYLON {
  114407. /**
  114408. * Class used to control physics engine
  114409. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114410. */
  114411. export class PhysicsEngine implements IPhysicsEngine {
  114412. private _physicsPlugin;
  114413. /**
  114414. * Global value used to control the smallest number supported by the simulation
  114415. */
  114416. static Epsilon: number;
  114417. private _impostors;
  114418. private _joints;
  114419. /**
  114420. * Gets the gravity vector used by the simulation
  114421. */
  114422. gravity: Vector3;
  114423. /**
  114424. * Factory used to create the default physics plugin.
  114425. * @returns The default physics plugin
  114426. */
  114427. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114428. /**
  114429. * Creates a new Physics Engine
  114430. * @param gravity defines the gravity vector used by the simulation
  114431. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114432. */
  114433. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114434. /**
  114435. * Sets the gravity vector used by the simulation
  114436. * @param gravity defines the gravity vector to use
  114437. */
  114438. setGravity(gravity: Vector3): void;
  114439. /**
  114440. * Set the time step of the physics engine.
  114441. * Default is 1/60.
  114442. * To slow it down, enter 1/600 for example.
  114443. * To speed it up, 1/30
  114444. * @param newTimeStep defines the new timestep to apply to this world.
  114445. */
  114446. setTimeStep(newTimeStep?: number): void;
  114447. /**
  114448. * Get the time step of the physics engine.
  114449. * @returns the current time step
  114450. */
  114451. getTimeStep(): number;
  114452. /**
  114453. * Release all resources
  114454. */
  114455. dispose(): void;
  114456. /**
  114457. * Gets the name of the current physics plugin
  114458. * @returns the name of the plugin
  114459. */
  114460. getPhysicsPluginName(): string;
  114461. /**
  114462. * Adding a new impostor for the impostor tracking.
  114463. * This will be done by the impostor itself.
  114464. * @param impostor the impostor to add
  114465. */
  114466. addImpostor(impostor: PhysicsImpostor): void;
  114467. /**
  114468. * Remove an impostor from the engine.
  114469. * This impostor and its mesh will not longer be updated by the physics engine.
  114470. * @param impostor the impostor to remove
  114471. */
  114472. removeImpostor(impostor: PhysicsImpostor): void;
  114473. /**
  114474. * Add a joint to the physics engine
  114475. * @param mainImpostor defines the main impostor to which the joint is added.
  114476. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114477. * @param joint defines the joint that will connect both impostors.
  114478. */
  114479. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114480. /**
  114481. * Removes a joint from the simulation
  114482. * @param mainImpostor defines the impostor used with the joint
  114483. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114484. * @param joint defines the joint to remove
  114485. */
  114486. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114487. /**
  114488. * Called by the scene. No need to call it.
  114489. * @param delta defines the timespam between frames
  114490. */
  114491. _step(delta: number): void;
  114492. /**
  114493. * Gets the current plugin used to run the simulation
  114494. * @returns current plugin
  114495. */
  114496. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114497. /**
  114498. * Gets the list of physic impostors
  114499. * @returns an array of PhysicsImpostor
  114500. */
  114501. getImpostors(): Array<PhysicsImpostor>;
  114502. /**
  114503. * Gets the impostor for a physics enabled object
  114504. * @param object defines the object impersonated by the impostor
  114505. * @returns the PhysicsImpostor or null if not found
  114506. */
  114507. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114508. /**
  114509. * Gets the impostor for a physics body object
  114510. * @param body defines physics body used by the impostor
  114511. * @returns the PhysicsImpostor or null if not found
  114512. */
  114513. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114514. /**
  114515. * Does a raycast in the physics world
  114516. * @param from when should the ray start?
  114517. * @param to when should the ray end?
  114518. * @returns PhysicsRaycastResult
  114519. */
  114520. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114521. }
  114522. }
  114523. declare module BABYLON {
  114524. /** @hidden */
  114525. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114526. private _useDeltaForWorldStep;
  114527. world: any;
  114528. name: string;
  114529. private _physicsMaterials;
  114530. private _fixedTimeStep;
  114531. private _cannonRaycastResult;
  114532. private _raycastResult;
  114533. private _physicsBodysToRemoveAfterStep;
  114534. BJSCANNON: any;
  114535. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114536. setGravity(gravity: Vector3): void;
  114537. setTimeStep(timeStep: number): void;
  114538. getTimeStep(): number;
  114539. executeStep(delta: number): void;
  114540. private _removeMarkedPhysicsBodiesFromWorld;
  114541. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114542. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114543. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114544. private _processChildMeshes;
  114545. removePhysicsBody(impostor: PhysicsImpostor): void;
  114546. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114547. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114548. private _addMaterial;
  114549. private _checkWithEpsilon;
  114550. private _createShape;
  114551. private _createHeightmap;
  114552. private _minus90X;
  114553. private _plus90X;
  114554. private _tmpPosition;
  114555. private _tmpDeltaPosition;
  114556. private _tmpUnityRotation;
  114557. private _updatePhysicsBodyTransformation;
  114558. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114559. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114560. isSupported(): boolean;
  114561. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114562. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114563. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114564. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114565. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114566. getBodyMass(impostor: PhysicsImpostor): number;
  114567. getBodyFriction(impostor: PhysicsImpostor): number;
  114568. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114569. getBodyRestitution(impostor: PhysicsImpostor): number;
  114570. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114571. sleepBody(impostor: PhysicsImpostor): void;
  114572. wakeUpBody(impostor: PhysicsImpostor): void;
  114573. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114574. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114575. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114576. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114577. getRadius(impostor: PhysicsImpostor): number;
  114578. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114579. dispose(): void;
  114580. private _extendNamespace;
  114581. /**
  114582. * Does a raycast in the physics world
  114583. * @param from when should the ray start?
  114584. * @param to when should the ray end?
  114585. * @returns PhysicsRaycastResult
  114586. */
  114587. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114588. }
  114589. }
  114590. declare module BABYLON {
  114591. /** @hidden */
  114592. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114593. world: any;
  114594. name: string;
  114595. BJSOIMO: any;
  114596. private _raycastResult;
  114597. constructor(iterations?: number, oimoInjection?: any);
  114598. setGravity(gravity: Vector3): void;
  114599. setTimeStep(timeStep: number): void;
  114600. getTimeStep(): number;
  114601. private _tmpImpostorsArray;
  114602. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114603. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114604. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114605. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114606. private _tmpPositionVector;
  114607. removePhysicsBody(impostor: PhysicsImpostor): void;
  114608. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114609. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114610. isSupported(): boolean;
  114611. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114612. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114613. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114614. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114615. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114616. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114617. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114618. getBodyMass(impostor: PhysicsImpostor): number;
  114619. getBodyFriction(impostor: PhysicsImpostor): number;
  114620. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114621. getBodyRestitution(impostor: PhysicsImpostor): number;
  114622. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114623. sleepBody(impostor: PhysicsImpostor): void;
  114624. wakeUpBody(impostor: PhysicsImpostor): void;
  114625. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114626. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114627. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114628. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114629. getRadius(impostor: PhysicsImpostor): number;
  114630. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114631. dispose(): void;
  114632. /**
  114633. * Does a raycast in the physics world
  114634. * @param from when should the ray start?
  114635. * @param to when should the ray end?
  114636. * @returns PhysicsRaycastResult
  114637. */
  114638. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114639. }
  114640. }
  114641. declare module BABYLON {
  114642. /**
  114643. * Class containing static functions to help procedurally build meshes
  114644. */
  114645. export class RibbonBuilder {
  114646. /**
  114647. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114648. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114649. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114650. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114651. * * 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
  114652. * * 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
  114653. * * 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
  114654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114657. * * 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
  114658. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114659. * * 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
  114660. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114662. * @param name defines the name of the mesh
  114663. * @param options defines the options used to create the mesh
  114664. * @param scene defines the hosting scene
  114665. * @returns the ribbon mesh
  114666. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114668. */
  114669. static CreateRibbon(name: string, options: {
  114670. pathArray: Vector3[][];
  114671. closeArray?: boolean;
  114672. closePath?: boolean;
  114673. offset?: number;
  114674. updatable?: boolean;
  114675. sideOrientation?: number;
  114676. frontUVs?: Vector4;
  114677. backUVs?: Vector4;
  114678. instance?: Mesh;
  114679. invertUV?: boolean;
  114680. uvs?: Vector2[];
  114681. colors?: Color4[];
  114682. }, scene?: Nullable<Scene>): Mesh;
  114683. }
  114684. }
  114685. declare module BABYLON {
  114686. /**
  114687. * Class containing static functions to help procedurally build meshes
  114688. */
  114689. export class ShapeBuilder {
  114690. /**
  114691. * 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.
  114692. * * 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.
  114693. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114694. * * 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.
  114695. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114696. * * 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
  114697. * * 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
  114698. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114703. * @param name defines the name of the mesh
  114704. * @param options defines the options used to create the mesh
  114705. * @param scene defines the hosting scene
  114706. * @returns the extruded shape mesh
  114707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114709. */
  114710. static ExtrudeShape(name: string, options: {
  114711. shape: Vector3[];
  114712. path: Vector3[];
  114713. scale?: number;
  114714. rotation?: number;
  114715. cap?: number;
  114716. updatable?: boolean;
  114717. sideOrientation?: number;
  114718. frontUVs?: Vector4;
  114719. backUVs?: Vector4;
  114720. instance?: Mesh;
  114721. invertUV?: boolean;
  114722. }, scene?: Nullable<Scene>): Mesh;
  114723. /**
  114724. * Creates an custom extruded shape mesh.
  114725. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114726. * * 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.
  114727. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114728. * * 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
  114729. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114730. * * 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
  114731. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114732. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114733. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114734. * * 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
  114735. * * 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
  114736. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114741. * @param name defines the name of the mesh
  114742. * @param options defines the options used to create the mesh
  114743. * @param scene defines the hosting scene
  114744. * @returns the custom extruded shape mesh
  114745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114748. */
  114749. static ExtrudeShapeCustom(name: string, options: {
  114750. shape: Vector3[];
  114751. path: Vector3[];
  114752. scaleFunction?: any;
  114753. rotationFunction?: any;
  114754. ribbonCloseArray?: boolean;
  114755. ribbonClosePath?: boolean;
  114756. cap?: number;
  114757. updatable?: boolean;
  114758. sideOrientation?: number;
  114759. frontUVs?: Vector4;
  114760. backUVs?: Vector4;
  114761. instance?: Mesh;
  114762. invertUV?: boolean;
  114763. }, scene?: Nullable<Scene>): Mesh;
  114764. private static _ExtrudeShapeGeneric;
  114765. }
  114766. }
  114767. declare module BABYLON {
  114768. /**
  114769. * AmmoJS Physics plugin
  114770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114771. * @see https://github.com/kripken/ammo.js/
  114772. */
  114773. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114774. private _useDeltaForWorldStep;
  114775. /**
  114776. * Reference to the Ammo library
  114777. */
  114778. bjsAMMO: any;
  114779. /**
  114780. * Created ammoJS world which physics bodies are added to
  114781. */
  114782. world: any;
  114783. /**
  114784. * Name of the plugin
  114785. */
  114786. name: string;
  114787. private _timeStep;
  114788. private _fixedTimeStep;
  114789. private _maxSteps;
  114790. private _tmpQuaternion;
  114791. private _tmpAmmoTransform;
  114792. private _tmpAmmoQuaternion;
  114793. private _tmpAmmoConcreteContactResultCallback;
  114794. private _collisionConfiguration;
  114795. private _dispatcher;
  114796. private _overlappingPairCache;
  114797. private _solver;
  114798. private _softBodySolver;
  114799. private _tmpAmmoVectorA;
  114800. private _tmpAmmoVectorB;
  114801. private _tmpAmmoVectorC;
  114802. private _tmpAmmoVectorD;
  114803. private _tmpContactCallbackResult;
  114804. private _tmpAmmoVectorRCA;
  114805. private _tmpAmmoVectorRCB;
  114806. private _raycastResult;
  114807. private static readonly DISABLE_COLLISION_FLAG;
  114808. private static readonly KINEMATIC_FLAG;
  114809. private static readonly DISABLE_DEACTIVATION_FLAG;
  114810. /**
  114811. * Initializes the ammoJS plugin
  114812. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114813. * @param ammoInjection can be used to inject your own ammo reference
  114814. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114815. */
  114816. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114817. /**
  114818. * Sets the gravity of the physics world (m/(s^2))
  114819. * @param gravity Gravity to set
  114820. */
  114821. setGravity(gravity: Vector3): void;
  114822. /**
  114823. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114824. * @param timeStep timestep to use in seconds
  114825. */
  114826. setTimeStep(timeStep: number): void;
  114827. /**
  114828. * 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)
  114829. * @param fixedTimeStep fixedTimeStep to use in seconds
  114830. */
  114831. setFixedTimeStep(fixedTimeStep: number): void;
  114832. /**
  114833. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114834. * @param maxSteps the maximum number of steps by the physics engine per frame
  114835. */
  114836. setMaxSteps(maxSteps: number): void;
  114837. /**
  114838. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114839. * @returns the current timestep in seconds
  114840. */
  114841. getTimeStep(): number;
  114842. private _isImpostorInContact;
  114843. private _isImpostorPairInContact;
  114844. private _stepSimulation;
  114845. /**
  114846. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114847. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114848. * After the step the babylon meshes are set to the position of the physics imposters
  114849. * @param delta amount of time to step forward
  114850. * @param impostors array of imposters to update before/after the step
  114851. */
  114852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114853. /**
  114854. * Update babylon mesh to match physics world object
  114855. * @param impostor imposter to match
  114856. */
  114857. private _afterSoftStep;
  114858. /**
  114859. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114860. * @param impostor imposter to match
  114861. */
  114862. private _ropeStep;
  114863. /**
  114864. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114865. * @param impostor imposter to match
  114866. */
  114867. private _softbodyOrClothStep;
  114868. private _tmpVector;
  114869. private _tmpMatrix;
  114870. /**
  114871. * Applies an impulse on the imposter
  114872. * @param impostor imposter to apply impulse to
  114873. * @param force amount of force to be applied to the imposter
  114874. * @param contactPoint the location to apply the impulse on the imposter
  114875. */
  114876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114877. /**
  114878. * Applies a force on the imposter
  114879. * @param impostor imposter to apply force
  114880. * @param force amount of force to be applied to the imposter
  114881. * @param contactPoint the location to apply the force on the imposter
  114882. */
  114883. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114884. /**
  114885. * Creates a physics body using the plugin
  114886. * @param impostor the imposter to create the physics body on
  114887. */
  114888. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114889. /**
  114890. * Removes the physics body from the imposter and disposes of the body's memory
  114891. * @param impostor imposter to remove the physics body from
  114892. */
  114893. removePhysicsBody(impostor: PhysicsImpostor): void;
  114894. /**
  114895. * Generates a joint
  114896. * @param impostorJoint the imposter joint to create the joint with
  114897. */
  114898. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114899. /**
  114900. * Removes a joint
  114901. * @param impostorJoint the imposter joint to remove the joint from
  114902. */
  114903. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114904. private _addMeshVerts;
  114905. /**
  114906. * Initialise the soft body vertices to match its object's (mesh) vertices
  114907. * Softbody vertices (nodes) are in world space and to match this
  114908. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114909. * @param impostor to create the softbody for
  114910. */
  114911. private _softVertexData;
  114912. /**
  114913. * Create an impostor's soft body
  114914. * @param impostor to create the softbody for
  114915. */
  114916. private _createSoftbody;
  114917. /**
  114918. * Create cloth for an impostor
  114919. * @param impostor to create the softbody for
  114920. */
  114921. private _createCloth;
  114922. /**
  114923. * Create rope for an impostor
  114924. * @param impostor to create the softbody for
  114925. */
  114926. private _createRope;
  114927. private _addHullVerts;
  114928. private _createShape;
  114929. /**
  114930. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114931. * @param impostor imposter containing the physics body and babylon object
  114932. */
  114933. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114934. /**
  114935. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114936. * @param impostor imposter containing the physics body and babylon object
  114937. * @param newPosition new position
  114938. * @param newRotation new rotation
  114939. */
  114940. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114941. /**
  114942. * If this plugin is supported
  114943. * @returns true if its supported
  114944. */
  114945. isSupported(): boolean;
  114946. /**
  114947. * Sets the linear velocity of the physics body
  114948. * @param impostor imposter to set the velocity on
  114949. * @param velocity velocity to set
  114950. */
  114951. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114952. /**
  114953. * Sets the angular velocity of the physics body
  114954. * @param impostor imposter to set the velocity on
  114955. * @param velocity velocity to set
  114956. */
  114957. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114958. /**
  114959. * gets the linear velocity
  114960. * @param impostor imposter to get linear velocity from
  114961. * @returns linear velocity
  114962. */
  114963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114964. /**
  114965. * gets the angular velocity
  114966. * @param impostor imposter to get angular velocity from
  114967. * @returns angular velocity
  114968. */
  114969. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114970. /**
  114971. * Sets the mass of physics body
  114972. * @param impostor imposter to set the mass on
  114973. * @param mass mass to set
  114974. */
  114975. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114976. /**
  114977. * Gets the mass of the physics body
  114978. * @param impostor imposter to get the mass from
  114979. * @returns mass
  114980. */
  114981. getBodyMass(impostor: PhysicsImpostor): number;
  114982. /**
  114983. * Gets friction of the impostor
  114984. * @param impostor impostor to get friction from
  114985. * @returns friction value
  114986. */
  114987. getBodyFriction(impostor: PhysicsImpostor): number;
  114988. /**
  114989. * Sets friction of the impostor
  114990. * @param impostor impostor to set friction on
  114991. * @param friction friction value
  114992. */
  114993. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114994. /**
  114995. * Gets restitution of the impostor
  114996. * @param impostor impostor to get restitution from
  114997. * @returns restitution value
  114998. */
  114999. getBodyRestitution(impostor: PhysicsImpostor): number;
  115000. /**
  115001. * Sets resitution of the impostor
  115002. * @param impostor impostor to set resitution on
  115003. * @param restitution resitution value
  115004. */
  115005. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115006. /**
  115007. * Gets pressure inside the impostor
  115008. * @param impostor impostor to get pressure from
  115009. * @returns pressure value
  115010. */
  115011. getBodyPressure(impostor: PhysicsImpostor): number;
  115012. /**
  115013. * Sets pressure inside a soft body impostor
  115014. * Cloth and rope must remain 0 pressure
  115015. * @param impostor impostor to set pressure on
  115016. * @param pressure pressure value
  115017. */
  115018. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115019. /**
  115020. * Gets stiffness of the impostor
  115021. * @param impostor impostor to get stiffness from
  115022. * @returns pressure value
  115023. */
  115024. getBodyStiffness(impostor: PhysicsImpostor): number;
  115025. /**
  115026. * Sets stiffness of the impostor
  115027. * @param impostor impostor to set stiffness on
  115028. * @param stiffness stiffness value from 0 to 1
  115029. */
  115030. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115031. /**
  115032. * Gets velocityIterations of the impostor
  115033. * @param impostor impostor to get velocity iterations from
  115034. * @returns velocityIterations value
  115035. */
  115036. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115037. /**
  115038. * Sets velocityIterations of the impostor
  115039. * @param impostor impostor to set velocity iterations on
  115040. * @param velocityIterations velocityIterations value
  115041. */
  115042. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115043. /**
  115044. * Gets positionIterations of the impostor
  115045. * @param impostor impostor to get position iterations from
  115046. * @returns positionIterations value
  115047. */
  115048. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115049. /**
  115050. * Sets positionIterations of the impostor
  115051. * @param impostor impostor to set position on
  115052. * @param positionIterations positionIterations value
  115053. */
  115054. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115055. /**
  115056. * Append an anchor to a cloth object
  115057. * @param impostor is the cloth impostor to add anchor to
  115058. * @param otherImpostor is the rigid impostor to anchor to
  115059. * @param width ratio across width from 0 to 1
  115060. * @param height ratio up height from 0 to 1
  115061. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115062. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115063. */
  115064. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115065. /**
  115066. * Append an hook to a rope object
  115067. * @param impostor is the rope impostor to add hook to
  115068. * @param otherImpostor is the rigid impostor to hook to
  115069. * @param length ratio along the rope from 0 to 1
  115070. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115071. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115072. */
  115073. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115074. /**
  115075. * Sleeps the physics body and stops it from being active
  115076. * @param impostor impostor to sleep
  115077. */
  115078. sleepBody(impostor: PhysicsImpostor): void;
  115079. /**
  115080. * Activates the physics body
  115081. * @param impostor impostor to activate
  115082. */
  115083. wakeUpBody(impostor: PhysicsImpostor): void;
  115084. /**
  115085. * Updates the distance parameters of the joint
  115086. * @param joint joint to update
  115087. * @param maxDistance maximum distance of the joint
  115088. * @param minDistance minimum distance of the joint
  115089. */
  115090. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115091. /**
  115092. * Sets a motor on the joint
  115093. * @param joint joint to set motor on
  115094. * @param speed speed of the motor
  115095. * @param maxForce maximum force of the motor
  115096. * @param motorIndex index of the motor
  115097. */
  115098. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115099. /**
  115100. * Sets the motors limit
  115101. * @param joint joint to set limit on
  115102. * @param upperLimit upper limit
  115103. * @param lowerLimit lower limit
  115104. */
  115105. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115106. /**
  115107. * Syncs the position and rotation of a mesh with the impostor
  115108. * @param mesh mesh to sync
  115109. * @param impostor impostor to update the mesh with
  115110. */
  115111. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115112. /**
  115113. * Gets the radius of the impostor
  115114. * @param impostor impostor to get radius from
  115115. * @returns the radius
  115116. */
  115117. getRadius(impostor: PhysicsImpostor): number;
  115118. /**
  115119. * Gets the box size of the impostor
  115120. * @param impostor impostor to get box size from
  115121. * @param result the resulting box size
  115122. */
  115123. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115124. /**
  115125. * Disposes of the impostor
  115126. */
  115127. dispose(): void;
  115128. /**
  115129. * Does a raycast in the physics world
  115130. * @param from when should the ray start?
  115131. * @param to when should the ray end?
  115132. * @returns PhysicsRaycastResult
  115133. */
  115134. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115135. }
  115136. }
  115137. declare module BABYLON {
  115138. interface AbstractScene {
  115139. /**
  115140. * The list of reflection probes added to the scene
  115141. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115142. */
  115143. reflectionProbes: Array<ReflectionProbe>;
  115144. /**
  115145. * Removes the given reflection probe from this scene.
  115146. * @param toRemove The reflection probe to remove
  115147. * @returns The index of the removed reflection probe
  115148. */
  115149. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115150. /**
  115151. * Adds the given reflection probe to this scene.
  115152. * @param newReflectionProbe The reflection probe to add
  115153. */
  115154. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115155. }
  115156. /**
  115157. * Class used to generate realtime reflection / refraction cube textures
  115158. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115159. */
  115160. export class ReflectionProbe {
  115161. /** defines the name of the probe */
  115162. name: string;
  115163. private _scene;
  115164. private _renderTargetTexture;
  115165. private _projectionMatrix;
  115166. private _viewMatrix;
  115167. private _target;
  115168. private _add;
  115169. private _attachedMesh;
  115170. private _invertYAxis;
  115171. /** Gets or sets probe position (center of the cube map) */
  115172. position: Vector3;
  115173. /**
  115174. * Creates a new reflection probe
  115175. * @param name defines the name of the probe
  115176. * @param size defines the texture resolution (for each face)
  115177. * @param scene defines the hosting scene
  115178. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115179. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115180. */
  115181. constructor(
  115182. /** defines the name of the probe */
  115183. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115184. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115185. samples: number;
  115186. /** Gets or sets the refresh rate to use (on every frame by default) */
  115187. refreshRate: number;
  115188. /**
  115189. * Gets the hosting scene
  115190. * @returns a Scene
  115191. */
  115192. getScene(): Scene;
  115193. /** Gets the internal CubeTexture used to render to */
  115194. readonly cubeTexture: RenderTargetTexture;
  115195. /** Gets the list of meshes to render */
  115196. readonly renderList: Nullable<AbstractMesh[]>;
  115197. /**
  115198. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115199. * @param mesh defines the mesh to attach to
  115200. */
  115201. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115202. /**
  115203. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115204. * @param renderingGroupId The rendering group id corresponding to its index
  115205. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115206. */
  115207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115208. /**
  115209. * Clean all associated resources
  115210. */
  115211. dispose(): void;
  115212. /**
  115213. * Converts the reflection probe information to a readable string for debug purpose.
  115214. * @param fullDetails Supports for multiple levels of logging within scene loading
  115215. * @returns the human readable reflection probe info
  115216. */
  115217. toString(fullDetails?: boolean): string;
  115218. /**
  115219. * Get the class name of the relfection probe.
  115220. * @returns "ReflectionProbe"
  115221. */
  115222. getClassName(): string;
  115223. /**
  115224. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115225. * @returns The JSON representation of the texture
  115226. */
  115227. serialize(): any;
  115228. /**
  115229. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115230. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115231. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115232. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115233. * @returns The parsed reflection probe if successful
  115234. */
  115235. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115236. }
  115237. }
  115238. declare module BABYLON {
  115239. /** @hidden */
  115240. export var _BabylonLoaderRegistered: boolean;
  115241. }
  115242. declare module BABYLON {
  115243. /**
  115244. * The Physically based simple base material of BJS.
  115245. *
  115246. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115247. * It is used as the base class for both the specGloss and metalRough conventions.
  115248. */
  115249. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115250. /**
  115251. * Number of Simultaneous lights allowed on the material.
  115252. */
  115253. maxSimultaneousLights: number;
  115254. /**
  115255. * If sets to true, disables all the lights affecting the material.
  115256. */
  115257. disableLighting: boolean;
  115258. /**
  115259. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115260. */
  115261. environmentTexture: BaseTexture;
  115262. /**
  115263. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115264. */
  115265. invertNormalMapX: boolean;
  115266. /**
  115267. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115268. */
  115269. invertNormalMapY: boolean;
  115270. /**
  115271. * Normal map used in the model.
  115272. */
  115273. normalTexture: BaseTexture;
  115274. /**
  115275. * Emissivie color used to self-illuminate the model.
  115276. */
  115277. emissiveColor: Color3;
  115278. /**
  115279. * Emissivie texture used to self-illuminate the model.
  115280. */
  115281. emissiveTexture: BaseTexture;
  115282. /**
  115283. * Occlusion Channel Strenght.
  115284. */
  115285. occlusionStrength: number;
  115286. /**
  115287. * Occlusion Texture of the material (adding extra occlusion effects).
  115288. */
  115289. occlusionTexture: BaseTexture;
  115290. /**
  115291. * Defines the alpha limits in alpha test mode.
  115292. */
  115293. alphaCutOff: number;
  115294. /**
  115295. * Gets the current double sided mode.
  115296. */
  115297. /**
  115298. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115299. */
  115300. doubleSided: boolean;
  115301. /**
  115302. * Stores the pre-calculated light information of a mesh in a texture.
  115303. */
  115304. lightmapTexture: BaseTexture;
  115305. /**
  115306. * If true, the light map contains occlusion information instead of lighting info.
  115307. */
  115308. useLightmapAsShadowmap: boolean;
  115309. /**
  115310. * Instantiates a new PBRMaterial instance.
  115311. *
  115312. * @param name The material name
  115313. * @param scene The scene the material will be use in.
  115314. */
  115315. constructor(name: string, scene: Scene);
  115316. getClassName(): string;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * The PBR material of BJS following the metal roughness convention.
  115322. *
  115323. * This fits to the PBR convention in the GLTF definition:
  115324. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115325. */
  115326. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115327. /**
  115328. * The base color has two different interpretations depending on the value of metalness.
  115329. * When the material is a metal, the base color is the specific measured reflectance value
  115330. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115331. * of the material.
  115332. */
  115333. baseColor: Color3;
  115334. /**
  115335. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115336. * well as opacity information in the alpha channel.
  115337. */
  115338. baseTexture: BaseTexture;
  115339. /**
  115340. * Specifies the metallic scalar value of the material.
  115341. * Can also be used to scale the metalness values of the metallic texture.
  115342. */
  115343. metallic: number;
  115344. /**
  115345. * Specifies the roughness scalar value of the material.
  115346. * Can also be used to scale the roughness values of the metallic texture.
  115347. */
  115348. roughness: number;
  115349. /**
  115350. * Texture containing both the metallic value in the B channel and the
  115351. * roughness value in the G channel to keep better precision.
  115352. */
  115353. metallicRoughnessTexture: BaseTexture;
  115354. /**
  115355. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115356. *
  115357. * @param name The material name
  115358. * @param scene The scene the material will be use in.
  115359. */
  115360. constructor(name: string, scene: Scene);
  115361. /**
  115362. * Return the currrent class name of the material.
  115363. */
  115364. getClassName(): string;
  115365. /**
  115366. * Makes a duplicate of the current material.
  115367. * @param name - name to use for the new material.
  115368. */
  115369. clone(name: string): PBRMetallicRoughnessMaterial;
  115370. /**
  115371. * Serialize the material to a parsable JSON object.
  115372. */
  115373. serialize(): any;
  115374. /**
  115375. * Parses a JSON object correponding to the serialize function.
  115376. */
  115377. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115378. }
  115379. }
  115380. declare module BABYLON {
  115381. /**
  115382. * The PBR material of BJS following the specular glossiness convention.
  115383. *
  115384. * This fits to the PBR convention in the GLTF definition:
  115385. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115386. */
  115387. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115388. /**
  115389. * Specifies the diffuse color of the material.
  115390. */
  115391. diffuseColor: Color3;
  115392. /**
  115393. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115394. * channel.
  115395. */
  115396. diffuseTexture: BaseTexture;
  115397. /**
  115398. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115399. */
  115400. specularColor: Color3;
  115401. /**
  115402. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115403. */
  115404. glossiness: number;
  115405. /**
  115406. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115407. */
  115408. specularGlossinessTexture: BaseTexture;
  115409. /**
  115410. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115411. *
  115412. * @param name The material name
  115413. * @param scene The scene the material will be use in.
  115414. */
  115415. constructor(name: string, scene: Scene);
  115416. /**
  115417. * Return the currrent class name of the material.
  115418. */
  115419. getClassName(): string;
  115420. /**
  115421. * Makes a duplicate of the current material.
  115422. * @param name - name to use for the new material.
  115423. */
  115424. clone(name: string): PBRSpecularGlossinessMaterial;
  115425. /**
  115426. * Serialize the material to a parsable JSON object.
  115427. */
  115428. serialize(): any;
  115429. /**
  115430. * Parses a JSON object correponding to the serialize function.
  115431. */
  115432. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115433. }
  115434. }
  115435. declare module BABYLON {
  115436. /**
  115437. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115438. * It can help converting any input color in a desired output one. This can then be used to create effects
  115439. * from sepia, black and white to sixties or futuristic rendering...
  115440. *
  115441. * The only supported format is currently 3dl.
  115442. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115443. */
  115444. export class ColorGradingTexture extends BaseTexture {
  115445. /**
  115446. * The current texture matrix. (will always be identity in color grading texture)
  115447. */
  115448. private _textureMatrix;
  115449. /**
  115450. * The texture URL.
  115451. */
  115452. url: string;
  115453. /**
  115454. * Empty line regex stored for GC.
  115455. */
  115456. private static _noneEmptyLineRegex;
  115457. private _engine;
  115458. /**
  115459. * Instantiates a ColorGradingTexture from the following parameters.
  115460. *
  115461. * @param url The location of the color gradind data (currently only supporting 3dl)
  115462. * @param scene The scene the texture will be used in
  115463. */
  115464. constructor(url: string, scene: Scene);
  115465. /**
  115466. * Returns the texture matrix used in most of the material.
  115467. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115468. */
  115469. getTextureMatrix(): Matrix;
  115470. /**
  115471. * Occurs when the file being loaded is a .3dl LUT file.
  115472. */
  115473. private load3dlTexture;
  115474. /**
  115475. * Starts the loading process of the texture.
  115476. */
  115477. private loadTexture;
  115478. /**
  115479. * Clones the color gradind texture.
  115480. */
  115481. clone(): ColorGradingTexture;
  115482. /**
  115483. * Called during delayed load for textures.
  115484. */
  115485. delayLoad(): void;
  115486. /**
  115487. * Parses a color grading texture serialized by Babylon.
  115488. * @param parsedTexture The texture information being parsedTexture
  115489. * @param scene The scene to load the texture in
  115490. * @param rootUrl The root url of the data assets to load
  115491. * @return A color gradind texture
  115492. */
  115493. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115494. /**
  115495. * Serializes the LUT texture to json format.
  115496. */
  115497. serialize(): any;
  115498. }
  115499. }
  115500. declare module BABYLON {
  115501. /**
  115502. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115503. */
  115504. export class EquiRectangularCubeTexture extends BaseTexture {
  115505. /** The six faces of the cube. */
  115506. private static _FacesMapping;
  115507. private _noMipmap;
  115508. private _onLoad;
  115509. private _onError;
  115510. /** The size of the cubemap. */
  115511. private _size;
  115512. /** The buffer of the image. */
  115513. private _buffer;
  115514. /** The width of the input image. */
  115515. private _width;
  115516. /** The height of the input image. */
  115517. private _height;
  115518. /** The URL to the image. */
  115519. url: string;
  115520. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115521. coordinatesMode: number;
  115522. /**
  115523. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115524. * @param url The location of the image
  115525. * @param scene The scene the texture will be used in
  115526. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115527. * @param noMipmap Forces to not generate the mipmap if true
  115528. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115529. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115530. * @param onLoad — defines a callback called when texture is loaded
  115531. * @param onError — defines a callback called if there is an error
  115532. */
  115533. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115534. /**
  115535. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115536. */
  115537. private loadImage;
  115538. /**
  115539. * Convert the image buffer into a cubemap and create a CubeTexture.
  115540. */
  115541. private loadTexture;
  115542. /**
  115543. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115544. * @param buffer The ArrayBuffer that should be converted.
  115545. * @returns The buffer as Float32Array.
  115546. */
  115547. private getFloat32ArrayFromArrayBuffer;
  115548. /**
  115549. * Get the current class name of the texture useful for serialization or dynamic coding.
  115550. * @returns "EquiRectangularCubeTexture"
  115551. */
  115552. getClassName(): string;
  115553. /**
  115554. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115555. * @returns A clone of the current EquiRectangularCubeTexture.
  115556. */
  115557. clone(): EquiRectangularCubeTexture;
  115558. }
  115559. }
  115560. declare module BABYLON {
  115561. /**
  115562. * Based on jsTGALoader - Javascript loader for TGA file
  115563. * By Vincent Thibault
  115564. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115565. */
  115566. export class TGATools {
  115567. private static _TYPE_INDEXED;
  115568. private static _TYPE_RGB;
  115569. private static _TYPE_GREY;
  115570. private static _TYPE_RLE_INDEXED;
  115571. private static _TYPE_RLE_RGB;
  115572. private static _TYPE_RLE_GREY;
  115573. private static _ORIGIN_MASK;
  115574. private static _ORIGIN_SHIFT;
  115575. private static _ORIGIN_BL;
  115576. private static _ORIGIN_BR;
  115577. private static _ORIGIN_UL;
  115578. private static _ORIGIN_UR;
  115579. /**
  115580. * Gets the header of a TGA file
  115581. * @param data defines the TGA data
  115582. * @returns the header
  115583. */
  115584. static GetTGAHeader(data: Uint8Array): any;
  115585. /**
  115586. * Uploads TGA content to a Babylon Texture
  115587. * @hidden
  115588. */
  115589. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115590. /** @hidden */
  115591. 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;
  115592. /** @hidden */
  115593. 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;
  115594. /** @hidden */
  115595. 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;
  115596. /** @hidden */
  115597. 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;
  115598. /** @hidden */
  115599. 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;
  115600. /** @hidden */
  115601. 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;
  115602. }
  115603. }
  115604. declare module BABYLON {
  115605. /**
  115606. * Implementation of the TGA Texture Loader.
  115607. * @hidden
  115608. */
  115609. export class _TGATextureLoader implements IInternalTextureLoader {
  115610. /**
  115611. * Defines wether the loader supports cascade loading the different faces.
  115612. */
  115613. readonly supportCascades: boolean;
  115614. /**
  115615. * This returns if the loader support the current file information.
  115616. * @param extension defines the file extension of the file being loaded
  115617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115618. * @param fallback defines the fallback internal texture if any
  115619. * @param isBase64 defines whether the texture is encoded as a base64
  115620. * @param isBuffer defines whether the texture data are stored as a buffer
  115621. * @returns true if the loader can load the specified file
  115622. */
  115623. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115624. /**
  115625. * Transform the url before loading if required.
  115626. * @param rootUrl the url of the texture
  115627. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115628. * @returns the transformed texture
  115629. */
  115630. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115631. /**
  115632. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115633. * @param rootUrl the url of the texture
  115634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115635. * @returns the fallback texture
  115636. */
  115637. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115638. /**
  115639. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115640. * @param data contains the texture data
  115641. * @param texture defines the BabylonJS internal texture
  115642. * @param createPolynomials will be true if polynomials have been requested
  115643. * @param onLoad defines the callback to trigger once the texture is ready
  115644. * @param onError defines the callback to trigger in case of error
  115645. */
  115646. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115647. /**
  115648. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115649. * @param data contains the texture data
  115650. * @param texture defines the BabylonJS internal texture
  115651. * @param callback defines the method to call once ready to upload
  115652. */
  115653. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115654. }
  115655. }
  115656. declare module BABYLON {
  115657. /**
  115658. * Info about the .basis files
  115659. */
  115660. class BasisFileInfo {
  115661. /**
  115662. * If the file has alpha
  115663. */
  115664. hasAlpha: boolean;
  115665. /**
  115666. * Info about each image of the basis file
  115667. */
  115668. images: Array<{
  115669. levels: Array<{
  115670. width: number;
  115671. height: number;
  115672. transcodedPixels: ArrayBufferView;
  115673. }>;
  115674. }>;
  115675. }
  115676. /**
  115677. * Result of transcoding a basis file
  115678. */
  115679. class TranscodeResult {
  115680. /**
  115681. * Info about the .basis file
  115682. */
  115683. fileInfo: BasisFileInfo;
  115684. /**
  115685. * Format to use when loading the file
  115686. */
  115687. format: number;
  115688. }
  115689. /**
  115690. * Configuration options for the Basis transcoder
  115691. */
  115692. export class BasisTranscodeConfiguration {
  115693. /**
  115694. * Supported compression formats used to determine the supported output format of the transcoder
  115695. */
  115696. supportedCompressionFormats?: {
  115697. /**
  115698. * etc1 compression format
  115699. */
  115700. etc1?: boolean;
  115701. /**
  115702. * s3tc compression format
  115703. */
  115704. s3tc?: boolean;
  115705. /**
  115706. * pvrtc compression format
  115707. */
  115708. pvrtc?: boolean;
  115709. /**
  115710. * etc2 compression format
  115711. */
  115712. etc2?: boolean;
  115713. };
  115714. /**
  115715. * If mipmap levels should be loaded for transcoded images (Default: true)
  115716. */
  115717. loadMipmapLevels?: boolean;
  115718. /**
  115719. * Index of a single image to load (Default: all images)
  115720. */
  115721. loadSingleImage?: number;
  115722. }
  115723. /**
  115724. * Used to load .Basis files
  115725. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115726. */
  115727. export class BasisTools {
  115728. private static _IgnoreSupportedFormats;
  115729. /**
  115730. * URL to use when loading the basis transcoder
  115731. */
  115732. static JSModuleURL: string;
  115733. /**
  115734. * URL to use when loading the wasm module for the transcoder
  115735. */
  115736. static WasmModuleURL: string;
  115737. /**
  115738. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115739. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115740. * @returns internal format corresponding to the Basis format
  115741. */
  115742. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115743. private static _WorkerPromise;
  115744. private static _Worker;
  115745. private static _actionId;
  115746. private static _CreateWorkerAsync;
  115747. /**
  115748. * Transcodes a loaded image file to compressed pixel data
  115749. * @param imageData image data to transcode
  115750. * @param config configuration options for the transcoding
  115751. * @returns a promise resulting in the transcoded image
  115752. */
  115753. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115754. /**
  115755. * Loads a texture from the transcode result
  115756. * @param texture texture load to
  115757. * @param transcodeResult the result of transcoding the basis file to load from
  115758. */
  115759. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115760. }
  115761. }
  115762. declare module BABYLON {
  115763. /**
  115764. * Loader for .basis file format
  115765. */
  115766. export class _BasisTextureLoader implements IInternalTextureLoader {
  115767. /**
  115768. * Defines whether the loader supports cascade loading the different faces.
  115769. */
  115770. readonly supportCascades: boolean;
  115771. /**
  115772. * This returns if the loader support the current file information.
  115773. * @param extension defines the file extension of the file being loaded
  115774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115775. * @param fallback defines the fallback internal texture if any
  115776. * @param isBase64 defines whether the texture is encoded as a base64
  115777. * @param isBuffer defines whether the texture data are stored as a buffer
  115778. * @returns true if the loader can load the specified file
  115779. */
  115780. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115781. /**
  115782. * Transform the url before loading if required.
  115783. * @param rootUrl the url of the texture
  115784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115785. * @returns the transformed texture
  115786. */
  115787. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115788. /**
  115789. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115790. * @param rootUrl the url of the texture
  115791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115792. * @returns the fallback texture
  115793. */
  115794. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115795. /**
  115796. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115797. * @param data contains the texture data
  115798. * @param texture defines the BabylonJS internal texture
  115799. * @param createPolynomials will be true if polynomials have been requested
  115800. * @param onLoad defines the callback to trigger once the texture is ready
  115801. * @param onError defines the callback to trigger in case of error
  115802. */
  115803. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115804. /**
  115805. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115806. * @param data contains the texture data
  115807. * @param texture defines the BabylonJS internal texture
  115808. * @param callback defines the method to call once ready to upload
  115809. */
  115810. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115811. }
  115812. }
  115813. declare module BABYLON {
  115814. /**
  115815. * 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.
  115816. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115818. */
  115819. export class CustomProceduralTexture extends ProceduralTexture {
  115820. private _animate;
  115821. private _time;
  115822. private _config;
  115823. private _texturePath;
  115824. /**
  115825. * Instantiates a new Custom Procedural Texture.
  115826. * 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.
  115827. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115828. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115829. * @param name Define the name of the texture
  115830. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115831. * @param size Define the size of the texture to create
  115832. * @param scene Define the scene the texture belongs to
  115833. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115834. * @param generateMipMaps Define if the texture should creates mip maps or not
  115835. */
  115836. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115837. private _loadJson;
  115838. /**
  115839. * Is the texture ready to be used ? (rendered at least once)
  115840. * @returns true if ready, otherwise, false.
  115841. */
  115842. isReady(): boolean;
  115843. /**
  115844. * Render the texture to its associated render target.
  115845. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  115846. */
  115847. render(useCameraPostProcess?: boolean): void;
  115848. /**
  115849. * Update the list of dependant textures samplers in the shader.
  115850. */
  115851. updateTextures(): void;
  115852. /**
  115853. * Update the uniform values of the procedural texture in the shader.
  115854. */
  115855. updateShaderUniforms(): void;
  115856. /**
  115857. * Define if the texture animates or not.
  115858. */
  115859. animate: boolean;
  115860. }
  115861. }
  115862. declare module BABYLON {
  115863. /** @hidden */
  115864. export var noisePixelShader: {
  115865. name: string;
  115866. shader: string;
  115867. };
  115868. }
  115869. declare module BABYLON {
  115870. /**
  115871. * Class used to generate noise procedural textures
  115872. */
  115873. export class NoiseProceduralTexture extends ProceduralTexture {
  115874. private _time;
  115875. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  115876. brightness: number;
  115877. /** Defines the number of octaves to process */
  115878. octaves: number;
  115879. /** Defines the level of persistence (0.8 by default) */
  115880. persistence: number;
  115881. /** Gets or sets animation speed factor (default is 1) */
  115882. animationSpeedFactor: number;
  115883. /**
  115884. * Creates a new NoiseProceduralTexture
  115885. * @param name defines the name fo the texture
  115886. * @param size defines the size of the texture (default is 256)
  115887. * @param scene defines the hosting scene
  115888. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  115889. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  115890. */
  115891. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115892. private _updateShaderUniforms;
  115893. protected _getDefines(): string;
  115894. /** Generate the current state of the procedural texture */
  115895. render(useCameraPostProcess?: boolean): void;
  115896. /**
  115897. * Serializes this noise procedural texture
  115898. * @returns a serialized noise procedural texture object
  115899. */
  115900. serialize(): any;
  115901. /**
  115902. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  115903. * @param parsedTexture defines parsed texture data
  115904. * @param scene defines the current scene
  115905. * @param rootUrl defines the root URL containing noise procedural texture information
  115906. * @returns a parsed NoiseProceduralTexture
  115907. */
  115908. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  115909. }
  115910. }
  115911. declare module BABYLON {
  115912. /**
  115913. * Raw cube texture where the raw buffers are passed in
  115914. */
  115915. export class RawCubeTexture extends CubeTexture {
  115916. /**
  115917. * Creates a cube texture where the raw buffers are passed in.
  115918. * @param scene defines the scene the texture is attached to
  115919. * @param data defines the array of data to use to create each face
  115920. * @param size defines the size of the textures
  115921. * @param format defines the format of the data
  115922. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115923. * @param generateMipMaps defines if the engine should generate the mip levels
  115924. * @param invertY defines if data must be stored with Y axis inverted
  115925. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115926. * @param compression defines the compression used (null by default)
  115927. */
  115928. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115929. /**
  115930. * Updates the raw cube texture.
  115931. * @param data defines the data to store
  115932. * @param format defines the data format
  115933. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115934. * @param invertY defines if data must be stored with Y axis inverted
  115935. * @param compression defines the compression used (null by default)
  115936. * @param level defines which level of the texture to update
  115937. */
  115938. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115939. /**
  115940. * Updates a raw cube texture with RGBD encoded data.
  115941. * @param data defines the array of data [mipmap][face] to use to create each face
  115942. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115943. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115944. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115945. * @returns a promsie that resolves when the operation is complete
  115946. */
  115947. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115948. /**
  115949. * Clones the raw cube texture.
  115950. * @return a new cube texture
  115951. */
  115952. clone(): CubeTexture;
  115953. /** @hidden */
  115954. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115955. }
  115956. }
  115957. declare module BABYLON {
  115958. /**
  115959. * Class used to store 3D textures containing user data
  115960. */
  115961. export class RawTexture3D extends Texture {
  115962. /** Gets or sets the texture format to use */
  115963. format: number;
  115964. private _engine;
  115965. /**
  115966. * Create a new RawTexture3D
  115967. * @param data defines the data of the texture
  115968. * @param width defines the width of the texture
  115969. * @param height defines the height of the texture
  115970. * @param depth defines the depth of the texture
  115971. * @param format defines the texture format to use
  115972. * @param scene defines the hosting scene
  115973. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115974. * @param invertY defines if texture must be stored with Y axis inverted
  115975. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115976. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115977. */
  115978. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115979. /** Gets or sets the texture format to use */
  115980. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115981. /**
  115982. * Update the texture with new data
  115983. * @param data defines the data to store in the texture
  115984. */
  115985. update(data: ArrayBufferView): void;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /**
  115990. * Creates a refraction texture used by refraction channel of the standard material.
  115991. * It is like a mirror but to see through a material.
  115992. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115993. */
  115994. export class RefractionTexture extends RenderTargetTexture {
  115995. /**
  115996. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115997. * 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.
  115998. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115999. */
  116000. refractionPlane: Plane;
  116001. /**
  116002. * Define how deep under the surface we should see.
  116003. */
  116004. depth: number;
  116005. /**
  116006. * Creates a refraction texture used by refraction channel of the standard material.
  116007. * It is like a mirror but to see through a material.
  116008. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116009. * @param name Define the texture name
  116010. * @param size Define the size of the underlying texture
  116011. * @param scene Define the scene the refraction belongs to
  116012. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116013. */
  116014. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116015. /**
  116016. * Clone the refraction texture.
  116017. * @returns the cloned texture
  116018. */
  116019. clone(): RefractionTexture;
  116020. /**
  116021. * Serialize the texture to a JSON representation you could use in Parse later on
  116022. * @returns the serialized JSON representation
  116023. */
  116024. serialize(): any;
  116025. }
  116026. }
  116027. declare module BABYLON {
  116028. /**
  116029. * Defines the options related to the creation of an HtmlElementTexture
  116030. */
  116031. export interface IHtmlElementTextureOptions {
  116032. /**
  116033. * Defines wether mip maps should be created or not.
  116034. */
  116035. generateMipMaps?: boolean;
  116036. /**
  116037. * Defines the sampling mode of the texture.
  116038. */
  116039. samplingMode?: number;
  116040. /**
  116041. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116042. */
  116043. engine: Nullable<Engine>;
  116044. /**
  116045. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116046. */
  116047. scene: Nullable<Scene>;
  116048. }
  116049. /**
  116050. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116051. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116052. * is automatically managed.
  116053. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116054. * in your application.
  116055. *
  116056. * As the update is not automatic, you need to call them manually.
  116057. */
  116058. export class HtmlElementTexture extends BaseTexture {
  116059. /**
  116060. * The texture URL.
  116061. */
  116062. element: HTMLVideoElement | HTMLCanvasElement;
  116063. private static readonly DefaultOptions;
  116064. private _textureMatrix;
  116065. private _engine;
  116066. private _isVideo;
  116067. private _generateMipMaps;
  116068. private _samplingMode;
  116069. /**
  116070. * Instantiates a HtmlElementTexture from the following parameters.
  116071. *
  116072. * @param name Defines the name of the texture
  116073. * @param element Defines the video or canvas the texture is filled with
  116074. * @param options Defines the other none mandatory texture creation options
  116075. */
  116076. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116077. private _createInternalTexture;
  116078. /**
  116079. * Returns the texture matrix used in most of the material.
  116080. */
  116081. getTextureMatrix(): Matrix;
  116082. /**
  116083. * Updates the content of the texture.
  116084. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116085. */
  116086. update(invertY?: Nullable<boolean>): void;
  116087. }
  116088. }
  116089. declare module BABYLON {
  116090. /**
  116091. * Enum used to define the target of a block
  116092. */
  116093. export enum NodeMaterialBlockTargets {
  116094. /** Vertex shader */
  116095. Vertex = 1,
  116096. /** Fragment shader */
  116097. Fragment = 2,
  116098. /** Neutral */
  116099. Neutral = 4,
  116100. /** Vertex and Fragment */
  116101. VertexAndFragment = 3
  116102. }
  116103. }
  116104. declare module BABYLON {
  116105. /**
  116106. * Defines the kind of connection point for node based material
  116107. */
  116108. export enum NodeMaterialBlockConnectionPointTypes {
  116109. /** Float */
  116110. Float = 1,
  116111. /** Int */
  116112. Int = 2,
  116113. /** Vector2 */
  116114. Vector2 = 4,
  116115. /** Vector3 */
  116116. Vector3 = 8,
  116117. /** Vector4 */
  116118. Vector4 = 16,
  116119. /** Color3 */
  116120. Color3 = 32,
  116121. /** Color4 */
  116122. Color4 = 64,
  116123. /** Matrix */
  116124. Matrix = 128,
  116125. /** Detect type based on connection */
  116126. AutoDetect = 1024,
  116127. /** Output type that will be defined by input type */
  116128. BasedOnInput = 2048
  116129. }
  116130. }
  116131. declare module BABYLON {
  116132. /**
  116133. * Root class for all node material optimizers
  116134. */
  116135. export class NodeMaterialOptimizer {
  116136. /**
  116137. * Function used to optimize a NodeMaterial graph
  116138. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116139. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116140. */
  116141. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116142. }
  116143. }
  116144. declare module BABYLON {
  116145. /**
  116146. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116147. */
  116148. export class TransformBlock extends NodeMaterialBlock {
  116149. /**
  116150. * Defines the value to use to complement W value to transform it to a Vector4
  116151. */
  116152. complementW: number;
  116153. /**
  116154. * Defines the value to use to complement z value to transform it to a Vector4
  116155. */
  116156. complementZ: number;
  116157. /**
  116158. * Creates a new TransformBlock
  116159. * @param name defines the block name
  116160. */
  116161. constructor(name: string);
  116162. /**
  116163. * Gets the current class name
  116164. * @returns the class name
  116165. */
  116166. getClassName(): string;
  116167. /**
  116168. * Gets the vector input
  116169. */
  116170. readonly vector: NodeMaterialConnectionPoint;
  116171. /**
  116172. * Gets the output component
  116173. */
  116174. readonly output: NodeMaterialConnectionPoint;
  116175. /**
  116176. * Gets the matrix transform input
  116177. */
  116178. readonly transform: NodeMaterialConnectionPoint;
  116179. protected _buildBlock(state: NodeMaterialBuildState): this;
  116180. serialize(): any;
  116181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /**
  116186. * Block used to output the vertex position
  116187. */
  116188. export class VertexOutputBlock extends NodeMaterialBlock {
  116189. /**
  116190. * Creates a new VertexOutputBlock
  116191. * @param name defines the block name
  116192. */
  116193. constructor(name: string);
  116194. /**
  116195. * Gets the current class name
  116196. * @returns the class name
  116197. */
  116198. getClassName(): string;
  116199. /**
  116200. * Gets the vector input component
  116201. */
  116202. readonly vector: NodeMaterialConnectionPoint;
  116203. protected _buildBlock(state: NodeMaterialBuildState): this;
  116204. }
  116205. }
  116206. declare module BABYLON {
  116207. /**
  116208. * Block used to output the final color
  116209. */
  116210. export class FragmentOutputBlock extends NodeMaterialBlock {
  116211. /**
  116212. * Create a new FragmentOutputBlock
  116213. * @param name defines the block name
  116214. */
  116215. constructor(name: string);
  116216. /**
  116217. * Gets the current class name
  116218. * @returns the class name
  116219. */
  116220. getClassName(): string;
  116221. /**
  116222. * Gets the rgba input component
  116223. */
  116224. readonly rgba: NodeMaterialConnectionPoint;
  116225. /**
  116226. * Gets the rgb input component
  116227. */
  116228. readonly rgb: NodeMaterialConnectionPoint;
  116229. /**
  116230. * Gets the a input component
  116231. */
  116232. readonly a: NodeMaterialConnectionPoint;
  116233. protected _buildBlock(state: NodeMaterialBuildState): this;
  116234. }
  116235. }
  116236. declare module BABYLON {
  116237. /**
  116238. * Interface used to configure the node material editor
  116239. */
  116240. export interface INodeMaterialEditorOptions {
  116241. /** Define the URl to load node editor script */
  116242. editorURL?: string;
  116243. }
  116244. /** @hidden */
  116245. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116246. /** BONES */
  116247. NUM_BONE_INFLUENCERS: number;
  116248. BonesPerMesh: number;
  116249. BONETEXTURE: boolean;
  116250. /** MORPH TARGETS */
  116251. MORPHTARGETS: boolean;
  116252. MORPHTARGETS_NORMAL: boolean;
  116253. MORPHTARGETS_TANGENT: boolean;
  116254. MORPHTARGETS_UV: boolean;
  116255. NUM_MORPH_INFLUENCERS: number;
  116256. /** IMAGE PROCESSING */
  116257. IMAGEPROCESSING: boolean;
  116258. VIGNETTE: boolean;
  116259. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116260. VIGNETTEBLENDMODEOPAQUE: boolean;
  116261. TONEMAPPING: boolean;
  116262. TONEMAPPING_ACES: boolean;
  116263. CONTRAST: boolean;
  116264. EXPOSURE: boolean;
  116265. COLORCURVES: boolean;
  116266. COLORGRADING: boolean;
  116267. COLORGRADING3D: boolean;
  116268. SAMPLER3DGREENDEPTH: boolean;
  116269. SAMPLER3DBGRMAP: boolean;
  116270. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116271. constructor();
  116272. setValue(name: string, value: boolean): void;
  116273. }
  116274. /**
  116275. * Class used to configure NodeMaterial
  116276. */
  116277. export interface INodeMaterialOptions {
  116278. /**
  116279. * Defines if blocks should emit comments
  116280. */
  116281. emitComments: boolean;
  116282. }
  116283. /**
  116284. * Class used to create a node based material built by assembling shader blocks
  116285. */
  116286. export class NodeMaterial extends PushMaterial {
  116287. private static _BuildIdGenerator;
  116288. private _options;
  116289. private _vertexCompilationState;
  116290. private _fragmentCompilationState;
  116291. private _sharedData;
  116292. private _buildId;
  116293. private _buildWasSuccessful;
  116294. private _cachedWorldViewMatrix;
  116295. private _cachedWorldViewProjectionMatrix;
  116296. private _optimizers;
  116297. private _animationFrame;
  116298. /** Define the URl to load node editor script */
  116299. static EditorURL: string;
  116300. private BJSNODEMATERIALEDITOR;
  116301. /** Get the inspector from bundle or global */
  116302. private _getGlobalNodeMaterialEditor;
  116303. /**
  116304. * 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)
  116305. */
  116306. ignoreAlpha: boolean;
  116307. /**
  116308. * Defines the maximum number of lights that can be used in the material
  116309. */
  116310. maxSimultaneousLights: number;
  116311. /**
  116312. * Observable raised when the material is built
  116313. */
  116314. onBuildObservable: Observable<NodeMaterial>;
  116315. /**
  116316. * Gets or sets the root nodes of the material vertex shader
  116317. */
  116318. _vertexOutputNodes: NodeMaterialBlock[];
  116319. /**
  116320. * Gets or sets the root nodes of the material fragment (pixel) shader
  116321. */
  116322. _fragmentOutputNodes: NodeMaterialBlock[];
  116323. /** Gets or sets options to control the node material overall behavior */
  116324. options: INodeMaterialOptions;
  116325. /**
  116326. * Default configuration related to image processing available in the standard Material.
  116327. */
  116328. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116329. /**
  116330. * Gets the image processing configuration used either in this material.
  116331. */
  116332. /**
  116333. * Sets the Default image processing configuration used either in the this material.
  116334. *
  116335. * If sets to null, the scene one is in use.
  116336. */
  116337. imageProcessingConfiguration: ImageProcessingConfiguration;
  116338. /**
  116339. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116340. */
  116341. attachedBlocks: NodeMaterialBlock[];
  116342. /**
  116343. * Create a new node based material
  116344. * @param name defines the material name
  116345. * @param scene defines the hosting scene
  116346. * @param options defines creation option
  116347. */
  116348. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  116349. /**
  116350. * Gets the current class name of the material e.g. "NodeMaterial"
  116351. * @returns the class name
  116352. */
  116353. getClassName(): string;
  116354. /**
  116355. * Keep track of the image processing observer to allow dispose and replace.
  116356. */
  116357. private _imageProcessingObserver;
  116358. /**
  116359. * Attaches a new image processing configuration to the Standard Material.
  116360. * @param configuration
  116361. */
  116362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116363. /**
  116364. * Adds a new optimizer to the list of optimizers
  116365. * @param optimizer defines the optimizers to add
  116366. * @returns the current material
  116367. */
  116368. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116369. /**
  116370. * Remove an optimizer from the list of optimizers
  116371. * @param optimizer defines the optimizers to remove
  116372. * @returns the current material
  116373. */
  116374. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  116375. /**
  116376. * Add a new block to the list of output nodes
  116377. * @param node defines the node to add
  116378. * @returns the current material
  116379. */
  116380. addOutputNode(node: NodeMaterialBlock): this;
  116381. /**
  116382. * Remove a block from the list of root nodes
  116383. * @param node defines the node to remove
  116384. * @returns the current material
  116385. */
  116386. removeOutputNode(node: NodeMaterialBlock): this;
  116387. private _addVertexOutputNode;
  116388. private _removeVertexOutputNode;
  116389. private _addFragmentOutputNode;
  116390. private _removeFragmentOutputNode;
  116391. /**
  116392. * Specifies if the material will require alpha blending
  116393. * @returns a boolean specifying if alpha blending is needed
  116394. */
  116395. needAlphaBlending(): boolean;
  116396. /**
  116397. * Specifies if this material should be rendered in alpha test mode
  116398. * @returns a boolean specifying if an alpha test is needed.
  116399. */
  116400. needAlphaTesting(): boolean;
  116401. private _initializeBlock;
  116402. private _resetDualBlocks;
  116403. /**
  116404. * Build the material and generates the inner effect
  116405. * @param verbose defines if the build should log activity
  116406. */
  116407. build(verbose?: boolean): void;
  116408. /**
  116409. * Runs an otpimization phase to try to improve the shader code
  116410. */
  116411. optimize(): void;
  116412. private _prepareDefinesForAttributes;
  116413. /**
  116414. * Get if the submesh is ready to be used and all its information available.
  116415. * Child classes can use it to update shaders
  116416. * @param mesh defines the mesh to check
  116417. * @param subMesh defines which submesh to check
  116418. * @param useInstances specifies that instances should be used
  116419. * @returns a boolean indicating that the submesh is ready or not
  116420. */
  116421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116422. /**
  116423. * Get a string representing the shaders built by the current node graph
  116424. */
  116425. readonly compiledShaders: string;
  116426. /**
  116427. * Binds the world matrix to the material
  116428. * @param world defines the world transformation matrix
  116429. */
  116430. bindOnlyWorldMatrix(world: Matrix): void;
  116431. /**
  116432. * Binds the submesh to this material by preparing the effect and shader to draw
  116433. * @param world defines the world transformation matrix
  116434. * @param mesh defines the mesh containing the submesh
  116435. * @param subMesh defines the submesh to bind the material to
  116436. */
  116437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116438. /**
  116439. * Gets the active textures from the material
  116440. * @returns an array of textures
  116441. */
  116442. getActiveTextures(): BaseTexture[];
  116443. /**
  116444. * Specifies if the material uses a texture
  116445. * @param texture defines the texture to check against the material
  116446. * @returns a boolean specifying if the material uses the texture
  116447. */
  116448. hasTexture(texture: BaseTexture): boolean;
  116449. /**
  116450. * Disposes the material
  116451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116453. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116454. */
  116455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116456. /** Creates the node editor window. */
  116457. private _createNodeEditor;
  116458. /**
  116459. * Launch the node material editor
  116460. * @param config Define the configuration of the editor
  116461. * @return a promise fulfilled when the node editor is visible
  116462. */
  116463. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116464. /**
  116465. * Clear the current material
  116466. */
  116467. clear(): void;
  116468. /**
  116469. * Clear the current material and set it to a default state
  116470. */
  116471. setToDefault(): void;
  116472. private _gatherBlocks;
  116473. /**
  116474. * Serializes this material in a JSON representation
  116475. * @returns the serialized material object
  116476. */
  116477. serialize(): any;
  116478. /**
  116479. * Clear the current graph and load a new one from a serialization object
  116480. * @param source defines the JSON representation of the material
  116481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116482. */
  116483. loadFromSerialization(source: any, rootUrl?: string): void;
  116484. /**
  116485. * Creates a node material from parsed material data
  116486. * @param source defines the JSON representation of the material
  116487. * @param scene defines the hosting scene
  116488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116489. * @returns a new node material
  116490. */
  116491. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116492. }
  116493. }
  116494. declare module BABYLON {
  116495. /**
  116496. * Block used to read a texture from a sampler
  116497. */
  116498. export class TextureBlock extends NodeMaterialBlock {
  116499. private _defineName;
  116500. private _samplerName;
  116501. private _transformedUVName;
  116502. private _textureTransformName;
  116503. private _textureInfoName;
  116504. private _mainUVName;
  116505. private _mainUVDefineName;
  116506. /**
  116507. * Gets or sets the texture associated with the node
  116508. */
  116509. texture: Nullable<BaseTexture>;
  116510. /**
  116511. * Create a new TextureBlock
  116512. * @param name defines the block name
  116513. */
  116514. constructor(name: string);
  116515. /**
  116516. * Gets the current class name
  116517. * @returns the class name
  116518. */
  116519. getClassName(): string;
  116520. /**
  116521. * Gets the uv input component
  116522. */
  116523. readonly uv: NodeMaterialConnectionPoint;
  116524. /**
  116525. * Gets the rgba output component
  116526. */
  116527. readonly rgba: NodeMaterialConnectionPoint;
  116528. /**
  116529. * Gets the rgb output component
  116530. */
  116531. readonly rgb: NodeMaterialConnectionPoint;
  116532. /**
  116533. * Gets the r output component
  116534. */
  116535. readonly r: NodeMaterialConnectionPoint;
  116536. /**
  116537. * Gets the g output component
  116538. */
  116539. readonly g: NodeMaterialConnectionPoint;
  116540. /**
  116541. * Gets the b output component
  116542. */
  116543. readonly b: NodeMaterialConnectionPoint;
  116544. /**
  116545. * Gets the a output component
  116546. */
  116547. readonly a: NodeMaterialConnectionPoint;
  116548. autoConfigure(): void;
  116549. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116550. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116551. isReady(): boolean;
  116552. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116553. private _injectVertexCode;
  116554. private _writeOutput;
  116555. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116556. serialize(): any;
  116557. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116558. }
  116559. }
  116560. declare module BABYLON {
  116561. /**
  116562. * Enum used to define well known values e.g. values automatically provided by the system
  116563. */
  116564. export enum NodeMaterialWellKnownValues {
  116565. /** World */
  116566. World = 1,
  116567. /** View */
  116568. View = 2,
  116569. /** Projection */
  116570. Projection = 3,
  116571. /** ViewProjection */
  116572. ViewProjection = 4,
  116573. /** WorldView */
  116574. WorldView = 5,
  116575. /** WorldViewProjection */
  116576. WorldViewProjection = 6,
  116577. /** CameraPosition */
  116578. CameraPosition = 7,
  116579. /** Fog Color */
  116580. FogColor = 8
  116581. }
  116582. }
  116583. declare module BABYLON {
  116584. /**
  116585. * Block used to read a reflection texture from a sampler
  116586. */
  116587. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116588. private _define3DName;
  116589. private _defineCubicName;
  116590. private _defineExplicitName;
  116591. private _defineProjectionName;
  116592. private _defineLocalCubicName;
  116593. private _defineSphericalName;
  116594. private _definePlanarName;
  116595. private _defineEquirectangularName;
  116596. private _defineMirroredEquirectangularFixedName;
  116597. private _defineEquirectangularFixedName;
  116598. private _defineSkyboxName;
  116599. private _cubeSamplerName;
  116600. private _2DSamplerName;
  116601. private _positionUVWName;
  116602. private _directionWName;
  116603. private _reflectionCoordsName;
  116604. private _reflection2DCoordsName;
  116605. private _reflectionColorName;
  116606. private _reflectionMatrixName;
  116607. /**
  116608. * Gets or sets the texture associated with the node
  116609. */
  116610. texture: Nullable<BaseTexture>;
  116611. /**
  116612. * Create a new TextureBlock
  116613. * @param name defines the block name
  116614. */
  116615. constructor(name: string);
  116616. /**
  116617. * Gets the current class name
  116618. * @returns the class name
  116619. */
  116620. getClassName(): string;
  116621. /**
  116622. * Gets the world position input component
  116623. */
  116624. readonly position: NodeMaterialConnectionPoint;
  116625. /**
  116626. * Gets the world position input component
  116627. */
  116628. readonly worldPosition: NodeMaterialConnectionPoint;
  116629. /**
  116630. * Gets the world normal input component
  116631. */
  116632. readonly worldNormal: NodeMaterialConnectionPoint;
  116633. /**
  116634. * Gets the world input component
  116635. */
  116636. readonly world: NodeMaterialConnectionPoint;
  116637. /**
  116638. * Gets the camera (or eye) position component
  116639. */
  116640. readonly cameraPosition: NodeMaterialConnectionPoint;
  116641. /**
  116642. * Gets the view input component
  116643. */
  116644. readonly view: NodeMaterialConnectionPoint;
  116645. /**
  116646. * Gets the rgb output component
  116647. */
  116648. readonly rgb: NodeMaterialConnectionPoint;
  116649. /**
  116650. * Gets the r output component
  116651. */
  116652. readonly r: NodeMaterialConnectionPoint;
  116653. /**
  116654. * Gets the g output component
  116655. */
  116656. readonly g: NodeMaterialConnectionPoint;
  116657. /**
  116658. * Gets the b output component
  116659. */
  116660. readonly b: NodeMaterialConnectionPoint;
  116661. autoConfigure(): void;
  116662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116663. isReady(): boolean;
  116664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116665. private _injectVertexCode;
  116666. private _writeOutput;
  116667. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116668. serialize(): any;
  116669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116670. }
  116671. }
  116672. declare module BABYLON {
  116673. /**
  116674. * Class used to store shared data between 2 NodeMaterialBuildState
  116675. */
  116676. export class NodeMaterialBuildStateSharedData {
  116677. /**
  116678. * Gets the list of emitted varyings
  116679. */
  116680. varyings: string[];
  116681. /**
  116682. * Gets the varying declaration string
  116683. */
  116684. varyingDeclaration: string;
  116685. /**
  116686. * Input blocks
  116687. */
  116688. inputBlocks: InputBlock[];
  116689. /**
  116690. * Input blocks
  116691. */
  116692. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  116693. /**
  116694. * Bindable blocks (Blocks that need to set data to the effect)
  116695. */
  116696. bindableBlocks: NodeMaterialBlock[];
  116697. /**
  116698. * List of blocks that can provide a compilation fallback
  116699. */
  116700. blocksWithFallbacks: NodeMaterialBlock[];
  116701. /**
  116702. * List of blocks that can provide a define update
  116703. */
  116704. blocksWithDefines: NodeMaterialBlock[];
  116705. /**
  116706. * List of blocks that can provide a repeatable content
  116707. */
  116708. repeatableContentBlocks: NodeMaterialBlock[];
  116709. /**
  116710. * List of blocks that can provide a dynamic list of uniforms
  116711. */
  116712. dynamicUniformBlocks: NodeMaterialBlock[];
  116713. /**
  116714. * List of blocks that can block the isReady function for the material
  116715. */
  116716. blockingBlocks: NodeMaterialBlock[];
  116717. /**
  116718. * Gets the list of animated inputs
  116719. */
  116720. animatedInputs: InputBlock[];
  116721. /**
  116722. * Build Id used to avoid multiple recompilations
  116723. */
  116724. buildId: number;
  116725. /** List of emitted variables */
  116726. variableNames: {
  116727. [key: string]: number;
  116728. };
  116729. /** List of emitted defines */
  116730. defineNames: {
  116731. [key: string]: number;
  116732. };
  116733. /** Should emit comments? */
  116734. emitComments: boolean;
  116735. /** Emit build activity */
  116736. verbose: boolean;
  116737. /**
  116738. * Gets the compilation hints emitted at compilation time
  116739. */
  116740. hints: {
  116741. needWorldViewMatrix: boolean;
  116742. needWorldViewProjectionMatrix: boolean;
  116743. needAlphaBlending: boolean;
  116744. needAlphaTesting: boolean;
  116745. };
  116746. /**
  116747. * List of compilation checks
  116748. */
  116749. checks: {
  116750. emitVertex: boolean;
  116751. emitFragment: boolean;
  116752. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116753. };
  116754. /** Creates a new shared data */
  116755. constructor();
  116756. /**
  116757. * Emits console errors and exceptions if there is a failing check
  116758. */
  116759. emitErrors(): void;
  116760. }
  116761. }
  116762. declare module BABYLON {
  116763. /**
  116764. * Class used to store node based material build state
  116765. */
  116766. export class NodeMaterialBuildState {
  116767. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116768. supportUniformBuffers: boolean;
  116769. /**
  116770. * Gets the list of emitted attributes
  116771. */
  116772. attributes: string[];
  116773. /**
  116774. * Gets the list of emitted uniforms
  116775. */
  116776. uniforms: string[];
  116777. /**
  116778. * Gets the list of emitted uniform buffers
  116779. */
  116780. uniformBuffers: string[];
  116781. /**
  116782. * Gets the list of emitted samplers
  116783. */
  116784. samplers: string[];
  116785. /**
  116786. * Gets the list of emitted functions
  116787. */
  116788. functions: {
  116789. [key: string]: string;
  116790. };
  116791. /**
  116792. * Gets the target of the compilation state
  116793. */
  116794. target: NodeMaterialBlockTargets;
  116795. /**
  116796. * Gets the list of emitted counters
  116797. */
  116798. counters: {
  116799. [key: string]: number;
  116800. };
  116801. /**
  116802. * Shared data between multiple NodeMaterialBuildState instances
  116803. */
  116804. sharedData: NodeMaterialBuildStateSharedData;
  116805. /** @hidden */
  116806. _vertexState: NodeMaterialBuildState;
  116807. /** @hidden */
  116808. _attributeDeclaration: string;
  116809. /** @hidden */
  116810. _uniformDeclaration: string;
  116811. /** @hidden */
  116812. _samplerDeclaration: string;
  116813. /** @hidden */
  116814. _varyingTransfer: string;
  116815. private _repeatableContentAnchorIndex;
  116816. /** @hidden */
  116817. _builtCompilationString: string;
  116818. /**
  116819. * Gets the emitted compilation strings
  116820. */
  116821. compilationString: string;
  116822. /**
  116823. * Finalize the compilation strings
  116824. * @param state defines the current compilation state
  116825. */
  116826. finalize(state: NodeMaterialBuildState): void;
  116827. /** @hidden */
  116828. readonly _repeatableContentAnchor: string;
  116829. /** @hidden */
  116830. _getFreeVariableName(prefix: string): string;
  116831. /** @hidden */
  116832. _getFreeDefineName(prefix: string): string;
  116833. /** @hidden */
  116834. _excludeVariableName(name: string): void;
  116835. /** @hidden */
  116836. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  116837. /** @hidden */
  116838. _emitFunction(name: string, code: string, comments: string): void;
  116839. /** @hidden */
  116840. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  116841. replaceStrings?: {
  116842. search: RegExp;
  116843. replace: string;
  116844. }[];
  116845. repeatKey?: string;
  116846. }): string;
  116847. /** @hidden */
  116848. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  116849. repeatKey?: string;
  116850. removeAttributes?: boolean;
  116851. removeUniforms?: boolean;
  116852. removeVaryings?: boolean;
  116853. removeIfDef?: boolean;
  116854. replaceStrings?: {
  116855. search: RegExp;
  116856. replace: string;
  116857. }[];
  116858. }, storeKey?: string): void;
  116859. /** @hidden */
  116860. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  116861. /** @hidden */
  116862. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116863. }
  116864. }
  116865. declare module BABYLON {
  116866. /**
  116867. * Defines a block that can be used inside a node based material
  116868. */
  116869. export class NodeMaterialBlock {
  116870. private _buildId;
  116871. private _buildTarget;
  116872. private _target;
  116873. private _isFinalMerger;
  116874. private _isInput;
  116875. /** @hidden */
  116876. _inputs: NodeMaterialConnectionPoint[];
  116877. /** @hidden */
  116878. _outputs: NodeMaterialConnectionPoint[];
  116879. /**
  116880. * Gets or sets the name of the block
  116881. */
  116882. name: string;
  116883. /**
  116884. * Gets or sets the unique id of the node
  116885. */
  116886. uniqueId: number;
  116887. /**
  116888. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  116889. */
  116890. readonly isFinalMerger: boolean;
  116891. /**
  116892. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  116893. */
  116894. readonly isInput: boolean;
  116895. /**
  116896. * Gets or sets the build Id
  116897. */
  116898. buildId: number;
  116899. /**
  116900. * Gets or sets the target of the block
  116901. */
  116902. target: NodeMaterialBlockTargets;
  116903. /**
  116904. * Gets the list of input points
  116905. */
  116906. readonly inputs: NodeMaterialConnectionPoint[];
  116907. /** Gets the list of output points */
  116908. readonly outputs: NodeMaterialConnectionPoint[];
  116909. /**
  116910. * Find an input by its name
  116911. * @param name defines the name of the input to look for
  116912. * @returns the input or null if not found
  116913. */
  116914. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116915. /**
  116916. * Find an output by its name
  116917. * @param name defines the name of the outputto look for
  116918. * @returns the output or null if not found
  116919. */
  116920. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116921. /**
  116922. * Creates a new NodeMaterialBlock
  116923. * @param name defines the block name
  116924. * @param target defines the target of that block (Vertex by default)
  116925. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  116926. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  116927. */
  116928. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  116929. /**
  116930. * Initialize the block and prepare the context for build
  116931. * @param state defines the state that will be used for the build
  116932. */
  116933. initialize(state: NodeMaterialBuildState): void;
  116934. /**
  116935. * Bind data to effect. Will only be called for blocks with isBindable === true
  116936. * @param effect defines the effect to bind data to
  116937. * @param nodeMaterial defines the hosting NodeMaterial
  116938. * @param mesh defines the mesh that will be rendered
  116939. */
  116940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116941. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  116942. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  116943. protected _writeFloat(value: number): string;
  116944. /**
  116945. * Gets the current class name e.g. "NodeMaterialBlock"
  116946. * @returns the class name
  116947. */
  116948. getClassName(): string;
  116949. /**
  116950. * Register a new input. Must be called inside a block constructor
  116951. * @param name defines the connection point name
  116952. * @param type defines the connection point type
  116953. * @param isOptional defines a boolean indicating that this input can be omitted
  116954. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116955. * @returns the current block
  116956. */
  116957. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  116958. /**
  116959. * Register a new output. Must be called inside a block constructor
  116960. * @param name defines the connection point name
  116961. * @param type defines the connection point type
  116962. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116963. * @returns the current block
  116964. */
  116965. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  116966. /**
  116967. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  116968. * @param forOutput defines an optional connection point to check compatibility with
  116969. * @returns the first available input or null
  116970. */
  116971. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  116972. /**
  116973. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  116974. * @param forBlock defines an optional block to check compatibility with
  116975. * @returns the first available input or null
  116976. */
  116977. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  116978. /**
  116979. * Gets the sibling of the given output
  116980. * @param current defines the current output
  116981. * @returns the next output in the list or null
  116982. */
  116983. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  116984. /**
  116985. * Connect current block with another block
  116986. * @param other defines the block to connect with
  116987. * @param options define the various options to help pick the right connections
  116988. * @returns the current block
  116989. */
  116990. connectTo(other: NodeMaterialBlock, options?: {
  116991. input?: string;
  116992. output?: string;
  116993. outputSwizzle?: string;
  116994. }): this | undefined;
  116995. protected _buildBlock(state: NodeMaterialBuildState): void;
  116996. /**
  116997. * Add uniforms, samplers and uniform buffers at compilation time
  116998. * @param state defines the state to update
  116999. * @param nodeMaterial defines the node material requesting the update
  117000. * @param defines defines the material defines to update
  117001. */
  117002. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117003. /**
  117004. * Add potential fallbacks if shader compilation fails
  117005. * @param mesh defines the mesh to be rendered
  117006. * @param fallbacks defines the current prioritized list of fallbacks
  117007. */
  117008. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117009. /**
  117010. * Update defines for shader compilation
  117011. * @param mesh defines the mesh to be rendered
  117012. * @param nodeMaterial defines the node material requesting the update
  117013. * @param defines defines the material defines to update
  117014. * @param useInstances specifies that instances should be used
  117015. */
  117016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117017. /**
  117018. * Initialize defines for shader compilation
  117019. * @param mesh defines the mesh to be rendered
  117020. * @param nodeMaterial defines the node material requesting the update
  117021. * @param defines defines the material defines to be prepared
  117022. * @param useInstances specifies that instances should be used
  117023. */
  117024. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117025. /**
  117026. * Lets the block try to connect some inputs automatically
  117027. */
  117028. autoConfigure(): void;
  117029. /**
  117030. * Function called when a block is declared as repeatable content generator
  117031. * @param vertexShaderState defines the current compilation state for the vertex shader
  117032. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117033. * @param mesh defines the mesh to be rendered
  117034. * @param defines defines the material defines to update
  117035. */
  117036. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117037. /**
  117038. * Checks if the block is ready
  117039. * @param mesh defines the mesh to be rendered
  117040. * @param nodeMaterial defines the node material requesting the update
  117041. * @param defines defines the material defines to update
  117042. * @param useInstances specifies that instances should be used
  117043. * @returns true if the block is ready
  117044. */
  117045. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117046. private _processBuild;
  117047. /**
  117048. * Compile the current node and generate the shader code
  117049. * @param state defines the current compilation state (uniforms, samplers, current string)
  117050. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  117051. * @returns true if already built
  117052. */
  117053. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  117054. /**
  117055. * Clone the current block to a new identical block
  117056. * @param scene defines the hosting scene
  117057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117058. * @returns a copy of the current block
  117059. */
  117060. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117061. /**
  117062. * Serializes this block in a JSON representation
  117063. * @returns the serialized block object
  117064. */
  117065. serialize(): any;
  117066. /** @hidden */
  117067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117068. }
  117069. }
  117070. declare module BABYLON {
  117071. /**
  117072. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117073. */
  117074. export enum NodeMaterialBlockConnectionPointMode {
  117075. /** Value is an uniform */
  117076. Uniform = 0,
  117077. /** Value is a mesh attribute */
  117078. Attribute = 1,
  117079. /** Value is a varying between vertex and fragment shaders */
  117080. Varying = 2,
  117081. /** Mode is undefined */
  117082. Undefined = 3
  117083. }
  117084. }
  117085. declare module BABYLON {
  117086. /**
  117087. * Enum defining the type of animations supported by InputBlock
  117088. */
  117089. export enum AnimatedInputBlockTypes {
  117090. /** No animation */
  117091. None = 0,
  117092. /** Time based animation. Will only work for floats */
  117093. Time = 1
  117094. }
  117095. }
  117096. declare module BABYLON {
  117097. /**
  117098. * Block used to expose an input value
  117099. */
  117100. export class InputBlock extends NodeMaterialBlock {
  117101. private _mode;
  117102. private _associatedVariableName;
  117103. private _storedValue;
  117104. private _valueCallback;
  117105. private _type;
  117106. private _animationType;
  117107. /** @hidden */
  117108. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117109. /**
  117110. * Gets or sets the connection point type (default is float)
  117111. */
  117112. readonly type: NodeMaterialBlockConnectionPointTypes;
  117113. /**
  117114. * Creates a new InputBlock
  117115. * @param name defines the block name
  117116. * @param target defines the target of that block (Vertex by default)
  117117. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117118. */
  117119. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117120. /**
  117121. * Gets the output component
  117122. */
  117123. readonly output: NodeMaterialConnectionPoint;
  117124. /**
  117125. * Set the source of this connection point to a vertex attribute
  117126. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117127. * @returns the current connection point
  117128. */
  117129. setAsAttribute(attributeName?: string): InputBlock;
  117130. /**
  117131. * Set the source of this connection point to a well known value
  117132. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117133. * @returns the current connection point
  117134. */
  117135. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117136. /**
  117137. * Gets or sets the value of that point.
  117138. * Please note that this value will be ignored if valueCallback is defined
  117139. */
  117140. value: any;
  117141. /**
  117142. * Gets or sets a callback used to get the value of that point.
  117143. * Please note that setting this value will force the connection point to ignore the value property
  117144. */
  117145. valueCallback: () => any;
  117146. /**
  117147. * Gets or sets the associated variable name in the shader
  117148. */
  117149. associatedVariableName: string;
  117150. /** Gets or sets the type of animation applied to the input */
  117151. animationType: AnimatedInputBlockTypes;
  117152. /**
  117153. * Gets a boolean indicating that this connection point not defined yet
  117154. */
  117155. readonly isUndefined: boolean;
  117156. /**
  117157. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117158. * In this case the connection point name must be the name of the uniform to use.
  117159. * Can only be set on inputs
  117160. */
  117161. isUniform: boolean;
  117162. /**
  117163. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117164. * In this case the connection point name must be the name of the attribute to use
  117165. * Can only be set on inputs
  117166. */
  117167. isAttribute: boolean;
  117168. /**
  117169. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117170. * Can only be set on exit points
  117171. */
  117172. isVarying: boolean;
  117173. /**
  117174. * Gets a boolean indicating that the current connection point is a well known value
  117175. */
  117176. readonly isWellKnownValue: boolean;
  117177. /**
  117178. * Gets or sets the current well known value or null if not defined as well know value
  117179. */
  117180. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117181. /**
  117182. * Gets the current class name
  117183. * @returns the class name
  117184. */
  117185. getClassName(): string;
  117186. /**
  117187. * Animate the input if animationType !== None
  117188. * @param scene defines the rendering scene
  117189. */
  117190. animate(scene: Scene): void;
  117191. private _emitDefine;
  117192. /**
  117193. * Set the input block to its default value (based on its type)
  117194. */
  117195. setDefaultValue(): void;
  117196. private _emit;
  117197. /** @hidden */
  117198. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117199. /** @hidden */
  117200. _transmit(effect: Effect, scene: Scene): void;
  117201. protected _buildBlock(state: NodeMaterialBuildState): void;
  117202. serialize(): any;
  117203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117204. }
  117205. }
  117206. declare module BABYLON {
  117207. /**
  117208. * Defines a connection point for a block
  117209. */
  117210. export class NodeMaterialConnectionPoint {
  117211. /** @hidden */
  117212. _ownerBlock: NodeMaterialBlock;
  117213. /** @hidden */
  117214. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117215. private _endpoints;
  117216. private _associatedVariableName;
  117217. /** @hidden */
  117218. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117219. private _type;
  117220. /** @hidden */
  117221. _enforceAssociatedVariableName: boolean;
  117222. /**
  117223. * Gets or sets the additional types supported byt this connection point
  117224. */
  117225. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117226. /**
  117227. * Gets or sets the associated variable name in the shader
  117228. */
  117229. associatedVariableName: string;
  117230. /**
  117231. * Gets or sets the connection point type (default is float)
  117232. */
  117233. type: NodeMaterialBlockConnectionPointTypes;
  117234. /**
  117235. * Gets or sets the connection point name
  117236. */
  117237. name: string;
  117238. /**
  117239. * Gets or sets a boolean indicating that this connection point can be omitted
  117240. */
  117241. isOptional: boolean;
  117242. /**
  117243. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117244. */
  117245. define: string;
  117246. /** Gets or sets the target of that connection point */
  117247. target: NodeMaterialBlockTargets;
  117248. /**
  117249. * Gets a boolean indicating that the current point is connected
  117250. */
  117251. readonly isConnected: boolean;
  117252. /**
  117253. * Gets a boolean indicating that the current point is connected to an input block
  117254. */
  117255. readonly isConnectedToInput: boolean;
  117256. /**
  117257. * Gets a the connected input block (if any)
  117258. */
  117259. readonly connectInputBlock: Nullable<InputBlock>;
  117260. /** Get the other side of the connection (if any) */
  117261. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117262. /** Get the block that owns this connection point */
  117263. readonly ownerBlock: NodeMaterialBlock;
  117264. /** Get the block connected on the other side of this connection (if any) */
  117265. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117266. /** Get the block connected on the endpoints of this connection (if any) */
  117267. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117268. /** Gets the list of connected endpoints */
  117269. readonly endpoints: NodeMaterialConnectionPoint[];
  117270. /**
  117271. * Creates a new connection point
  117272. * @param name defines the connection point name
  117273. * @param ownerBlock defines the block hosting this connection point
  117274. */
  117275. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117276. /**
  117277. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117278. * @returns the class name
  117279. */
  117280. getClassName(): string;
  117281. /**
  117282. * Gets an boolean indicating if the current point can be connected to another point
  117283. * @param connectionPoint defines the other connection point
  117284. * @returns true if the connection is possible
  117285. */
  117286. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117287. /**
  117288. * Connect this point to another connection point
  117289. * @param connectionPoint defines the other connection point
  117290. * @returns the current connection point
  117291. */
  117292. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117293. /**
  117294. * Disconnect this point from one of his endpoint
  117295. * @param endpoint defines the other connection point
  117296. * @returns the current connection point
  117297. */
  117298. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117299. /**
  117300. * Serializes this point in a JSON representation
  117301. * @returns the serialized point object
  117302. */
  117303. serialize(): any;
  117304. }
  117305. }
  117306. declare module BABYLON {
  117307. /**
  117308. * Block used to add support for vertex skinning (bones)
  117309. */
  117310. export class BonesBlock extends NodeMaterialBlock {
  117311. /**
  117312. * Creates a new BonesBlock
  117313. * @param name defines the block name
  117314. */
  117315. constructor(name: string);
  117316. /**
  117317. * Initialize the block and prepare the context for build
  117318. * @param state defines the state that will be used for the build
  117319. */
  117320. initialize(state: NodeMaterialBuildState): void;
  117321. /**
  117322. * Gets the current class name
  117323. * @returns the class name
  117324. */
  117325. getClassName(): string;
  117326. /**
  117327. * Gets the matrix indices input component
  117328. */
  117329. readonly matricesIndices: NodeMaterialConnectionPoint;
  117330. /**
  117331. * Gets the matrix weights input component
  117332. */
  117333. readonly matricesWeights: NodeMaterialConnectionPoint;
  117334. /**
  117335. * Gets the extra matrix indices input component
  117336. */
  117337. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117338. /**
  117339. * Gets the extra matrix weights input component
  117340. */
  117341. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117342. /**
  117343. * Gets the world input component
  117344. */
  117345. readonly world: NodeMaterialConnectionPoint;
  117346. /**
  117347. * Gets the output component
  117348. */
  117349. readonly output: NodeMaterialConnectionPoint;
  117350. autoConfigure(): void;
  117351. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117354. protected _buildBlock(state: NodeMaterialBuildState): this;
  117355. }
  117356. }
  117357. declare module BABYLON {
  117358. /**
  117359. * Block used to add support for instances
  117360. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117361. */
  117362. export class InstancesBlock extends NodeMaterialBlock {
  117363. /**
  117364. * Creates a new InstancesBlock
  117365. * @param name defines the block name
  117366. */
  117367. constructor(name: string);
  117368. /**
  117369. * Gets the current class name
  117370. * @returns the class name
  117371. */
  117372. getClassName(): string;
  117373. /**
  117374. * Gets the first world row input component
  117375. */
  117376. readonly world0: NodeMaterialConnectionPoint;
  117377. /**
  117378. * Gets the second world row input component
  117379. */
  117380. readonly world1: NodeMaterialConnectionPoint;
  117381. /**
  117382. * Gets the third world row input component
  117383. */
  117384. readonly world2: NodeMaterialConnectionPoint;
  117385. /**
  117386. * Gets the forth world row input component
  117387. */
  117388. readonly world3: NodeMaterialConnectionPoint;
  117389. /**
  117390. * Gets the world input component
  117391. */
  117392. readonly world: NodeMaterialConnectionPoint;
  117393. /**
  117394. * Gets the output component
  117395. */
  117396. readonly output: NodeMaterialConnectionPoint;
  117397. autoConfigure(): void;
  117398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117399. protected _buildBlock(state: NodeMaterialBuildState): this;
  117400. }
  117401. }
  117402. declare module BABYLON {
  117403. /**
  117404. * Block used to add morph targets support to vertex shader
  117405. */
  117406. export class MorphTargetsBlock extends NodeMaterialBlock {
  117407. private _repeatableContentAnchor;
  117408. private _repeatebleContentGenerated;
  117409. /**
  117410. * Create a new MorphTargetsBlock
  117411. * @param name defines the block name
  117412. */
  117413. constructor(name: string);
  117414. /**
  117415. * Gets the current class name
  117416. * @returns the class name
  117417. */
  117418. getClassName(): string;
  117419. /**
  117420. * Gets the position input component
  117421. */
  117422. readonly position: NodeMaterialConnectionPoint;
  117423. /**
  117424. * Gets the normal input component
  117425. */
  117426. readonly normal: NodeMaterialConnectionPoint;
  117427. /**
  117428. * Gets the tangent input component
  117429. */
  117430. readonly tangent: NodeMaterialConnectionPoint;
  117431. /**
  117432. * Gets the tangent input component
  117433. */
  117434. readonly uv: NodeMaterialConnectionPoint;
  117435. /**
  117436. * Gets the position output component
  117437. */
  117438. readonly positionOutput: NodeMaterialConnectionPoint;
  117439. /**
  117440. * Gets the normal output component
  117441. */
  117442. readonly normalOutput: NodeMaterialConnectionPoint;
  117443. /**
  117444. * Gets the tangent output component
  117445. */
  117446. readonly tangentOutput: NodeMaterialConnectionPoint;
  117447. /**
  117448. * Gets the tangent output component
  117449. */
  117450. readonly uvOutput: NodeMaterialConnectionPoint;
  117451. initialize(state: NodeMaterialBuildState): void;
  117452. autoConfigure(): void;
  117453. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117455. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117456. protected _buildBlock(state: NodeMaterialBuildState): this;
  117457. }
  117458. }
  117459. declare module BABYLON {
  117460. /**
  117461. * Block used to add an alpha test in the fragment shader
  117462. */
  117463. export class AlphaTestBlock extends NodeMaterialBlock {
  117464. /**
  117465. * Gets or sets the alpha value where alpha testing happens
  117466. */
  117467. alphaCutOff: number;
  117468. /**
  117469. * Create a new AlphaTestBlock
  117470. * @param name defines the block name
  117471. */
  117472. constructor(name: string);
  117473. /**
  117474. * Gets the current class name
  117475. * @returns the class name
  117476. */
  117477. getClassName(): string;
  117478. /**
  117479. * Gets the color input component
  117480. */
  117481. readonly color: NodeMaterialConnectionPoint;
  117482. /**
  117483. * Gets the alpha input component
  117484. */
  117485. readonly alpha: NodeMaterialConnectionPoint;
  117486. protected _buildBlock(state: NodeMaterialBuildState): this;
  117487. }
  117488. }
  117489. declare module BABYLON {
  117490. /**
  117491. * Block used to create a Color3/4 out of individual inputs (one for each component)
  117492. */
  117493. export class ColorMergerBlock extends NodeMaterialBlock {
  117494. /**
  117495. * Create a new ColorMergerBlock
  117496. * @param name defines the block name
  117497. */
  117498. constructor(name: string);
  117499. /**
  117500. * Gets the current class name
  117501. * @returns the class name
  117502. */
  117503. getClassName(): string;
  117504. /**
  117505. * Gets the r component (input)
  117506. */
  117507. readonly r: NodeMaterialConnectionPoint;
  117508. /**
  117509. * Gets the g component (input)
  117510. */
  117511. readonly g: NodeMaterialConnectionPoint;
  117512. /**
  117513. * Gets the b component (input)
  117514. */
  117515. readonly b: NodeMaterialConnectionPoint;
  117516. /**
  117517. * Gets the a component (input)
  117518. */
  117519. readonly a: NodeMaterialConnectionPoint;
  117520. /**
  117521. * Gets the rgba component (output)
  117522. */
  117523. readonly rgba: NodeMaterialConnectionPoint;
  117524. /**
  117525. * Gets the rgb component (output)
  117526. */
  117527. readonly rgb: NodeMaterialConnectionPoint;
  117528. protected _buildBlock(state: NodeMaterialBuildState): this;
  117529. }
  117530. }
  117531. declare module BABYLON {
  117532. /**
  117533. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  117534. */
  117535. export class VectorMergerBlock extends NodeMaterialBlock {
  117536. /**
  117537. * Create a new VectorMergerBlock
  117538. * @param name defines the block name
  117539. */
  117540. constructor(name: string);
  117541. /**
  117542. * Gets the current class name
  117543. * @returns the class name
  117544. */
  117545. getClassName(): string;
  117546. /**
  117547. * Gets the x component (input)
  117548. */
  117549. readonly x: NodeMaterialConnectionPoint;
  117550. /**
  117551. * Gets the y component (input)
  117552. */
  117553. readonly y: NodeMaterialConnectionPoint;
  117554. /**
  117555. * Gets the z component (input)
  117556. */
  117557. readonly z: NodeMaterialConnectionPoint;
  117558. /**
  117559. * Gets the w component (input)
  117560. */
  117561. readonly w: NodeMaterialConnectionPoint;
  117562. /**
  117563. * Gets the xyzw component (output)
  117564. */
  117565. readonly xyzw: NodeMaterialConnectionPoint;
  117566. /**
  117567. * Gets the xyz component (output)
  117568. */
  117569. readonly xyz: NodeMaterialConnectionPoint;
  117570. /**
  117571. * Gets the xy component (output)
  117572. */
  117573. readonly xy: NodeMaterialConnectionPoint;
  117574. protected _buildBlock(state: NodeMaterialBuildState): this;
  117575. }
  117576. }
  117577. declare module BABYLON {
  117578. /**
  117579. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  117580. */
  117581. export class ColorSplitterBlock extends NodeMaterialBlock {
  117582. /**
  117583. * Create a new ColorSplitterBlock
  117584. * @param name defines the block name
  117585. */
  117586. constructor(name: string);
  117587. /**
  117588. * Gets the current class name
  117589. * @returns the class name
  117590. */
  117591. getClassName(): string;
  117592. /**
  117593. * Gets the rgba component (input)
  117594. */
  117595. readonly rgba: NodeMaterialConnectionPoint;
  117596. /**
  117597. * Gets the rgb component (input)
  117598. */
  117599. readonly rgbIn: NodeMaterialConnectionPoint;
  117600. /**
  117601. * Gets the rgb component (output)
  117602. */
  117603. readonly rgbOut: NodeMaterialConnectionPoint;
  117604. /**
  117605. * Gets the r component (output)
  117606. */
  117607. readonly r: NodeMaterialConnectionPoint;
  117608. /**
  117609. * Gets the g component (output)
  117610. */
  117611. readonly g: NodeMaterialConnectionPoint;
  117612. /**
  117613. * Gets the b component (output)
  117614. */
  117615. readonly b: NodeMaterialConnectionPoint;
  117616. /**
  117617. * Gets the a component (output)
  117618. */
  117619. readonly a: NodeMaterialConnectionPoint;
  117620. protected _buildBlock(state: NodeMaterialBuildState): this;
  117621. }
  117622. }
  117623. declare module BABYLON {
  117624. /**
  117625. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  117626. */
  117627. export class VectorSplitterBlock extends NodeMaterialBlock {
  117628. /**
  117629. * Create a new VectorSplitterBlock
  117630. * @param name defines the block name
  117631. */
  117632. constructor(name: string);
  117633. /**
  117634. * Gets the current class name
  117635. * @returns the class name
  117636. */
  117637. getClassName(): string;
  117638. /**
  117639. * Gets the xyzw component (input)
  117640. */
  117641. readonly xyzw: NodeMaterialConnectionPoint;
  117642. /**
  117643. * Gets the xyz component (input)
  117644. */
  117645. readonly xyzIn: NodeMaterialConnectionPoint;
  117646. /**
  117647. * Gets the xy component (input)
  117648. */
  117649. readonly xyIn: NodeMaterialConnectionPoint;
  117650. /**
  117651. * Gets the xyz component (output)
  117652. */
  117653. readonly xyzOut: NodeMaterialConnectionPoint;
  117654. /**
  117655. * Gets the xy component (output)
  117656. */
  117657. readonly xyOut: NodeMaterialConnectionPoint;
  117658. /**
  117659. * Gets the x component (output)
  117660. */
  117661. readonly x: NodeMaterialConnectionPoint;
  117662. /**
  117663. * Gets the y component (output)
  117664. */
  117665. readonly y: NodeMaterialConnectionPoint;
  117666. /**
  117667. * Gets the z component (output)
  117668. */
  117669. readonly z: NodeMaterialConnectionPoint;
  117670. /**
  117671. * Gets the w component (output)
  117672. */
  117673. readonly w: NodeMaterialConnectionPoint;
  117674. protected _buildBlock(state: NodeMaterialBuildState): this;
  117675. }
  117676. }
  117677. declare module BABYLON {
  117678. /**
  117679. * Block used to add image processing support to fragment shader
  117680. */
  117681. export class ImageProcessingBlock extends NodeMaterialBlock {
  117682. /**
  117683. * Create a new ImageProcessingBlock
  117684. * @param name defines the block name
  117685. */
  117686. constructor(name: string);
  117687. /**
  117688. * Gets the current class name
  117689. * @returns the class name
  117690. */
  117691. getClassName(): string;
  117692. /**
  117693. * Gets the color input component
  117694. */
  117695. readonly color: NodeMaterialConnectionPoint;
  117696. /**
  117697. * Gets the output component
  117698. */
  117699. readonly output: NodeMaterialConnectionPoint;
  117700. /**
  117701. * Initialize the block and prepare the context for build
  117702. * @param state defines the state that will be used for the build
  117703. */
  117704. initialize(state: NodeMaterialBuildState): void;
  117705. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117708. protected _buildBlock(state: NodeMaterialBuildState): this;
  117709. }
  117710. }
  117711. declare module BABYLON {
  117712. /**
  117713. * Block used to add support for scene fog
  117714. */
  117715. export class FogBlock extends NodeMaterialBlock {
  117716. private _fogDistanceName;
  117717. private _fogParameters;
  117718. /**
  117719. * Create a new FogBlock
  117720. * @param name defines the block name
  117721. */
  117722. constructor(name: string);
  117723. /**
  117724. * Gets the current class name
  117725. * @returns the class name
  117726. */
  117727. getClassName(): string;
  117728. /**
  117729. * Gets the world position input component
  117730. */
  117731. readonly worldPosition: NodeMaterialConnectionPoint;
  117732. /**
  117733. * Gets the view input component
  117734. */
  117735. readonly view: NodeMaterialConnectionPoint;
  117736. /**
  117737. * Gets the color input component
  117738. */
  117739. readonly color: NodeMaterialConnectionPoint;
  117740. /**
  117741. * Gets the fog color input component
  117742. */
  117743. readonly fogColor: NodeMaterialConnectionPoint;
  117744. /**
  117745. * Gets the output component
  117746. */
  117747. readonly output: NodeMaterialConnectionPoint;
  117748. autoConfigure(): void;
  117749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117751. protected _buildBlock(state: NodeMaterialBuildState): this;
  117752. }
  117753. }
  117754. declare module BABYLON {
  117755. /**
  117756. * Block used to add light in the fragment shader
  117757. */
  117758. export class LightBlock extends NodeMaterialBlock {
  117759. private _lightId;
  117760. /**
  117761. * Gets or sets the light associated with this block
  117762. */
  117763. light: Nullable<Light>;
  117764. /**
  117765. * Create a new LightBlock
  117766. * @param name defines the block name
  117767. */
  117768. constructor(name: string);
  117769. /**
  117770. * Gets the current class name
  117771. * @returns the class name
  117772. */
  117773. getClassName(): string;
  117774. /**
  117775. * Gets the world position input component
  117776. */
  117777. readonly worldPosition: NodeMaterialConnectionPoint;
  117778. /**
  117779. * Gets the world normal input component
  117780. */
  117781. readonly worldNormal: NodeMaterialConnectionPoint;
  117782. /**
  117783. * Gets the camera (or eye) position component
  117784. */
  117785. readonly cameraPosition: NodeMaterialConnectionPoint;
  117786. /**
  117787. * Gets the diffuse output component
  117788. */
  117789. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117790. /**
  117791. * Gets the specular output component
  117792. */
  117793. readonly specularOutput: NodeMaterialConnectionPoint;
  117794. autoConfigure(): void;
  117795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117796. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117797. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117798. private _injectVertexCode;
  117799. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117800. serialize(): any;
  117801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117802. }
  117803. }
  117804. declare module BABYLON {
  117805. /**
  117806. * Block used to multiply 2 values
  117807. */
  117808. export class MultiplyBlock extends NodeMaterialBlock {
  117809. /**
  117810. * Creates a new MultiplyBlock
  117811. * @param name defines the block name
  117812. */
  117813. constructor(name: string);
  117814. /**
  117815. * Gets the current class name
  117816. * @returns the class name
  117817. */
  117818. getClassName(): string;
  117819. /**
  117820. * Gets the left operand input component
  117821. */
  117822. readonly left: NodeMaterialConnectionPoint;
  117823. /**
  117824. * Gets the right operand input component
  117825. */
  117826. readonly right: NodeMaterialConnectionPoint;
  117827. /**
  117828. * Gets the output component
  117829. */
  117830. readonly output: NodeMaterialConnectionPoint;
  117831. protected _buildBlock(state: NodeMaterialBuildState): this;
  117832. }
  117833. }
  117834. declare module BABYLON {
  117835. /**
  117836. * Block used to add 2 vectors
  117837. */
  117838. export class AddBlock extends NodeMaterialBlock {
  117839. /**
  117840. * Creates a new AddBlock
  117841. * @param name defines the block name
  117842. */
  117843. constructor(name: string);
  117844. /**
  117845. * Gets the current class name
  117846. * @returns the class name
  117847. */
  117848. getClassName(): string;
  117849. /**
  117850. * Gets the left operand input component
  117851. */
  117852. readonly left: NodeMaterialConnectionPoint;
  117853. /**
  117854. * Gets the right operand input component
  117855. */
  117856. readonly right: NodeMaterialConnectionPoint;
  117857. /**
  117858. * Gets the output component
  117859. */
  117860. readonly output: NodeMaterialConnectionPoint;
  117861. protected _buildBlock(state: NodeMaterialBuildState): this;
  117862. }
  117863. }
  117864. declare module BABYLON {
  117865. /**
  117866. * Block used to scale a vector by a float
  117867. */
  117868. export class ScaleBlock extends NodeMaterialBlock {
  117869. /**
  117870. * Creates a new ScaleBlock
  117871. * @param name defines the block name
  117872. */
  117873. constructor(name: string);
  117874. /**
  117875. * Gets the current class name
  117876. * @returns the class name
  117877. */
  117878. getClassName(): string;
  117879. /**
  117880. * Gets the input component
  117881. */
  117882. readonly input: NodeMaterialConnectionPoint;
  117883. /**
  117884. * Gets the factor input component
  117885. */
  117886. readonly factor: NodeMaterialConnectionPoint;
  117887. /**
  117888. * Gets the output component
  117889. */
  117890. readonly output: NodeMaterialConnectionPoint;
  117891. protected _buildBlock(state: NodeMaterialBuildState): this;
  117892. }
  117893. }
  117894. declare module BABYLON {
  117895. /**
  117896. * Block used to clamp a float
  117897. */
  117898. export class ClampBlock extends NodeMaterialBlock {
  117899. /** Gets or sets the minimum range */
  117900. minimum: number;
  117901. /** Gets or sets the maximum range */
  117902. maximum: number;
  117903. /**
  117904. * Creates a new ClampBlock
  117905. * @param name defines the block name
  117906. */
  117907. constructor(name: string);
  117908. /**
  117909. * Gets the current class name
  117910. * @returns the class name
  117911. */
  117912. getClassName(): string;
  117913. /**
  117914. * Gets the value input component
  117915. */
  117916. readonly value: NodeMaterialConnectionPoint;
  117917. /**
  117918. * Gets the output component
  117919. */
  117920. readonly output: NodeMaterialConnectionPoint;
  117921. protected _buildBlock(state: NodeMaterialBuildState): this;
  117922. }
  117923. }
  117924. declare module BABYLON {
  117925. /**
  117926. * Block used to apply a cross product between 2 vectors
  117927. */
  117928. export class CrossBlock extends NodeMaterialBlock {
  117929. /**
  117930. * Creates a new CrossBlock
  117931. * @param name defines the block name
  117932. */
  117933. constructor(name: string);
  117934. /**
  117935. * Gets the current class name
  117936. * @returns the class name
  117937. */
  117938. getClassName(): string;
  117939. /**
  117940. * Gets the left operand input component
  117941. */
  117942. readonly left: NodeMaterialConnectionPoint;
  117943. /**
  117944. * Gets the right operand input component
  117945. */
  117946. readonly right: NodeMaterialConnectionPoint;
  117947. /**
  117948. * Gets the output component
  117949. */
  117950. readonly output: NodeMaterialConnectionPoint;
  117951. protected _buildBlock(state: NodeMaterialBuildState): this;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /**
  117956. * Block used to apply a dot product between 2 vectors
  117957. */
  117958. export class DotBlock extends NodeMaterialBlock {
  117959. /**
  117960. * Creates a new DotBlock
  117961. * @param name defines the block name
  117962. */
  117963. constructor(name: string);
  117964. /**
  117965. * Gets the current class name
  117966. * @returns the class name
  117967. */
  117968. getClassName(): string;
  117969. /**
  117970. * Gets the left operand input component
  117971. */
  117972. readonly left: NodeMaterialConnectionPoint;
  117973. /**
  117974. * Gets the right operand input component
  117975. */
  117976. readonly right: NodeMaterialConnectionPoint;
  117977. /**
  117978. * Gets the output component
  117979. */
  117980. readonly output: NodeMaterialConnectionPoint;
  117981. protected _buildBlock(state: NodeMaterialBuildState): this;
  117982. }
  117983. }
  117984. declare module BABYLON {
  117985. /**
  117986. * Block used to remap a float from a range to a new one
  117987. */
  117988. export class RemapBlock extends NodeMaterialBlock {
  117989. /**
  117990. * Gets or sets the source range
  117991. */
  117992. sourceRange: Vector2;
  117993. /**
  117994. * Gets or sets the target range
  117995. */
  117996. targetRange: Vector2;
  117997. /**
  117998. * Creates a new RemapBlock
  117999. * @param name defines the block name
  118000. */
  118001. constructor(name: string);
  118002. /**
  118003. * Gets the current class name
  118004. * @returns the class name
  118005. */
  118006. getClassName(): string;
  118007. /**
  118008. * Gets the input component
  118009. */
  118010. readonly input: NodeMaterialConnectionPoint;
  118011. /**
  118012. * Gets the output component
  118013. */
  118014. readonly output: NodeMaterialConnectionPoint;
  118015. protected _buildBlock(state: NodeMaterialBuildState): this;
  118016. }
  118017. }
  118018. declare module BABYLON {
  118019. /**
  118020. * Block used to normalize a vector
  118021. */
  118022. export class NormalizeBlock extends NodeMaterialBlock {
  118023. /**
  118024. * Creates a new NormalizeBlock
  118025. * @param name defines the block name
  118026. */
  118027. constructor(name: string);
  118028. /**
  118029. * Gets the current class name
  118030. * @returns the class name
  118031. */
  118032. getClassName(): string;
  118033. /**
  118034. * Gets the input component
  118035. */
  118036. readonly input: NodeMaterialConnectionPoint;
  118037. /**
  118038. * Gets the output component
  118039. */
  118040. readonly output: NodeMaterialConnectionPoint;
  118041. protected _buildBlock(state: NodeMaterialBuildState): this;
  118042. }
  118043. }
  118044. declare module BABYLON {
  118045. /**
  118046. * Operations supported by the Trigonometry block
  118047. */
  118048. export enum TrigonometryBlockOperations {
  118049. /** Cos */
  118050. Cos = 0,
  118051. /** Sin */
  118052. Sin = 1,
  118053. /** Abs */
  118054. Abs = 2
  118055. }
  118056. /**
  118057. * Block used to apply trigonometry operation to floats
  118058. */
  118059. export class TrigonometryBlock extends NodeMaterialBlock {
  118060. /**
  118061. * Gets or sets the operation applied by the block
  118062. */
  118063. operation: TrigonometryBlockOperations;
  118064. /**
  118065. * Creates a new TrigonometryBlock
  118066. * @param name defines the block name
  118067. */
  118068. constructor(name: string);
  118069. /**
  118070. * Gets the current class name
  118071. * @returns the class name
  118072. */
  118073. getClassName(): string;
  118074. /**
  118075. * Gets the input component
  118076. */
  118077. readonly input: NodeMaterialConnectionPoint;
  118078. /**
  118079. * Gets the output component
  118080. */
  118081. readonly output: NodeMaterialConnectionPoint;
  118082. protected _buildBlock(state: NodeMaterialBuildState): this;
  118083. }
  118084. }
  118085. declare module BABYLON {
  118086. /**
  118087. * Effect Render Options
  118088. */
  118089. export interface IEffectRendererOptions {
  118090. /**
  118091. * Defines the vertices positions.
  118092. */
  118093. positions?: number[];
  118094. /**
  118095. * Defines the indices.
  118096. */
  118097. indices?: number[];
  118098. }
  118099. /**
  118100. * Helper class to render one or more effects
  118101. */
  118102. export class EffectRenderer {
  118103. private engine;
  118104. private static _DefaultOptions;
  118105. private _vertexBuffers;
  118106. private _indexBuffer;
  118107. private _ringBufferIndex;
  118108. private _ringScreenBuffer;
  118109. private _fullscreenViewport;
  118110. private _getNextFrameBuffer;
  118111. /**
  118112. * Creates an effect renderer
  118113. * @param engine the engine to use for rendering
  118114. * @param options defines the options of the effect renderer
  118115. */
  118116. constructor(engine: Engine, options?: IEffectRendererOptions);
  118117. /**
  118118. * Sets the current viewport in normalized coordinates 0-1
  118119. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118120. */
  118121. setViewport(viewport?: Viewport): void;
  118122. /**
  118123. * Sets the current effect wrapper to use during draw.
  118124. * The effect needs to be ready before calling this api.
  118125. * This also sets the default full screen position attribute.
  118126. * @param effectWrapper Defines the effect to draw with
  118127. */
  118128. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118129. /**
  118130. * Draws a full screen quad.
  118131. */
  118132. draw(): void;
  118133. /**
  118134. * renders one or more effects to a specified texture
  118135. * @param effectWrappers list of effects to renderer
  118136. * @param outputTexture texture to draw to, if null it will render to the screen
  118137. */
  118138. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  118139. /**
  118140. * Disposes of the effect renderer
  118141. */
  118142. dispose(): void;
  118143. }
  118144. /**
  118145. * Options to create an EffectWrapper
  118146. */
  118147. interface EffectWrapperCreationOptions {
  118148. /**
  118149. * Engine to use to create the effect
  118150. */
  118151. engine: Engine;
  118152. /**
  118153. * Fragment shader for the effect
  118154. */
  118155. fragmentShader: string;
  118156. /**
  118157. * Vertex shader for the effect
  118158. */
  118159. vertexShader?: string;
  118160. /**
  118161. * Attributes to use in the shader
  118162. */
  118163. attributeNames?: Array<string>;
  118164. /**
  118165. * Uniforms to use in the shader
  118166. */
  118167. uniformNames?: Array<string>;
  118168. /**
  118169. * Texture sampler names to use in the shader
  118170. */
  118171. samplerNames?: Array<string>;
  118172. /**
  118173. * The friendly name of the effect displayed in Spector.
  118174. */
  118175. name?: string;
  118176. }
  118177. /**
  118178. * Wraps an effect to be used for rendering
  118179. */
  118180. export class EffectWrapper {
  118181. /**
  118182. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  118183. */
  118184. onApplyObservable: Observable<{}>;
  118185. /**
  118186. * The underlying effect
  118187. */
  118188. effect: Effect;
  118189. /**
  118190. * Creates an effect to be renderer
  118191. * @param creationOptions options to create the effect
  118192. */
  118193. constructor(creationOptions: EffectWrapperCreationOptions);
  118194. /**
  118195. * Disposes of the effect wrapper
  118196. */
  118197. dispose(): void;
  118198. }
  118199. }
  118200. declare module BABYLON {
  118201. /**
  118202. * Helper class to push actions to a pool of workers.
  118203. */
  118204. export class WorkerPool implements IDisposable {
  118205. private _workerInfos;
  118206. private _pendingActions;
  118207. /**
  118208. * Constructor
  118209. * @param workers Array of workers to use for actions
  118210. */
  118211. constructor(workers: Array<Worker>);
  118212. /**
  118213. * Terminates all workers and clears any pending actions.
  118214. */
  118215. dispose(): void;
  118216. /**
  118217. * Pushes an action to the worker pool. If all the workers are active, the action will be
  118218. * pended until a worker has completed its action.
  118219. * @param action The action to perform. Call onComplete when the action is complete.
  118220. */
  118221. push(action: (worker: Worker, onComplete: () => void) => void): void;
  118222. private _execute;
  118223. }
  118224. }
  118225. declare module BABYLON {
  118226. /**
  118227. * Configuration for Draco compression
  118228. */
  118229. export interface IDracoCompressionConfiguration {
  118230. /**
  118231. * Configuration for the decoder.
  118232. */
  118233. decoder: {
  118234. /**
  118235. * The url to the WebAssembly module.
  118236. */
  118237. wasmUrl?: string;
  118238. /**
  118239. * The url to the WebAssembly binary.
  118240. */
  118241. wasmBinaryUrl?: string;
  118242. /**
  118243. * The url to the fallback JavaScript module.
  118244. */
  118245. fallbackUrl?: string;
  118246. };
  118247. }
  118248. /**
  118249. * Draco compression (https://google.github.io/draco/)
  118250. *
  118251. * This class wraps the Draco module.
  118252. *
  118253. * **Encoder**
  118254. *
  118255. * The encoder is not currently implemented.
  118256. *
  118257. * **Decoder**
  118258. *
  118259. * 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.
  118260. *
  118261. * To update the configuration, use the following code:
  118262. * ```javascript
  118263. * DracoCompression.Configuration = {
  118264. * decoder: {
  118265. * wasmUrl: "<url to the WebAssembly library>",
  118266. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  118267. * fallbackUrl: "<url to the fallback JavaScript library>",
  118268. * }
  118269. * };
  118270. * ```
  118271. *
  118272. * 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.
  118273. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  118274. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  118275. *
  118276. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  118277. * ```javascript
  118278. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  118279. * ```
  118280. *
  118281. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  118282. */
  118283. export class DracoCompression implements IDisposable {
  118284. private _workerPoolPromise?;
  118285. private _decoderModulePromise?;
  118286. /**
  118287. * The configuration. Defaults to the following urls:
  118288. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  118289. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  118290. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  118291. */
  118292. static Configuration: IDracoCompressionConfiguration;
  118293. /**
  118294. * Returns true if the decoder configuration is available.
  118295. */
  118296. static readonly DecoderAvailable: boolean;
  118297. /**
  118298. * Default number of workers to create when creating the draco compression object.
  118299. */
  118300. static DefaultNumWorkers: number;
  118301. private static GetDefaultNumWorkers;
  118302. private static _Default;
  118303. /**
  118304. * Default instance for the draco compression object.
  118305. */
  118306. static readonly Default: DracoCompression;
  118307. /**
  118308. * Constructor
  118309. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  118310. */
  118311. constructor(numWorkers?: number);
  118312. /**
  118313. * Stop all async operations and release resources.
  118314. */
  118315. dispose(): void;
  118316. /**
  118317. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  118318. * @returns a promise that resolves when ready
  118319. */
  118320. whenReadyAsync(): Promise<void>;
  118321. /**
  118322. * Decode Draco compressed mesh data to vertex data.
  118323. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  118324. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  118325. * @returns A promise that resolves with the decoded vertex data
  118326. */
  118327. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  118328. [kind: string]: number;
  118329. }): Promise<VertexData>;
  118330. }
  118331. }
  118332. declare module BABYLON {
  118333. /**
  118334. * Class for building Constructive Solid Geometry
  118335. */
  118336. export class CSG {
  118337. private polygons;
  118338. /**
  118339. * The world matrix
  118340. */
  118341. matrix: Matrix;
  118342. /**
  118343. * Stores the position
  118344. */
  118345. position: Vector3;
  118346. /**
  118347. * Stores the rotation
  118348. */
  118349. rotation: Vector3;
  118350. /**
  118351. * Stores the rotation quaternion
  118352. */
  118353. rotationQuaternion: Nullable<Quaternion>;
  118354. /**
  118355. * Stores the scaling vector
  118356. */
  118357. scaling: Vector3;
  118358. /**
  118359. * Convert the Mesh to CSG
  118360. * @param mesh The Mesh to convert to CSG
  118361. * @returns A new CSG from the Mesh
  118362. */
  118363. static FromMesh(mesh: Mesh): CSG;
  118364. /**
  118365. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  118366. * @param polygons Polygons used to construct a CSG solid
  118367. */
  118368. private static FromPolygons;
  118369. /**
  118370. * Clones, or makes a deep copy, of the CSG
  118371. * @returns A new CSG
  118372. */
  118373. clone(): CSG;
  118374. /**
  118375. * Unions this CSG with another CSG
  118376. * @param csg The CSG to union against this CSG
  118377. * @returns The unioned CSG
  118378. */
  118379. union(csg: CSG): CSG;
  118380. /**
  118381. * Unions this CSG with another CSG in place
  118382. * @param csg The CSG to union against this CSG
  118383. */
  118384. unionInPlace(csg: CSG): void;
  118385. /**
  118386. * Subtracts this CSG with another CSG
  118387. * @param csg The CSG to subtract against this CSG
  118388. * @returns A new CSG
  118389. */
  118390. subtract(csg: CSG): CSG;
  118391. /**
  118392. * Subtracts this CSG with another CSG in place
  118393. * @param csg The CSG to subtact against this CSG
  118394. */
  118395. subtractInPlace(csg: CSG): void;
  118396. /**
  118397. * Intersect this CSG with another CSG
  118398. * @param csg The CSG to intersect against this CSG
  118399. * @returns A new CSG
  118400. */
  118401. intersect(csg: CSG): CSG;
  118402. /**
  118403. * Intersects this CSG with another CSG in place
  118404. * @param csg The CSG to intersect against this CSG
  118405. */
  118406. intersectInPlace(csg: CSG): void;
  118407. /**
  118408. * Return a new CSG solid with solid and empty space switched. This solid is
  118409. * not modified.
  118410. * @returns A new CSG solid with solid and empty space switched
  118411. */
  118412. inverse(): CSG;
  118413. /**
  118414. * Inverses the CSG in place
  118415. */
  118416. inverseInPlace(): void;
  118417. /**
  118418. * This is used to keep meshes transformations so they can be restored
  118419. * when we build back a Babylon Mesh
  118420. * NB : All CSG operations are performed in world coordinates
  118421. * @param csg The CSG to copy the transform attributes from
  118422. * @returns This CSG
  118423. */
  118424. copyTransformAttributes(csg: CSG): CSG;
  118425. /**
  118426. * Build Raw mesh from CSG
  118427. * Coordinates here are in world space
  118428. * @param name The name of the mesh geometry
  118429. * @param scene The Scene
  118430. * @param keepSubMeshes Specifies if the submeshes should be kept
  118431. * @returns A new Mesh
  118432. */
  118433. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  118434. /**
  118435. * Build Mesh from CSG taking material and transforms into account
  118436. * @param name The name of the Mesh
  118437. * @param material The material of the Mesh
  118438. * @param scene The Scene
  118439. * @param keepSubMeshes Specifies if submeshes should be kept
  118440. * @returns The new Mesh
  118441. */
  118442. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  118443. }
  118444. }
  118445. declare module BABYLON {
  118446. /**
  118447. * Class used to create a trail following a mesh
  118448. */
  118449. export class TrailMesh extends Mesh {
  118450. private _generator;
  118451. private _autoStart;
  118452. private _running;
  118453. private _diameter;
  118454. private _length;
  118455. private _sectionPolygonPointsCount;
  118456. private _sectionVectors;
  118457. private _sectionNormalVectors;
  118458. private _beforeRenderObserver;
  118459. /**
  118460. * @constructor
  118461. * @param name The value used by scene.getMeshByName() to do a lookup.
  118462. * @param generator The mesh to generate a trail.
  118463. * @param scene The scene to add this mesh to.
  118464. * @param diameter Diameter of trailing mesh. Default is 1.
  118465. * @param length Length of trailing mesh. Default is 60.
  118466. * @param autoStart Automatically start trailing mesh. Default true.
  118467. */
  118468. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  118469. /**
  118470. * "TrailMesh"
  118471. * @returns "TrailMesh"
  118472. */
  118473. getClassName(): string;
  118474. private _createMesh;
  118475. /**
  118476. * Start trailing mesh.
  118477. */
  118478. start(): void;
  118479. /**
  118480. * Stop trailing mesh.
  118481. */
  118482. stop(): void;
  118483. /**
  118484. * Update trailing mesh geometry.
  118485. */
  118486. update(): void;
  118487. /**
  118488. * Returns a new TrailMesh object.
  118489. * @param name is a string, the name given to the new mesh
  118490. * @param newGenerator use new generator object for cloned trail mesh
  118491. * @returns a new mesh
  118492. */
  118493. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  118494. /**
  118495. * Serializes this trail mesh
  118496. * @param serializationObject object to write serialization to
  118497. */
  118498. serialize(serializationObject: any): void;
  118499. /**
  118500. * Parses a serialized trail mesh
  118501. * @param parsedMesh the serialized mesh
  118502. * @param scene the scene to create the trail mesh in
  118503. * @returns the created trail mesh
  118504. */
  118505. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  118506. }
  118507. }
  118508. declare module BABYLON {
  118509. /**
  118510. * Class containing static functions to help procedurally build meshes
  118511. */
  118512. export class TiledBoxBuilder {
  118513. /**
  118514. * Creates a box mesh
  118515. * 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)
  118516. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118520. * @param name defines the name of the mesh
  118521. * @param options defines the options used to create the mesh
  118522. * @param scene defines the hosting scene
  118523. * @returns the box mesh
  118524. */
  118525. static CreateTiledBox(name: string, options: {
  118526. pattern?: number;
  118527. width?: number;
  118528. height?: number;
  118529. depth?: number;
  118530. tileSize?: number;
  118531. tileWidth?: number;
  118532. tileHeight?: number;
  118533. alignHorizontal?: number;
  118534. alignVertical?: number;
  118535. faceUV?: Vector4[];
  118536. faceColors?: Color4[];
  118537. sideOrientation?: number;
  118538. updatable?: boolean;
  118539. }, scene?: Nullable<Scene>): Mesh;
  118540. }
  118541. }
  118542. declare module BABYLON {
  118543. /**
  118544. * Class containing static functions to help procedurally build meshes
  118545. */
  118546. export class TorusKnotBuilder {
  118547. /**
  118548. * Creates a torus knot mesh
  118549. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118550. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118551. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118552. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118556. * @param name defines the name of the mesh
  118557. * @param options defines the options used to create the mesh
  118558. * @param scene defines the hosting scene
  118559. * @returns the torus knot mesh
  118560. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118561. */
  118562. static CreateTorusKnot(name: string, options: {
  118563. radius?: number;
  118564. tube?: number;
  118565. radialSegments?: number;
  118566. tubularSegments?: number;
  118567. p?: number;
  118568. q?: number;
  118569. updatable?: boolean;
  118570. sideOrientation?: number;
  118571. frontUVs?: Vector4;
  118572. backUVs?: Vector4;
  118573. }, scene: any): Mesh;
  118574. }
  118575. }
  118576. declare module BABYLON {
  118577. /**
  118578. * Polygon
  118579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118580. */
  118581. export class Polygon {
  118582. /**
  118583. * Creates a rectangle
  118584. * @param xmin bottom X coord
  118585. * @param ymin bottom Y coord
  118586. * @param xmax top X coord
  118587. * @param ymax top Y coord
  118588. * @returns points that make the resulting rectation
  118589. */
  118590. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  118591. /**
  118592. * Creates a circle
  118593. * @param radius radius of circle
  118594. * @param cx scale in x
  118595. * @param cy scale in y
  118596. * @param numberOfSides number of sides that make up the circle
  118597. * @returns points that make the resulting circle
  118598. */
  118599. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  118600. /**
  118601. * Creates a polygon from input string
  118602. * @param input Input polygon data
  118603. * @returns the parsed points
  118604. */
  118605. static Parse(input: string): Vector2[];
  118606. /**
  118607. * Starts building a polygon from x and y coordinates
  118608. * @param x x coordinate
  118609. * @param y y coordinate
  118610. * @returns the started path2
  118611. */
  118612. static StartingAt(x: number, y: number): Path2;
  118613. }
  118614. /**
  118615. * Builds a polygon
  118616. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118617. */
  118618. export class PolygonMeshBuilder {
  118619. private _points;
  118620. private _outlinepoints;
  118621. private _holes;
  118622. private _name;
  118623. private _scene;
  118624. private _epoints;
  118625. private _eholes;
  118626. private _addToepoint;
  118627. /**
  118628. * Babylon reference to the earcut plugin.
  118629. */
  118630. bjsEarcut: any;
  118631. /**
  118632. * Creates a PolygonMeshBuilder
  118633. * @param name name of the builder
  118634. * @param contours Path of the polygon
  118635. * @param scene scene to add to when creating the mesh
  118636. * @param earcutInjection can be used to inject your own earcut reference
  118637. */
  118638. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118639. /**
  118640. * Adds a whole within the polygon
  118641. * @param hole Array of points defining the hole
  118642. * @returns this
  118643. */
  118644. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118645. /**
  118646. * Creates the polygon
  118647. * @param updatable If the mesh should be updatable
  118648. * @param depth The depth of the mesh created
  118649. * @returns the created mesh
  118650. */
  118651. build(updatable?: boolean, depth?: number): Mesh;
  118652. /**
  118653. * Creates the polygon
  118654. * @param depth The depth of the mesh created
  118655. * @returns the created VertexData
  118656. */
  118657. buildVertexData(depth?: number): VertexData;
  118658. /**
  118659. * Adds a side to the polygon
  118660. * @param positions points that make the polygon
  118661. * @param normals normals of the polygon
  118662. * @param uvs uvs of the polygon
  118663. * @param indices indices of the polygon
  118664. * @param bounds bounds of the polygon
  118665. * @param points points of the polygon
  118666. * @param depth depth of the polygon
  118667. * @param flip flip of the polygon
  118668. */
  118669. private addSide;
  118670. }
  118671. }
  118672. declare module BABYLON {
  118673. /**
  118674. * Class containing static functions to help procedurally build meshes
  118675. */
  118676. export class PolygonBuilder {
  118677. /**
  118678. * Creates a polygon mesh
  118679. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118680. * * 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
  118681. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118684. * * Remember you can only change the shape positions, not their number when updating a polygon
  118685. * @param name defines the name of the mesh
  118686. * @param options defines the options used to create the mesh
  118687. * @param scene defines the hosting scene
  118688. * @param earcutInjection can be used to inject your own earcut reference
  118689. * @returns the polygon mesh
  118690. */
  118691. static CreatePolygon(name: string, options: {
  118692. shape: Vector3[];
  118693. holes?: Vector3[][];
  118694. depth?: number;
  118695. faceUV?: Vector4[];
  118696. faceColors?: Color4[];
  118697. updatable?: boolean;
  118698. sideOrientation?: number;
  118699. frontUVs?: Vector4;
  118700. backUVs?: Vector4;
  118701. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118702. /**
  118703. * Creates an extruded polygon mesh, with depth in the Y direction.
  118704. * * 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)
  118705. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118706. * @param name defines the name of the mesh
  118707. * @param options defines the options used to create the mesh
  118708. * @param scene defines the hosting scene
  118709. * @param earcutInjection can be used to inject your own earcut reference
  118710. * @returns the polygon mesh
  118711. */
  118712. static ExtrudePolygon(name: string, options: {
  118713. shape: Vector3[];
  118714. holes?: Vector3[][];
  118715. depth?: number;
  118716. faceUV?: Vector4[];
  118717. faceColors?: Color4[];
  118718. updatable?: boolean;
  118719. sideOrientation?: number;
  118720. frontUVs?: Vector4;
  118721. backUVs?: Vector4;
  118722. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118723. }
  118724. }
  118725. declare module BABYLON {
  118726. /**
  118727. * Class containing static functions to help procedurally build meshes
  118728. */
  118729. export class LatheBuilder {
  118730. /**
  118731. * Creates lathe mesh.
  118732. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118733. * * 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
  118734. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118735. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118736. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118737. * * 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
  118738. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118739. * * 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
  118740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118744. * @param name defines the name of the mesh
  118745. * @param options defines the options used to create the mesh
  118746. * @param scene defines the hosting scene
  118747. * @returns the lathe mesh
  118748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118749. */
  118750. static CreateLathe(name: string, options: {
  118751. shape: Vector3[];
  118752. radius?: number;
  118753. tessellation?: number;
  118754. clip?: number;
  118755. arc?: number;
  118756. closed?: boolean;
  118757. updatable?: boolean;
  118758. sideOrientation?: number;
  118759. frontUVs?: Vector4;
  118760. backUVs?: Vector4;
  118761. cap?: number;
  118762. invertUV?: boolean;
  118763. }, scene?: Nullable<Scene>): Mesh;
  118764. }
  118765. }
  118766. declare module BABYLON {
  118767. /**
  118768. * Class containing static functions to help procedurally build meshes
  118769. */
  118770. export class TiledPlaneBuilder {
  118771. /**
  118772. * Creates a tiled plane mesh
  118773. * * The parameter `pattern` will, depending on value, do nothing or
  118774. * * * flip (reflect about central vertical) alternate tiles across and up
  118775. * * * flip every tile on alternate rows
  118776. * * * rotate (180 degs) alternate tiles across and up
  118777. * * * rotate every tile on alternate rows
  118778. * * * flip and rotate alternate tiles across and up
  118779. * * * flip and rotate every tile on alternate rows
  118780. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  118781. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  118782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118784. * * 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)
  118785. * * 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)
  118786. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118787. * @param name defines the name of the mesh
  118788. * @param options defines the options used to create the mesh
  118789. * @param scene defines the hosting scene
  118790. * @returns the box mesh
  118791. */
  118792. static CreateTiledPlane(name: string, options: {
  118793. pattern?: number;
  118794. tileSize?: number;
  118795. tileWidth?: number;
  118796. tileHeight?: number;
  118797. size?: number;
  118798. width?: number;
  118799. height?: number;
  118800. alignHorizontal?: number;
  118801. alignVertical?: number;
  118802. sideOrientation?: number;
  118803. frontUVs?: Vector4;
  118804. backUVs?: Vector4;
  118805. updatable?: boolean;
  118806. }, scene?: Nullable<Scene>): Mesh;
  118807. }
  118808. }
  118809. declare module BABYLON {
  118810. /**
  118811. * Class containing static functions to help procedurally build meshes
  118812. */
  118813. export class TubeBuilder {
  118814. /**
  118815. * Creates a tube mesh.
  118816. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118817. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118818. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118819. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118820. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118821. * * 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)
  118822. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118823. * * 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
  118824. * * 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
  118825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118829. * @param name defines the name of the mesh
  118830. * @param options defines the options used to create the mesh
  118831. * @param scene defines the hosting scene
  118832. * @returns the tube mesh
  118833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118834. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118835. */
  118836. static CreateTube(name: string, options: {
  118837. path: Vector3[];
  118838. radius?: number;
  118839. tessellation?: number;
  118840. radiusFunction?: {
  118841. (i: number, distance: number): number;
  118842. };
  118843. cap?: number;
  118844. arc?: number;
  118845. updatable?: boolean;
  118846. sideOrientation?: number;
  118847. frontUVs?: Vector4;
  118848. backUVs?: Vector4;
  118849. instance?: Mesh;
  118850. invertUV?: boolean;
  118851. }, scene?: Nullable<Scene>): Mesh;
  118852. }
  118853. }
  118854. declare module BABYLON {
  118855. /**
  118856. * Class containing static functions to help procedurally build meshes
  118857. */
  118858. export class IcoSphereBuilder {
  118859. /**
  118860. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118861. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118862. * * 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`)
  118863. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118864. * * 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
  118865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118868. * @param name defines the name of the mesh
  118869. * @param options defines the options used to create the mesh
  118870. * @param scene defines the hosting scene
  118871. * @returns the icosahedron mesh
  118872. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118873. */
  118874. static CreateIcoSphere(name: string, options: {
  118875. radius?: number;
  118876. radiusX?: number;
  118877. radiusY?: number;
  118878. radiusZ?: number;
  118879. flat?: boolean;
  118880. subdivisions?: number;
  118881. sideOrientation?: number;
  118882. frontUVs?: Vector4;
  118883. backUVs?: Vector4;
  118884. updatable?: boolean;
  118885. }, scene?: Nullable<Scene>): Mesh;
  118886. }
  118887. }
  118888. declare module BABYLON {
  118889. /**
  118890. * Class containing static functions to help procedurally build meshes
  118891. */
  118892. export class DecalBuilder {
  118893. /**
  118894. * Creates a decal mesh.
  118895. * 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
  118896. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118897. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118898. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118899. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118900. * @param name defines the name of the mesh
  118901. * @param sourceMesh defines the mesh where the decal must be applied
  118902. * @param options defines the options used to create the mesh
  118903. * @param scene defines the hosting scene
  118904. * @returns the decal mesh
  118905. * @see https://doc.babylonjs.com/how_to/decals
  118906. */
  118907. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118908. position?: Vector3;
  118909. normal?: Vector3;
  118910. size?: Vector3;
  118911. angle?: number;
  118912. }): Mesh;
  118913. }
  118914. }
  118915. declare module BABYLON {
  118916. /**
  118917. * Class containing static functions to help procedurally build meshes
  118918. */
  118919. export class MeshBuilder {
  118920. /**
  118921. * Creates a box mesh
  118922. * * The parameter `size` sets the size (float) of each box side (default 1)
  118923. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118924. * * 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)
  118925. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118929. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118930. * @param name defines the name of the mesh
  118931. * @param options defines the options used to create the mesh
  118932. * @param scene defines the hosting scene
  118933. * @returns the box mesh
  118934. */
  118935. static CreateBox(name: string, options: {
  118936. size?: number;
  118937. width?: number;
  118938. height?: number;
  118939. depth?: number;
  118940. faceUV?: Vector4[];
  118941. faceColors?: Color4[];
  118942. sideOrientation?: number;
  118943. frontUVs?: Vector4;
  118944. backUVs?: Vector4;
  118945. updatable?: boolean;
  118946. }, scene?: Nullable<Scene>): Mesh;
  118947. /**
  118948. * Creates a tiled box mesh
  118949. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118951. * @param name defines the name of the mesh
  118952. * @param options defines the options used to create the mesh
  118953. * @param scene defines the hosting scene
  118954. * @returns the tiled box mesh
  118955. */
  118956. static CreateTiledBox(name: string, options: {
  118957. pattern?: number;
  118958. size?: number;
  118959. width?: number;
  118960. height?: number;
  118961. depth: number;
  118962. tileSize?: number;
  118963. tileWidth?: number;
  118964. tileHeight?: number;
  118965. faceUV?: Vector4[];
  118966. faceColors?: Color4[];
  118967. alignHorizontal?: number;
  118968. alignVertical?: number;
  118969. sideOrientation?: number;
  118970. updatable?: boolean;
  118971. }, scene?: Nullable<Scene>): Mesh;
  118972. /**
  118973. * Creates a sphere mesh
  118974. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118975. * * 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`)
  118976. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118977. * * 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
  118978. * * 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)
  118979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118982. * @param name defines the name of the mesh
  118983. * @param options defines the options used to create the mesh
  118984. * @param scene defines the hosting scene
  118985. * @returns the sphere mesh
  118986. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118987. */
  118988. static CreateSphere(name: string, options: {
  118989. segments?: number;
  118990. diameter?: number;
  118991. diameterX?: number;
  118992. diameterY?: number;
  118993. diameterZ?: number;
  118994. arc?: number;
  118995. slice?: number;
  118996. sideOrientation?: number;
  118997. frontUVs?: Vector4;
  118998. backUVs?: Vector4;
  118999. updatable?: boolean;
  119000. }, scene?: Nullable<Scene>): Mesh;
  119001. /**
  119002. * Creates a plane polygonal mesh. By default, this is a disc
  119003. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119004. * * 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
  119005. * * 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
  119006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119009. * @param name defines the name of the mesh
  119010. * @param options defines the options used to create the mesh
  119011. * @param scene defines the hosting scene
  119012. * @returns the plane polygonal mesh
  119013. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119014. */
  119015. static CreateDisc(name: string, options: {
  119016. radius?: number;
  119017. tessellation?: number;
  119018. arc?: number;
  119019. updatable?: boolean;
  119020. sideOrientation?: number;
  119021. frontUVs?: Vector4;
  119022. backUVs?: Vector4;
  119023. }, scene?: Nullable<Scene>): Mesh;
  119024. /**
  119025. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119026. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119027. * * 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`)
  119028. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119029. * * 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
  119030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119033. * @param name defines the name of the mesh
  119034. * @param options defines the options used to create the mesh
  119035. * @param scene defines the hosting scene
  119036. * @returns the icosahedron mesh
  119037. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119038. */
  119039. static CreateIcoSphere(name: string, options: {
  119040. radius?: number;
  119041. radiusX?: number;
  119042. radiusY?: number;
  119043. radiusZ?: number;
  119044. flat?: boolean;
  119045. subdivisions?: number;
  119046. sideOrientation?: number;
  119047. frontUVs?: Vector4;
  119048. backUVs?: Vector4;
  119049. updatable?: boolean;
  119050. }, scene?: Nullable<Scene>): Mesh;
  119051. /**
  119052. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119053. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119054. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119055. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119056. * * 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
  119057. * * 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
  119058. * * 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
  119059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119062. * * 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
  119063. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119064. * * 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
  119065. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119067. * @param name defines the name of the mesh
  119068. * @param options defines the options used to create the mesh
  119069. * @param scene defines the hosting scene
  119070. * @returns the ribbon mesh
  119071. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119073. */
  119074. static CreateRibbon(name: string, options: {
  119075. pathArray: Vector3[][];
  119076. closeArray?: boolean;
  119077. closePath?: boolean;
  119078. offset?: number;
  119079. updatable?: boolean;
  119080. sideOrientation?: number;
  119081. frontUVs?: Vector4;
  119082. backUVs?: Vector4;
  119083. instance?: Mesh;
  119084. invertUV?: boolean;
  119085. uvs?: Vector2[];
  119086. colors?: Color4[];
  119087. }, scene?: Nullable<Scene>): Mesh;
  119088. /**
  119089. * Creates a cylinder or a cone mesh
  119090. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119091. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119092. * * 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.
  119093. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119094. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119095. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119096. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119097. * * 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).
  119098. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119099. * * 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).
  119100. * * 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
  119101. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119102. * * 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
  119103. * * 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.
  119104. * * If `enclose` is false, a ring surface is one element.
  119105. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119106. * * 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
  119107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119110. * @param name defines the name of the mesh
  119111. * @param options defines the options used to create the mesh
  119112. * @param scene defines the hosting scene
  119113. * @returns the cylinder mesh
  119114. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119115. */
  119116. static CreateCylinder(name: string, options: {
  119117. height?: number;
  119118. diameterTop?: number;
  119119. diameterBottom?: number;
  119120. diameter?: number;
  119121. tessellation?: number;
  119122. subdivisions?: number;
  119123. arc?: number;
  119124. faceColors?: Color4[];
  119125. faceUV?: Vector4[];
  119126. updatable?: boolean;
  119127. hasRings?: boolean;
  119128. enclose?: boolean;
  119129. cap?: number;
  119130. sideOrientation?: number;
  119131. frontUVs?: Vector4;
  119132. backUVs?: Vector4;
  119133. }, scene?: Nullable<Scene>): Mesh;
  119134. /**
  119135. * Creates a torus mesh
  119136. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119137. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119138. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  119139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119142. * @param name defines the name of the mesh
  119143. * @param options defines the options used to create the mesh
  119144. * @param scene defines the hosting scene
  119145. * @returns the torus mesh
  119146. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  119147. */
  119148. static CreateTorus(name: string, options: {
  119149. diameter?: number;
  119150. thickness?: number;
  119151. tessellation?: number;
  119152. updatable?: boolean;
  119153. sideOrientation?: number;
  119154. frontUVs?: Vector4;
  119155. backUVs?: Vector4;
  119156. }, scene?: Nullable<Scene>): Mesh;
  119157. /**
  119158. * Creates a torus knot mesh
  119159. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119160. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119161. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119162. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119166. * @param name defines the name of the mesh
  119167. * @param options defines the options used to create the mesh
  119168. * @param scene defines the hosting scene
  119169. * @returns the torus knot mesh
  119170. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119171. */
  119172. static CreateTorusKnot(name: string, options: {
  119173. radius?: number;
  119174. tube?: number;
  119175. radialSegments?: number;
  119176. tubularSegments?: number;
  119177. p?: number;
  119178. q?: number;
  119179. updatable?: boolean;
  119180. sideOrientation?: number;
  119181. frontUVs?: Vector4;
  119182. backUVs?: Vector4;
  119183. }, scene?: Nullable<Scene>): Mesh;
  119184. /**
  119185. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119186. * * 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
  119187. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119188. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119189. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119190. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119191. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119192. * * 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
  119193. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119196. * @param name defines the name of the new line system
  119197. * @param options defines the options used to create the line system
  119198. * @param scene defines the hosting scene
  119199. * @returns a new line system mesh
  119200. */
  119201. static CreateLineSystem(name: string, options: {
  119202. lines: Vector3[][];
  119203. updatable?: boolean;
  119204. instance?: Nullable<LinesMesh>;
  119205. colors?: Nullable<Color4[][]>;
  119206. useVertexAlpha?: boolean;
  119207. }, scene: Nullable<Scene>): LinesMesh;
  119208. /**
  119209. * Creates a line mesh
  119210. * 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
  119211. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119212. * * The parameter `points` is an array successive Vector3
  119213. * * 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
  119214. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119215. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119216. * * When updating an instance, remember that only point positions can change, not the number of points
  119217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119219. * @param name defines the name of the new line system
  119220. * @param options defines the options used to create the line system
  119221. * @param scene defines the hosting scene
  119222. * @returns a new line mesh
  119223. */
  119224. static CreateLines(name: string, options: {
  119225. points: Vector3[];
  119226. updatable?: boolean;
  119227. instance?: Nullable<LinesMesh>;
  119228. colors?: Color4[];
  119229. useVertexAlpha?: boolean;
  119230. }, scene?: Nullable<Scene>): LinesMesh;
  119231. /**
  119232. * Creates a dashed line mesh
  119233. * * 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
  119234. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119235. * * The parameter `points` is an array successive Vector3
  119236. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119237. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119238. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119239. * * 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
  119240. * * When updating an instance, remember that only point positions can change, not the number of points
  119241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119242. * @param name defines the name of the mesh
  119243. * @param options defines the options used to create the mesh
  119244. * @param scene defines the hosting scene
  119245. * @returns the dashed line mesh
  119246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119247. */
  119248. static CreateDashedLines(name: string, options: {
  119249. points: Vector3[];
  119250. dashSize?: number;
  119251. gapSize?: number;
  119252. dashNb?: number;
  119253. updatable?: boolean;
  119254. instance?: LinesMesh;
  119255. }, scene?: Nullable<Scene>): LinesMesh;
  119256. /**
  119257. * 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.
  119258. * * 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.
  119259. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119260. * * 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.
  119261. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119262. * * 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
  119263. * * 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
  119264. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119269. * @param name defines the name of the mesh
  119270. * @param options defines the options used to create the mesh
  119271. * @param scene defines the hosting scene
  119272. * @returns the extruded shape mesh
  119273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119275. */
  119276. static ExtrudeShape(name: string, options: {
  119277. shape: Vector3[];
  119278. path: Vector3[];
  119279. scale?: number;
  119280. rotation?: number;
  119281. cap?: number;
  119282. updatable?: boolean;
  119283. sideOrientation?: number;
  119284. frontUVs?: Vector4;
  119285. backUVs?: Vector4;
  119286. instance?: Mesh;
  119287. invertUV?: boolean;
  119288. }, scene?: Nullable<Scene>): Mesh;
  119289. /**
  119290. * Creates an custom extruded shape mesh.
  119291. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119292. * * 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.
  119293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119294. * * 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
  119295. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119296. * * 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
  119297. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119298. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119299. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119300. * * 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
  119301. * * 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
  119302. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119307. * @param name defines the name of the mesh
  119308. * @param options defines the options used to create the mesh
  119309. * @param scene defines the hosting scene
  119310. * @returns the custom extruded shape mesh
  119311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119312. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119314. */
  119315. static ExtrudeShapeCustom(name: string, options: {
  119316. shape: Vector3[];
  119317. path: Vector3[];
  119318. scaleFunction?: any;
  119319. rotationFunction?: any;
  119320. ribbonCloseArray?: boolean;
  119321. ribbonClosePath?: boolean;
  119322. cap?: number;
  119323. updatable?: boolean;
  119324. sideOrientation?: number;
  119325. frontUVs?: Vector4;
  119326. backUVs?: Vector4;
  119327. instance?: Mesh;
  119328. invertUV?: boolean;
  119329. }, scene?: Nullable<Scene>): Mesh;
  119330. /**
  119331. * Creates lathe mesh.
  119332. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119333. * * 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
  119334. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119335. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119336. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119337. * * 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
  119338. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119339. * * 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
  119340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119344. * @param name defines the name of the mesh
  119345. * @param options defines the options used to create the mesh
  119346. * @param scene defines the hosting scene
  119347. * @returns the lathe mesh
  119348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119349. */
  119350. static CreateLathe(name: string, options: {
  119351. shape: Vector3[];
  119352. radius?: number;
  119353. tessellation?: number;
  119354. clip?: number;
  119355. arc?: number;
  119356. closed?: boolean;
  119357. updatable?: boolean;
  119358. sideOrientation?: number;
  119359. frontUVs?: Vector4;
  119360. backUVs?: Vector4;
  119361. cap?: number;
  119362. invertUV?: boolean;
  119363. }, scene?: Nullable<Scene>): Mesh;
  119364. /**
  119365. * Creates a tiled plane mesh
  119366. * * You can set a limited pattern arrangement with the tiles
  119367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119370. * @param name defines the name of the mesh
  119371. * @param options defines the options used to create the mesh
  119372. * @param scene defines the hosting scene
  119373. * @returns the plane mesh
  119374. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119375. */
  119376. static CreateTiledPlane(name: string, options: {
  119377. pattern?: number;
  119378. tileSize?: number;
  119379. tileWidth?: number;
  119380. tileHeight?: number;
  119381. size?: number;
  119382. width?: number;
  119383. height?: number;
  119384. alignHorizontal?: number;
  119385. alignVertical?: number;
  119386. sideOrientation?: number;
  119387. frontUVs?: Vector4;
  119388. backUVs?: Vector4;
  119389. updatable?: boolean;
  119390. }, scene?: Nullable<Scene>): Mesh;
  119391. /**
  119392. * Creates a plane mesh
  119393. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119394. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119395. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119399. * @param name defines the name of the mesh
  119400. * @param options defines the options used to create the mesh
  119401. * @param scene defines the hosting scene
  119402. * @returns the plane mesh
  119403. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119404. */
  119405. static CreatePlane(name: string, options: {
  119406. size?: number;
  119407. width?: number;
  119408. height?: number;
  119409. sideOrientation?: number;
  119410. frontUVs?: Vector4;
  119411. backUVs?: Vector4;
  119412. updatable?: boolean;
  119413. sourcePlane?: Plane;
  119414. }, scene?: Nullable<Scene>): Mesh;
  119415. /**
  119416. * Creates a ground mesh
  119417. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  119418. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  119419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119420. * @param name defines the name of the mesh
  119421. * @param options defines the options used to create the mesh
  119422. * @param scene defines the hosting scene
  119423. * @returns the ground mesh
  119424. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  119425. */
  119426. static CreateGround(name: string, options: {
  119427. width?: number;
  119428. height?: number;
  119429. subdivisions?: number;
  119430. subdivisionsX?: number;
  119431. subdivisionsY?: number;
  119432. updatable?: boolean;
  119433. }, scene?: Nullable<Scene>): Mesh;
  119434. /**
  119435. * Creates a tiled ground mesh
  119436. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  119437. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  119438. * * 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
  119439. * * 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
  119440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119441. * @param name defines the name of the mesh
  119442. * @param options defines the options used to create the mesh
  119443. * @param scene defines the hosting scene
  119444. * @returns the tiled ground mesh
  119445. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  119446. */
  119447. static CreateTiledGround(name: string, options: {
  119448. xmin: number;
  119449. zmin: number;
  119450. xmax: number;
  119451. zmax: number;
  119452. subdivisions?: {
  119453. w: number;
  119454. h: number;
  119455. };
  119456. precision?: {
  119457. w: number;
  119458. h: number;
  119459. };
  119460. updatable?: boolean;
  119461. }, scene?: Nullable<Scene>): Mesh;
  119462. /**
  119463. * Creates a ground mesh from a height map
  119464. * * The parameter `url` sets the URL of the height map image resource.
  119465. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  119466. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  119467. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  119468. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  119469. * * 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.
  119470. * * 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).
  119471. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119473. * @param name defines the name of the mesh
  119474. * @param url defines the url to the height map
  119475. * @param options defines the options used to create the mesh
  119476. * @param scene defines the hosting scene
  119477. * @returns the ground mesh
  119478. * @see https://doc.babylonjs.com/babylon101/height_map
  119479. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  119480. */
  119481. static CreateGroundFromHeightMap(name: string, url: string, options: {
  119482. width?: number;
  119483. height?: number;
  119484. subdivisions?: number;
  119485. minHeight?: number;
  119486. maxHeight?: number;
  119487. colorFilter?: Color3;
  119488. alphaFilter?: number;
  119489. updatable?: boolean;
  119490. onReady?: (mesh: GroundMesh) => void;
  119491. }, scene?: Nullable<Scene>): GroundMesh;
  119492. /**
  119493. * Creates a polygon mesh
  119494. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119495. * * 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
  119496. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119499. * * Remember you can only change the shape positions, not their number when updating a polygon
  119500. * @param name defines the name of the mesh
  119501. * @param options defines the options used to create the mesh
  119502. * @param scene defines the hosting scene
  119503. * @param earcutInjection can be used to inject your own earcut reference
  119504. * @returns the polygon mesh
  119505. */
  119506. static CreatePolygon(name: string, options: {
  119507. shape: Vector3[];
  119508. holes?: Vector3[][];
  119509. depth?: number;
  119510. faceUV?: Vector4[];
  119511. faceColors?: Color4[];
  119512. updatable?: boolean;
  119513. sideOrientation?: number;
  119514. frontUVs?: Vector4;
  119515. backUVs?: Vector4;
  119516. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119517. /**
  119518. * Creates an extruded polygon mesh, with depth in the Y direction.
  119519. * * 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)
  119520. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119521. * @param name defines the name of the mesh
  119522. * @param options defines the options used to create the mesh
  119523. * @param scene defines the hosting scene
  119524. * @param earcutInjection can be used to inject your own earcut reference
  119525. * @returns the polygon mesh
  119526. */
  119527. static ExtrudePolygon(name: string, options: {
  119528. shape: Vector3[];
  119529. holes?: Vector3[][];
  119530. depth?: number;
  119531. faceUV?: Vector4[];
  119532. faceColors?: Color4[];
  119533. updatable?: boolean;
  119534. sideOrientation?: number;
  119535. frontUVs?: Vector4;
  119536. backUVs?: Vector4;
  119537. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119538. /**
  119539. * Creates a tube mesh.
  119540. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119541. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119542. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119543. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119544. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119545. * * 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)
  119546. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119547. * * 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
  119548. * * 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
  119549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119553. * @param name defines the name of the mesh
  119554. * @param options defines the options used to create the mesh
  119555. * @param scene defines the hosting scene
  119556. * @returns the tube mesh
  119557. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119558. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119559. */
  119560. static CreateTube(name: string, options: {
  119561. path: Vector3[];
  119562. radius?: number;
  119563. tessellation?: number;
  119564. radiusFunction?: {
  119565. (i: number, distance: number): number;
  119566. };
  119567. cap?: number;
  119568. arc?: number;
  119569. updatable?: boolean;
  119570. sideOrientation?: number;
  119571. frontUVs?: Vector4;
  119572. backUVs?: Vector4;
  119573. instance?: Mesh;
  119574. invertUV?: boolean;
  119575. }, scene?: Nullable<Scene>): Mesh;
  119576. /**
  119577. * Creates a polyhedron mesh
  119578. * * 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
  119579. * * The parameter `size` (positive float, default 1) sets the polygon size
  119580. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119581. * * 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`
  119582. * * 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
  119583. * * 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)`)
  119584. * * 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
  119585. * * 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
  119586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119589. * @param name defines the name of the mesh
  119590. * @param options defines the options used to create the mesh
  119591. * @param scene defines the hosting scene
  119592. * @returns the polyhedron mesh
  119593. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119594. */
  119595. static CreatePolyhedron(name: string, options: {
  119596. type?: number;
  119597. size?: number;
  119598. sizeX?: number;
  119599. sizeY?: number;
  119600. sizeZ?: number;
  119601. custom?: any;
  119602. faceUV?: Vector4[];
  119603. faceColors?: Color4[];
  119604. flat?: boolean;
  119605. updatable?: boolean;
  119606. sideOrientation?: number;
  119607. frontUVs?: Vector4;
  119608. backUVs?: Vector4;
  119609. }, scene?: Nullable<Scene>): Mesh;
  119610. /**
  119611. * Creates a decal mesh.
  119612. * 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
  119613. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119614. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119615. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119616. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119617. * @param name defines the name of the mesh
  119618. * @param sourceMesh defines the mesh where the decal must be applied
  119619. * @param options defines the options used to create the mesh
  119620. * @param scene defines the hosting scene
  119621. * @returns the decal mesh
  119622. * @see https://doc.babylonjs.com/how_to/decals
  119623. */
  119624. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119625. position?: Vector3;
  119626. normal?: Vector3;
  119627. size?: Vector3;
  119628. angle?: number;
  119629. }): Mesh;
  119630. }
  119631. }
  119632. declare module BABYLON {
  119633. /**
  119634. * A simplifier interface for future simplification implementations
  119635. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119636. */
  119637. export interface ISimplifier {
  119638. /**
  119639. * Simplification of a given mesh according to the given settings.
  119640. * Since this requires computation, it is assumed that the function runs async.
  119641. * @param settings The settings of the simplification, including quality and distance
  119642. * @param successCallback A callback that will be called after the mesh was simplified.
  119643. * @param errorCallback in case of an error, this callback will be called. optional.
  119644. */
  119645. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119646. }
  119647. /**
  119648. * Expected simplification settings.
  119649. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119650. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119651. */
  119652. export interface ISimplificationSettings {
  119653. /**
  119654. * Gets or sets the expected quality
  119655. */
  119656. quality: number;
  119657. /**
  119658. * Gets or sets the distance when this optimized version should be used
  119659. */
  119660. distance: number;
  119661. /**
  119662. * Gets an already optimized mesh
  119663. */
  119664. optimizeMesh?: boolean;
  119665. }
  119666. /**
  119667. * Class used to specify simplification options
  119668. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119669. */
  119670. export class SimplificationSettings implements ISimplificationSettings {
  119671. /** expected quality */
  119672. quality: number;
  119673. /** distance when this optimized version should be used */
  119674. distance: number;
  119675. /** already optimized mesh */
  119676. optimizeMesh?: boolean | undefined;
  119677. /**
  119678. * Creates a SimplificationSettings
  119679. * @param quality expected quality
  119680. * @param distance distance when this optimized version should be used
  119681. * @param optimizeMesh already optimized mesh
  119682. */
  119683. constructor(
  119684. /** expected quality */
  119685. quality: number,
  119686. /** distance when this optimized version should be used */
  119687. distance: number,
  119688. /** already optimized mesh */
  119689. optimizeMesh?: boolean | undefined);
  119690. }
  119691. /**
  119692. * Interface used to define a simplification task
  119693. */
  119694. export interface ISimplificationTask {
  119695. /**
  119696. * Array of settings
  119697. */
  119698. settings: Array<ISimplificationSettings>;
  119699. /**
  119700. * Simplification type
  119701. */
  119702. simplificationType: SimplificationType;
  119703. /**
  119704. * Mesh to simplify
  119705. */
  119706. mesh: Mesh;
  119707. /**
  119708. * Callback called on success
  119709. */
  119710. successCallback?: () => void;
  119711. /**
  119712. * Defines if parallel processing can be used
  119713. */
  119714. parallelProcessing: boolean;
  119715. }
  119716. /**
  119717. * Queue used to order the simplification tasks
  119718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119719. */
  119720. export class SimplificationQueue {
  119721. private _simplificationArray;
  119722. /**
  119723. * Gets a boolean indicating that the process is still running
  119724. */
  119725. running: boolean;
  119726. /**
  119727. * Creates a new queue
  119728. */
  119729. constructor();
  119730. /**
  119731. * Adds a new simplification task
  119732. * @param task defines a task to add
  119733. */
  119734. addTask(task: ISimplificationTask): void;
  119735. /**
  119736. * Execute next task
  119737. */
  119738. executeNext(): void;
  119739. /**
  119740. * Execute a simplification task
  119741. * @param task defines the task to run
  119742. */
  119743. runSimplification(task: ISimplificationTask): void;
  119744. private getSimplifier;
  119745. }
  119746. /**
  119747. * The implemented types of simplification
  119748. * At the moment only Quadratic Error Decimation is implemented
  119749. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119750. */
  119751. export enum SimplificationType {
  119752. /** Quadratic error decimation */
  119753. QUADRATIC = 0
  119754. }
  119755. }
  119756. declare module BABYLON {
  119757. interface Scene {
  119758. /** @hidden (Backing field) */
  119759. _simplificationQueue: SimplificationQueue;
  119760. /**
  119761. * Gets or sets the simplification queue attached to the scene
  119762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119763. */
  119764. simplificationQueue: SimplificationQueue;
  119765. }
  119766. interface Mesh {
  119767. /**
  119768. * Simplify the mesh according to the given array of settings.
  119769. * Function will return immediately and will simplify async
  119770. * @param settings a collection of simplification settings
  119771. * @param parallelProcessing should all levels calculate parallel or one after the other
  119772. * @param simplificationType the type of simplification to run
  119773. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  119774. * @returns the current mesh
  119775. */
  119776. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  119777. }
  119778. /**
  119779. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  119780. * created in a scene
  119781. */
  119782. export class SimplicationQueueSceneComponent implements ISceneComponent {
  119783. /**
  119784. * The component name helpfull to identify the component in the list of scene components.
  119785. */
  119786. readonly name: string;
  119787. /**
  119788. * The scene the component belongs to.
  119789. */
  119790. scene: Scene;
  119791. /**
  119792. * Creates a new instance of the component for the given scene
  119793. * @param scene Defines the scene to register the component in
  119794. */
  119795. constructor(scene: Scene);
  119796. /**
  119797. * Registers the component in a given scene
  119798. */
  119799. register(): void;
  119800. /**
  119801. * Rebuilds the elements related to this component in case of
  119802. * context lost for instance.
  119803. */
  119804. rebuild(): void;
  119805. /**
  119806. * Disposes the component and the associated ressources
  119807. */
  119808. dispose(): void;
  119809. private _beforeCameraUpdate;
  119810. }
  119811. }
  119812. declare module BABYLON {
  119813. /**
  119814. * Navigation plugin interface to add navigation constrained by a navigation mesh
  119815. */
  119816. export interface INavigationEnginePlugin {
  119817. /**
  119818. * plugin name
  119819. */
  119820. name: string;
  119821. /**
  119822. * Creates a navigation mesh
  119823. * @param meshes array of all the geometry used to compute the navigatio mesh
  119824. * @param parameters bunch of parameters used to filter geometry
  119825. */
  119826. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119827. /**
  119828. * Create a navigation mesh debug mesh
  119829. * @param scene is where the mesh will be added
  119830. * @returns debug display mesh
  119831. */
  119832. createDebugNavMesh(scene: Scene): Mesh;
  119833. /**
  119834. * Get a navigation mesh constrained position, closest to the parameter position
  119835. * @param position world position
  119836. * @returns the closest point to position constrained by the navigation mesh
  119837. */
  119838. getClosestPoint(position: Vector3): Vector3;
  119839. /**
  119840. * Get a navigation mesh constrained position, within a particular radius
  119841. * @param position world position
  119842. * @param maxRadius the maximum distance to the constrained world position
  119843. * @returns the closest point to position constrained by the navigation mesh
  119844. */
  119845. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119846. /**
  119847. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119848. * @param start world position
  119849. * @param end world position
  119850. * @returns array containing world position composing the path
  119851. */
  119852. computePath(start: Vector3, end: Vector3): Vector3[];
  119853. /**
  119854. * If this plugin is supported
  119855. * @returns true if plugin is supported
  119856. */
  119857. isSupported(): boolean;
  119858. /**
  119859. * Create a new Crowd so you can add agents
  119860. * @param maxAgents the maximum agent count in the crowd
  119861. * @param maxAgentRadius the maximum radius an agent can have
  119862. * @param scene to attach the crowd to
  119863. * @returns the crowd you can add agents to
  119864. */
  119865. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119866. /**
  119867. * Release all resources
  119868. */
  119869. dispose(): void;
  119870. }
  119871. /**
  119872. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  119873. */
  119874. export interface ICrowd {
  119875. /**
  119876. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119877. * You can attach anything to that node. The node position is updated in the scene update tick.
  119878. * @param pos world position that will be constrained by the navigation mesh
  119879. * @param parameters agent parameters
  119880. * @param transform hooked to the agent that will be update by the scene
  119881. * @returns agent index
  119882. */
  119883. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119884. /**
  119885. * Returns the agent position in world space
  119886. * @param index agent index returned by addAgent
  119887. * @returns world space position
  119888. */
  119889. getAgentPosition(index: number): Vector3;
  119890. /**
  119891. * Gets the agent velocity in world space
  119892. * @param index agent index returned by addAgent
  119893. * @returns world space velocity
  119894. */
  119895. getAgentVelocity(index: number): Vector3;
  119896. /**
  119897. * remove a particular agent previously created
  119898. * @param index agent index returned by addAgent
  119899. */
  119900. removeAgent(index: number): void;
  119901. /**
  119902. * get the list of all agents attached to this crowd
  119903. * @returns list of agent indices
  119904. */
  119905. getAgents(): number[];
  119906. /**
  119907. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119908. * @param deltaTime in seconds
  119909. */
  119910. update(deltaTime: number): void;
  119911. /**
  119912. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119913. * @param index agent index returned by addAgent
  119914. * @param destination targeted world position
  119915. */
  119916. agentGoto(index: number, destination: Vector3): void;
  119917. /**
  119918. * Release all resources
  119919. */
  119920. dispose(): void;
  119921. }
  119922. /**
  119923. * Configures an agent
  119924. */
  119925. export interface IAgentParameters {
  119926. /**
  119927. * Agent radius. [Limit: >= 0]
  119928. */
  119929. radius: number;
  119930. /**
  119931. * Agent height. [Limit: > 0]
  119932. */
  119933. height: number;
  119934. /**
  119935. * Maximum allowed acceleration. [Limit: >= 0]
  119936. */
  119937. maxAcceleration: number;
  119938. /**
  119939. * Maximum allowed speed. [Limit: >= 0]
  119940. */
  119941. maxSpeed: number;
  119942. /**
  119943. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  119944. */
  119945. collisionQueryRange: number;
  119946. /**
  119947. * The path visibility optimization range. [Limit: > 0]
  119948. */
  119949. pathOptimizationRange: number;
  119950. /**
  119951. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  119952. */
  119953. separationWeight: number;
  119954. }
  119955. /**
  119956. * Configures the navigation mesh creation
  119957. */
  119958. export interface INavMeshParameters {
  119959. /**
  119960. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  119961. */
  119962. cs: number;
  119963. /**
  119964. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  119965. */
  119966. ch: number;
  119967. /**
  119968. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  119969. */
  119970. walkableSlopeAngle: number;
  119971. /**
  119972. * Minimum floor to 'ceiling' height that will still allow the floor area to
  119973. * be considered walkable. [Limit: >= 3] [Units: vx]
  119974. */
  119975. walkableHeight: number;
  119976. /**
  119977. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  119978. */
  119979. walkableClimb: number;
  119980. /**
  119981. * The distance to erode/shrink the walkable area of the heightfield away from
  119982. * obstructions. [Limit: >=0] [Units: vx]
  119983. */
  119984. walkableRadius: number;
  119985. /**
  119986. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  119987. */
  119988. maxEdgeLen: number;
  119989. /**
  119990. * The maximum distance a simplfied contour's border edges should deviate
  119991. * the original raw contour. [Limit: >=0] [Units: vx]
  119992. */
  119993. maxSimplificationError: number;
  119994. /**
  119995. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  119996. */
  119997. minRegionArea: number;
  119998. /**
  119999. * Any regions with a span count smaller than this value will, if possible,
  120000. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120001. */
  120002. mergeRegionArea: number;
  120003. /**
  120004. * The maximum number of vertices allowed for polygons generated during the
  120005. * contour to polygon conversion process. [Limit: >= 3]
  120006. */
  120007. maxVertsPerPoly: number;
  120008. /**
  120009. * Sets the sampling distance to use when generating the detail mesh.
  120010. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120011. */
  120012. detailSampleDist: number;
  120013. /**
  120014. * The maximum distance the detail mesh surface should deviate from heightfield
  120015. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120016. */
  120017. detailSampleMaxError: number;
  120018. }
  120019. }
  120020. declare module BABYLON {
  120021. /**
  120022. * RecastJS navigation plugin
  120023. */
  120024. export class RecastJSPlugin implements INavigationEnginePlugin {
  120025. /**
  120026. * Reference to the Recast library
  120027. */
  120028. bjsRECAST: any;
  120029. /**
  120030. * plugin name
  120031. */
  120032. name: string;
  120033. /**
  120034. * the first navmesh created. We might extend this to support multiple navmeshes
  120035. */
  120036. navMesh: any;
  120037. /**
  120038. * Initializes the recastJS plugin
  120039. * @param recastInjection can be used to inject your own recast reference
  120040. */
  120041. constructor(recastInjection?: any);
  120042. /**
  120043. * Creates a navigation mesh
  120044. * @param meshes array of all the geometry used to compute the navigatio mesh
  120045. * @param parameters bunch of parameters used to filter geometry
  120046. */
  120047. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120048. /**
  120049. * Create a navigation mesh debug mesh
  120050. * @param scene is where the mesh will be added
  120051. * @returns debug display mesh
  120052. */
  120053. createDebugNavMesh(scene: Scene): Mesh;
  120054. /**
  120055. * Get a navigation mesh constrained position, closest to the parameter position
  120056. * @param position world position
  120057. * @returns the closest point to position constrained by the navigation mesh
  120058. */
  120059. getClosestPoint(position: Vector3): Vector3;
  120060. /**
  120061. * Get a navigation mesh constrained position, within a particular radius
  120062. * @param position world position
  120063. * @param maxRadius the maximum distance to the constrained world position
  120064. * @returns the closest point to position constrained by the navigation mesh
  120065. */
  120066. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120067. /**
  120068. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120069. * @param start world position
  120070. * @param end world position
  120071. * @returns array containing world position composing the path
  120072. */
  120073. computePath(start: Vector3, end: Vector3): Vector3[];
  120074. /**
  120075. * Create a new Crowd so you can add agents
  120076. * @param maxAgents the maximum agent count in the crowd
  120077. * @param maxAgentRadius the maximum radius an agent can have
  120078. * @param scene to attach the crowd to
  120079. * @returns the crowd you can add agents to
  120080. */
  120081. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120082. /**
  120083. * Disposes
  120084. */
  120085. dispose(): void;
  120086. /**
  120087. * If this plugin is supported
  120088. * @returns true if plugin is supported
  120089. */
  120090. isSupported(): boolean;
  120091. }
  120092. /**
  120093. * Recast detour crowd implementation
  120094. */
  120095. export class RecastJSCrowd implements ICrowd {
  120096. /**
  120097. * Recast/detour plugin
  120098. */
  120099. bjsRECASTPlugin: RecastJSPlugin;
  120100. /**
  120101. * Link to the detour crowd
  120102. */
  120103. recastCrowd: any;
  120104. /**
  120105. * One transform per agent
  120106. */
  120107. transforms: TransformNode[];
  120108. /**
  120109. * All agents created
  120110. */
  120111. agents: number[];
  120112. /**
  120113. * Link to the scene is kept to unregister the crowd from the scene
  120114. */
  120115. private _scene;
  120116. /**
  120117. * Observer for crowd updates
  120118. */
  120119. private _onBeforeAnimationsObserver;
  120120. /**
  120121. * Constructor
  120122. * @param plugin recastJS plugin
  120123. * @param maxAgents the maximum agent count in the crowd
  120124. * @param maxAgentRadius the maximum radius an agent can have
  120125. * @param scene to attach the crowd to
  120126. * @returns the crowd you can add agents to
  120127. */
  120128. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  120129. /**
  120130. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120131. * You can attach anything to that node. The node position is updated in the scene update tick.
  120132. * @param pos world position that will be constrained by the navigation mesh
  120133. * @param parameters agent parameters
  120134. * @param transform hooked to the agent that will be update by the scene
  120135. * @returns agent index
  120136. */
  120137. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120138. /**
  120139. * Returns the agent position in world space
  120140. * @param index agent index returned by addAgent
  120141. * @returns world space position
  120142. */
  120143. getAgentPosition(index: number): Vector3;
  120144. /**
  120145. * Returns the agent velocity in world space
  120146. * @param index agent index returned by addAgent
  120147. * @returns world space velocity
  120148. */
  120149. getAgentVelocity(index: number): Vector3;
  120150. /**
  120151. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120152. * @param index agent index returned by addAgent
  120153. * @param destination targeted world position
  120154. */
  120155. agentGoto(index: number, destination: Vector3): void;
  120156. /**
  120157. * remove a particular agent previously created
  120158. * @param index agent index returned by addAgent
  120159. */
  120160. removeAgent(index: number): void;
  120161. /**
  120162. * get the list of all agents attached to this crowd
  120163. * @returns list of agent indices
  120164. */
  120165. getAgents(): number[];
  120166. /**
  120167. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120168. * @param deltaTime in seconds
  120169. */
  120170. update(deltaTime: number): void;
  120171. /**
  120172. * Release all resources
  120173. */
  120174. dispose(): void;
  120175. }
  120176. }
  120177. declare module BABYLON {
  120178. /**
  120179. * Class used to enable access to IndexedDB
  120180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120181. */
  120182. export class Database implements IOfflineProvider {
  120183. private _callbackManifestChecked;
  120184. private _currentSceneUrl;
  120185. private _db;
  120186. private _enableSceneOffline;
  120187. private _enableTexturesOffline;
  120188. private _manifestVersionFound;
  120189. private _mustUpdateRessources;
  120190. private _hasReachedQuota;
  120191. private _isSupported;
  120192. private _idbFactory;
  120193. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  120194. private static IsUASupportingBlobStorage;
  120195. /**
  120196. * Gets a boolean indicating if Database storate is enabled (off by default)
  120197. */
  120198. static IDBStorageEnabled: boolean;
  120199. /**
  120200. * Gets a boolean indicating if scene must be saved in the database
  120201. */
  120202. readonly enableSceneOffline: boolean;
  120203. /**
  120204. * Gets a boolean indicating if textures must be saved in the database
  120205. */
  120206. readonly enableTexturesOffline: boolean;
  120207. /**
  120208. * Creates a new Database
  120209. * @param urlToScene defines the url to load the scene
  120210. * @param callbackManifestChecked defines the callback to use when manifest is checked
  120211. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  120212. */
  120213. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  120214. private static _ParseURL;
  120215. private static _ReturnFullUrlLocation;
  120216. private _checkManifestFile;
  120217. /**
  120218. * Open the database and make it available
  120219. * @param successCallback defines the callback to call on success
  120220. * @param errorCallback defines the callback to call on error
  120221. */
  120222. open(successCallback: () => void, errorCallback: () => void): void;
  120223. /**
  120224. * Loads an image from the database
  120225. * @param url defines the url to load from
  120226. * @param image defines the target DOM image
  120227. */
  120228. loadImage(url: string, image: HTMLImageElement): void;
  120229. private _loadImageFromDBAsync;
  120230. private _saveImageIntoDBAsync;
  120231. private _checkVersionFromDB;
  120232. private _loadVersionFromDBAsync;
  120233. private _saveVersionIntoDBAsync;
  120234. /**
  120235. * Loads a file from database
  120236. * @param url defines the URL to load from
  120237. * @param sceneLoaded defines a callback to call on success
  120238. * @param progressCallBack defines a callback to call when progress changed
  120239. * @param errorCallback defines a callback to call on error
  120240. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  120241. */
  120242. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  120243. private _loadFileAsync;
  120244. private _saveFileAsync;
  120245. /**
  120246. * Validates if xhr data is correct
  120247. * @param xhr defines the request to validate
  120248. * @param dataType defines the expected data type
  120249. * @returns true if data is correct
  120250. */
  120251. private static _ValidateXHRData;
  120252. }
  120253. }
  120254. declare module BABYLON {
  120255. /** @hidden */
  120256. export var gpuUpdateParticlesPixelShader: {
  120257. name: string;
  120258. shader: string;
  120259. };
  120260. }
  120261. declare module BABYLON {
  120262. /** @hidden */
  120263. export var gpuUpdateParticlesVertexShader: {
  120264. name: string;
  120265. shader: string;
  120266. };
  120267. }
  120268. declare module BABYLON {
  120269. /** @hidden */
  120270. export var clipPlaneFragmentDeclaration2: {
  120271. name: string;
  120272. shader: string;
  120273. };
  120274. }
  120275. declare module BABYLON {
  120276. /** @hidden */
  120277. export var gpuRenderParticlesPixelShader: {
  120278. name: string;
  120279. shader: string;
  120280. };
  120281. }
  120282. declare module BABYLON {
  120283. /** @hidden */
  120284. export var clipPlaneVertexDeclaration2: {
  120285. name: string;
  120286. shader: string;
  120287. };
  120288. }
  120289. declare module BABYLON {
  120290. /** @hidden */
  120291. export var gpuRenderParticlesVertexShader: {
  120292. name: string;
  120293. shader: string;
  120294. };
  120295. }
  120296. declare module BABYLON {
  120297. /**
  120298. * This represents a GPU particle system in Babylon
  120299. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  120300. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  120301. */
  120302. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  120303. /**
  120304. * The layer mask we are rendering the particles through.
  120305. */
  120306. layerMask: number;
  120307. private _capacity;
  120308. private _activeCount;
  120309. private _currentActiveCount;
  120310. private _accumulatedCount;
  120311. private _renderEffect;
  120312. private _updateEffect;
  120313. private _buffer0;
  120314. private _buffer1;
  120315. private _spriteBuffer;
  120316. private _updateVAO;
  120317. private _renderVAO;
  120318. private _targetIndex;
  120319. private _sourceBuffer;
  120320. private _targetBuffer;
  120321. private _engine;
  120322. private _currentRenderId;
  120323. private _started;
  120324. private _stopped;
  120325. private _timeDelta;
  120326. private _randomTexture;
  120327. private _randomTexture2;
  120328. private _attributesStrideSize;
  120329. private _updateEffectOptions;
  120330. private _randomTextureSize;
  120331. private _actualFrame;
  120332. private readonly _rawTextureWidth;
  120333. /**
  120334. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  120335. */
  120336. static readonly IsSupported: boolean;
  120337. /**
  120338. * An event triggered when the system is disposed.
  120339. */
  120340. onDisposeObservable: Observable<GPUParticleSystem>;
  120341. /**
  120342. * Gets the maximum number of particles active at the same time.
  120343. * @returns The max number of active particles.
  120344. */
  120345. getCapacity(): number;
  120346. /**
  120347. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  120348. * to override the particles.
  120349. */
  120350. forceDepthWrite: boolean;
  120351. /**
  120352. * Gets or set the number of active particles
  120353. */
  120354. activeParticleCount: number;
  120355. private _preWarmDone;
  120356. /**
  120357. * Is this system ready to be used/rendered
  120358. * @return true if the system is ready
  120359. */
  120360. isReady(): boolean;
  120361. /**
  120362. * Gets if the system has been started. (Note: this will still be true after stop is called)
  120363. * @returns True if it has been started, otherwise false.
  120364. */
  120365. isStarted(): boolean;
  120366. /**
  120367. * Starts the particle system and begins to emit
  120368. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  120369. */
  120370. start(delay?: number): void;
  120371. /**
  120372. * Stops the particle system.
  120373. */
  120374. stop(): void;
  120375. /**
  120376. * Remove all active particles
  120377. */
  120378. reset(): void;
  120379. /**
  120380. * Returns the string "GPUParticleSystem"
  120381. * @returns a string containing the class name
  120382. */
  120383. getClassName(): string;
  120384. private _colorGradientsTexture;
  120385. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  120386. /**
  120387. * Adds a new color gradient
  120388. * @param gradient defines the gradient to use (between 0 and 1)
  120389. * @param color1 defines the color to affect to the specified gradient
  120390. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  120391. * @returns the current particle system
  120392. */
  120393. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  120394. /**
  120395. * Remove a specific color gradient
  120396. * @param gradient defines the gradient to remove
  120397. * @returns the current particle system
  120398. */
  120399. removeColorGradient(gradient: number): GPUParticleSystem;
  120400. private _angularSpeedGradientsTexture;
  120401. private _sizeGradientsTexture;
  120402. private _velocityGradientsTexture;
  120403. private _limitVelocityGradientsTexture;
  120404. private _dragGradientsTexture;
  120405. private _addFactorGradient;
  120406. /**
  120407. * Adds a new size gradient
  120408. * @param gradient defines the gradient to use (between 0 and 1)
  120409. * @param factor defines the size factor to affect to the specified gradient
  120410. * @returns the current particle system
  120411. */
  120412. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  120413. /**
  120414. * Remove a specific size gradient
  120415. * @param gradient defines the gradient to remove
  120416. * @returns the current particle system
  120417. */
  120418. removeSizeGradient(gradient: number): GPUParticleSystem;
  120419. /**
  120420. * Adds a new angular speed gradient
  120421. * @param gradient defines the gradient to use (between 0 and 1)
  120422. * @param factor defines the angular speed to affect to the specified gradient
  120423. * @returns the current particle system
  120424. */
  120425. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  120426. /**
  120427. * Remove a specific angular speed gradient
  120428. * @param gradient defines the gradient to remove
  120429. * @returns the current particle system
  120430. */
  120431. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  120432. /**
  120433. * Adds a new velocity gradient
  120434. * @param gradient defines the gradient to use (between 0 and 1)
  120435. * @param factor defines the velocity to affect to the specified gradient
  120436. * @returns the current particle system
  120437. */
  120438. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120439. /**
  120440. * Remove a specific velocity gradient
  120441. * @param gradient defines the gradient to remove
  120442. * @returns the current particle system
  120443. */
  120444. removeVelocityGradient(gradient: number): GPUParticleSystem;
  120445. /**
  120446. * Adds a new limit velocity gradient
  120447. * @param gradient defines the gradient to use (between 0 and 1)
  120448. * @param factor defines the limit velocity value to affect to the specified gradient
  120449. * @returns the current particle system
  120450. */
  120451. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  120452. /**
  120453. * Remove a specific limit velocity gradient
  120454. * @param gradient defines the gradient to remove
  120455. * @returns the current particle system
  120456. */
  120457. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  120458. /**
  120459. * Adds a new drag gradient
  120460. * @param gradient defines the gradient to use (between 0 and 1)
  120461. * @param factor defines the drag value to affect to the specified gradient
  120462. * @returns the current particle system
  120463. */
  120464. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  120465. /**
  120466. * Remove a specific drag gradient
  120467. * @param gradient defines the gradient to remove
  120468. * @returns the current particle system
  120469. */
  120470. removeDragGradient(gradient: number): GPUParticleSystem;
  120471. /**
  120472. * Not supported by GPUParticleSystem
  120473. * @param gradient defines the gradient to use (between 0 and 1)
  120474. * @param factor defines the emit rate value to affect to the specified gradient
  120475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120476. * @returns the current particle system
  120477. */
  120478. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120479. /**
  120480. * Not supported by GPUParticleSystem
  120481. * @param gradient defines the gradient to remove
  120482. * @returns the current particle system
  120483. */
  120484. removeEmitRateGradient(gradient: number): IParticleSystem;
  120485. /**
  120486. * Not supported by GPUParticleSystem
  120487. * @param gradient defines the gradient to use (between 0 and 1)
  120488. * @param factor defines the start size value to affect to the specified gradient
  120489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120490. * @returns the current particle system
  120491. */
  120492. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120493. /**
  120494. * Not supported by GPUParticleSystem
  120495. * @param gradient defines the gradient to remove
  120496. * @returns the current particle system
  120497. */
  120498. removeStartSizeGradient(gradient: number): IParticleSystem;
  120499. /**
  120500. * Not supported by GPUParticleSystem
  120501. * @param gradient defines the gradient to use (between 0 and 1)
  120502. * @param min defines the color remap minimal range
  120503. * @param max defines the color remap maximal range
  120504. * @returns the current particle system
  120505. */
  120506. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120507. /**
  120508. * Not supported by GPUParticleSystem
  120509. * @param gradient defines the gradient to remove
  120510. * @returns the current particle system
  120511. */
  120512. removeColorRemapGradient(): IParticleSystem;
  120513. /**
  120514. * Not supported by GPUParticleSystem
  120515. * @param gradient defines the gradient to use (between 0 and 1)
  120516. * @param min defines the alpha remap minimal range
  120517. * @param max defines the alpha remap maximal range
  120518. * @returns the current particle system
  120519. */
  120520. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  120521. /**
  120522. * Not supported by GPUParticleSystem
  120523. * @param gradient defines the gradient to remove
  120524. * @returns the current particle system
  120525. */
  120526. removeAlphaRemapGradient(): IParticleSystem;
  120527. /**
  120528. * Not supported by GPUParticleSystem
  120529. * @param gradient defines the gradient to use (between 0 and 1)
  120530. * @param color defines the color to affect to the specified gradient
  120531. * @returns the current particle system
  120532. */
  120533. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  120534. /**
  120535. * Not supported by GPUParticleSystem
  120536. * @param gradient defines the gradient to remove
  120537. * @returns the current particle system
  120538. */
  120539. removeRampGradient(): IParticleSystem;
  120540. /**
  120541. * Not supported by GPUParticleSystem
  120542. * @returns the list of ramp gradients
  120543. */
  120544. getRampGradients(): Nullable<Array<Color3Gradient>>;
  120545. /**
  120546. * Not supported by GPUParticleSystem
  120547. * Gets or sets a boolean indicating that ramp gradients must be used
  120548. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  120549. */
  120550. useRampGradients: boolean;
  120551. /**
  120552. * Not supported by GPUParticleSystem
  120553. * @param gradient defines the gradient to use (between 0 and 1)
  120554. * @param factor defines the life time factor to affect to the specified gradient
  120555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  120556. * @returns the current particle system
  120557. */
  120558. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  120559. /**
  120560. * Not supported by GPUParticleSystem
  120561. * @param gradient defines the gradient to remove
  120562. * @returns the current particle system
  120563. */
  120564. removeLifeTimeGradient(gradient: number): IParticleSystem;
  120565. /**
  120566. * Instantiates a GPU particle system.
  120567. * 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.
  120568. * @param name The name of the particle system
  120569. * @param options The options used to create the system
  120570. * @param scene The scene the particle system belongs to
  120571. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  120572. */
  120573. constructor(name: string, options: Partial<{
  120574. capacity: number;
  120575. randomTextureSize: number;
  120576. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  120577. protected _reset(): void;
  120578. private _createUpdateVAO;
  120579. private _createRenderVAO;
  120580. private _initialize;
  120581. /** @hidden */
  120582. _recreateUpdateEffect(): void;
  120583. /** @hidden */
  120584. _recreateRenderEffect(): void;
  120585. /**
  120586. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  120587. * @param preWarm defines if we are in the pre-warmimg phase
  120588. */
  120589. animate(preWarm?: boolean): void;
  120590. private _createFactorGradientTexture;
  120591. private _createSizeGradientTexture;
  120592. private _createAngularSpeedGradientTexture;
  120593. private _createVelocityGradientTexture;
  120594. private _createLimitVelocityGradientTexture;
  120595. private _createDragGradientTexture;
  120596. private _createColorGradientTexture;
  120597. /**
  120598. * Renders the particle system in its current state
  120599. * @param preWarm defines if the system should only update the particles but not render them
  120600. * @returns the current number of particles
  120601. */
  120602. render(preWarm?: boolean): number;
  120603. /**
  120604. * Rebuilds the particle system
  120605. */
  120606. rebuild(): void;
  120607. private _releaseBuffers;
  120608. private _releaseVAOs;
  120609. /**
  120610. * Disposes the particle system and free the associated resources
  120611. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120612. */
  120613. dispose(disposeTexture?: boolean): void;
  120614. /**
  120615. * Clones the particle system.
  120616. * @param name The name of the cloned object
  120617. * @param newEmitter The new emitter to use
  120618. * @returns the cloned particle system
  120619. */
  120620. clone(name: string, newEmitter: any): GPUParticleSystem;
  120621. /**
  120622. * Serializes the particle system to a JSON object.
  120623. * @returns the JSON object
  120624. */
  120625. serialize(): any;
  120626. /**
  120627. * Parses a JSON object to create a GPU particle system.
  120628. * @param parsedParticleSystem The JSON object to parse
  120629. * @param scene The scene to create the particle system in
  120630. * @param rootUrl The root url to use to load external dependencies like texture
  120631. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120632. * @returns the parsed GPU particle system
  120633. */
  120634. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120635. }
  120636. }
  120637. declare module BABYLON {
  120638. /**
  120639. * Represents a set of particle systems working together to create a specific effect
  120640. */
  120641. export class ParticleSystemSet implements IDisposable {
  120642. private _emitterCreationOptions;
  120643. private _emitterNode;
  120644. /**
  120645. * Gets the particle system list
  120646. */
  120647. systems: IParticleSystem[];
  120648. /**
  120649. * Gets the emitter node used with this set
  120650. */
  120651. readonly emitterNode: Nullable<TransformNode>;
  120652. /**
  120653. * Creates a new emitter mesh as a sphere
  120654. * @param options defines the options used to create the sphere
  120655. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120656. * @param scene defines the hosting scene
  120657. */
  120658. setEmitterAsSphere(options: {
  120659. diameter: number;
  120660. segments: number;
  120661. color: Color3;
  120662. }, renderingGroupId: number, scene: Scene): void;
  120663. /**
  120664. * Starts all particle systems of the set
  120665. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120666. */
  120667. start(emitter?: AbstractMesh): void;
  120668. /**
  120669. * Release all associated resources
  120670. */
  120671. dispose(): void;
  120672. /**
  120673. * Serialize the set into a JSON compatible object
  120674. * @returns a JSON compatible representation of the set
  120675. */
  120676. serialize(): any;
  120677. /**
  120678. * Parse a new ParticleSystemSet from a serialized source
  120679. * @param data defines a JSON compatible representation of the set
  120680. * @param scene defines the hosting scene
  120681. * @param gpu defines if we want GPU particles or CPU particles
  120682. * @returns a new ParticleSystemSet
  120683. */
  120684. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120685. }
  120686. }
  120687. declare module BABYLON {
  120688. /**
  120689. * This class is made for on one-liner static method to help creating particle system set.
  120690. */
  120691. export class ParticleHelper {
  120692. /**
  120693. * Gets or sets base Assets URL
  120694. */
  120695. static BaseAssetsUrl: string;
  120696. /**
  120697. * Create a default particle system that you can tweak
  120698. * @param emitter defines the emitter to use
  120699. * @param capacity defines the system capacity (default is 500 particles)
  120700. * @param scene defines the hosting scene
  120701. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120702. * @returns the new Particle system
  120703. */
  120704. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120705. /**
  120706. * This is the main static method (one-liner) of this helper to create different particle systems
  120707. * @param type This string represents the type to the particle system to create
  120708. * @param scene The scene where the particle system should live
  120709. * @param gpu If the system will use gpu
  120710. * @returns the ParticleSystemSet created
  120711. */
  120712. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120713. /**
  120714. * Static function used to export a particle system to a ParticleSystemSet variable.
  120715. * Please note that the emitter shape is not exported
  120716. * @param systems defines the particle systems to export
  120717. * @returns the created particle system set
  120718. */
  120719. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120720. }
  120721. }
  120722. declare module BABYLON {
  120723. interface Engine {
  120724. /**
  120725. * Create an effect to use with particle systems.
  120726. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120727. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120728. * @param uniformsNames defines a list of attribute names
  120729. * @param samplers defines an array of string used to represent textures
  120730. * @param defines defines the string containing the defines to use to compile the shaders
  120731. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120732. * @param onCompiled defines a function to call when the effect creation is successful
  120733. * @param onError defines a function to call when the effect creation has failed
  120734. * @returns the new Effect
  120735. */
  120736. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120737. }
  120738. interface Mesh {
  120739. /**
  120740. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120741. * @returns an array of IParticleSystem
  120742. */
  120743. getEmittedParticleSystems(): IParticleSystem[];
  120744. /**
  120745. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120746. * @returns an array of IParticleSystem
  120747. */
  120748. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120749. }
  120750. /**
  120751. * @hidden
  120752. */
  120753. export var _IDoNeedToBeInTheBuild: number;
  120754. }
  120755. declare module BABYLON {
  120756. interface Scene {
  120757. /** @hidden (Backing field) */
  120758. _physicsEngine: Nullable<IPhysicsEngine>;
  120759. /**
  120760. * Gets the current physics engine
  120761. * @returns a IPhysicsEngine or null if none attached
  120762. */
  120763. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  120764. /**
  120765. * Enables physics to the current scene
  120766. * @param gravity defines the scene's gravity for the physics engine
  120767. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  120768. * @return a boolean indicating if the physics engine was initialized
  120769. */
  120770. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  120771. /**
  120772. * Disables and disposes the physics engine associated with the scene
  120773. */
  120774. disablePhysicsEngine(): void;
  120775. /**
  120776. * Gets a boolean indicating if there is an active physics engine
  120777. * @returns a boolean indicating if there is an active physics engine
  120778. */
  120779. isPhysicsEnabled(): boolean;
  120780. /**
  120781. * Deletes a physics compound impostor
  120782. * @param compound defines the compound to delete
  120783. */
  120784. deleteCompoundImpostor(compound: any): void;
  120785. /**
  120786. * An event triggered when physic simulation is about to be run
  120787. */
  120788. onBeforePhysicsObservable: Observable<Scene>;
  120789. /**
  120790. * An event triggered when physic simulation has been done
  120791. */
  120792. onAfterPhysicsObservable: Observable<Scene>;
  120793. }
  120794. interface AbstractMesh {
  120795. /** @hidden */
  120796. _physicsImpostor: Nullable<PhysicsImpostor>;
  120797. /**
  120798. * Gets or sets impostor used for physic simulation
  120799. * @see http://doc.babylonjs.com/features/physics_engine
  120800. */
  120801. physicsImpostor: Nullable<PhysicsImpostor>;
  120802. /**
  120803. * Gets the current physics impostor
  120804. * @see http://doc.babylonjs.com/features/physics_engine
  120805. * @returns a physics impostor or null
  120806. */
  120807. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  120808. /** Apply a physic impulse to the mesh
  120809. * @param force defines the force to apply
  120810. * @param contactPoint defines where to apply the force
  120811. * @returns the current mesh
  120812. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120813. */
  120814. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  120815. /**
  120816. * Creates a physic joint between two meshes
  120817. * @param otherMesh defines the other mesh to use
  120818. * @param pivot1 defines the pivot to use on this mesh
  120819. * @param pivot2 defines the pivot to use on the other mesh
  120820. * @param options defines additional options (can be plugin dependent)
  120821. * @returns the current mesh
  120822. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  120823. */
  120824. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  120825. /** @hidden */
  120826. _disposePhysicsObserver: Nullable<Observer<Node>>;
  120827. }
  120828. /**
  120829. * Defines the physics engine scene component responsible to manage a physics engine
  120830. */
  120831. export class PhysicsEngineSceneComponent implements ISceneComponent {
  120832. /**
  120833. * The component name helpful to identify the component in the list of scene components.
  120834. */
  120835. readonly name: string;
  120836. /**
  120837. * The scene the component belongs to.
  120838. */
  120839. scene: Scene;
  120840. /**
  120841. * Creates a new instance of the component for the given scene
  120842. * @param scene Defines the scene to register the component in
  120843. */
  120844. constructor(scene: Scene);
  120845. /**
  120846. * Registers the component in a given scene
  120847. */
  120848. register(): void;
  120849. /**
  120850. * Rebuilds the elements related to this component in case of
  120851. * context lost for instance.
  120852. */
  120853. rebuild(): void;
  120854. /**
  120855. * Disposes the component and the associated ressources
  120856. */
  120857. dispose(): void;
  120858. }
  120859. }
  120860. declare module BABYLON {
  120861. /**
  120862. * A helper for physics simulations
  120863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120864. */
  120865. export class PhysicsHelper {
  120866. private _scene;
  120867. private _physicsEngine;
  120868. /**
  120869. * Initializes the Physics helper
  120870. * @param scene Babylon.js scene
  120871. */
  120872. constructor(scene: Scene);
  120873. /**
  120874. * Applies a radial explosion impulse
  120875. * @param origin the origin of the explosion
  120876. * @param radiusOrEventOptions the radius or the options of radial explosion
  120877. * @param strength the explosion strength
  120878. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120879. * @returns A physics radial explosion event, or null
  120880. */
  120881. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120882. /**
  120883. * Applies a radial explosion force
  120884. * @param origin the origin of the explosion
  120885. * @param radiusOrEventOptions the radius or the options of radial explosion
  120886. * @param strength the explosion strength
  120887. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120888. * @returns A physics radial explosion event, or null
  120889. */
  120890. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120891. /**
  120892. * Creates a gravitational field
  120893. * @param origin the origin of the explosion
  120894. * @param radiusOrEventOptions the radius or the options of radial explosion
  120895. * @param strength the explosion strength
  120896. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120897. * @returns A physics gravitational field event, or null
  120898. */
  120899. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  120900. /**
  120901. * Creates a physics updraft event
  120902. * @param origin the origin of the updraft
  120903. * @param radiusOrEventOptions the radius or the options of the updraft
  120904. * @param strength the strength of the updraft
  120905. * @param height the height of the updraft
  120906. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  120907. * @returns A physics updraft event, or null
  120908. */
  120909. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  120910. /**
  120911. * Creates a physics vortex event
  120912. * @param origin the of the vortex
  120913. * @param radiusOrEventOptions the radius or the options of the vortex
  120914. * @param strength the strength of the vortex
  120915. * @param height the height of the vortex
  120916. * @returns a Physics vortex event, or null
  120917. * A physics vortex event or null
  120918. */
  120919. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  120920. }
  120921. /**
  120922. * Represents a physics radial explosion event
  120923. */
  120924. class PhysicsRadialExplosionEvent {
  120925. private _scene;
  120926. private _options;
  120927. private _sphere;
  120928. private _dataFetched;
  120929. /**
  120930. * Initializes a radial explosioin event
  120931. * @param _scene BabylonJS scene
  120932. * @param _options The options for the vortex event
  120933. */
  120934. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  120935. /**
  120936. * Returns the data related to the radial explosion event (sphere).
  120937. * @returns The radial explosion event data
  120938. */
  120939. getData(): PhysicsRadialExplosionEventData;
  120940. /**
  120941. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  120942. * @param impostor A physics imposter
  120943. * @param origin the origin of the explosion
  120944. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  120945. */
  120946. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  120947. /**
  120948. * Triggers affecterd impostors callbacks
  120949. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  120950. */
  120951. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  120952. /**
  120953. * Disposes the sphere.
  120954. * @param force Specifies if the sphere should be disposed by force
  120955. */
  120956. dispose(force?: boolean): void;
  120957. /*** Helpers ***/
  120958. private _prepareSphere;
  120959. private _intersectsWithSphere;
  120960. }
  120961. /**
  120962. * Represents a gravitational field event
  120963. */
  120964. class PhysicsGravitationalFieldEvent {
  120965. private _physicsHelper;
  120966. private _scene;
  120967. private _origin;
  120968. private _options;
  120969. private _tickCallback;
  120970. private _sphere;
  120971. private _dataFetched;
  120972. /**
  120973. * Initializes the physics gravitational field event
  120974. * @param _physicsHelper A physics helper
  120975. * @param _scene BabylonJS scene
  120976. * @param _origin The origin position of the gravitational field event
  120977. * @param _options The options for the vortex event
  120978. */
  120979. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  120980. /**
  120981. * Returns the data related to the gravitational field event (sphere).
  120982. * @returns A gravitational field event
  120983. */
  120984. getData(): PhysicsGravitationalFieldEventData;
  120985. /**
  120986. * Enables the gravitational field.
  120987. */
  120988. enable(): void;
  120989. /**
  120990. * Disables the gravitational field.
  120991. */
  120992. disable(): void;
  120993. /**
  120994. * Disposes the sphere.
  120995. * @param force The force to dispose from the gravitational field event
  120996. */
  120997. dispose(force?: boolean): void;
  120998. private _tick;
  120999. }
  121000. /**
  121001. * Represents a physics updraft event
  121002. */
  121003. class PhysicsUpdraftEvent {
  121004. private _scene;
  121005. private _origin;
  121006. private _options;
  121007. private _physicsEngine;
  121008. private _originTop;
  121009. private _originDirection;
  121010. private _tickCallback;
  121011. private _cylinder;
  121012. private _cylinderPosition;
  121013. private _dataFetched;
  121014. /**
  121015. * Initializes the physics updraft event
  121016. * @param _scene BabylonJS scene
  121017. * @param _origin The origin position of the updraft
  121018. * @param _options The options for the updraft event
  121019. */
  121020. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121021. /**
  121022. * Returns the data related to the updraft event (cylinder).
  121023. * @returns A physics updraft event
  121024. */
  121025. getData(): PhysicsUpdraftEventData;
  121026. /**
  121027. * Enables the updraft.
  121028. */
  121029. enable(): void;
  121030. /**
  121031. * Disables the updraft.
  121032. */
  121033. disable(): void;
  121034. /**
  121035. * Disposes the cylinder.
  121036. * @param force Specifies if the updraft should be disposed by force
  121037. */
  121038. dispose(force?: boolean): void;
  121039. private getImpostorHitData;
  121040. private _tick;
  121041. /*** Helpers ***/
  121042. private _prepareCylinder;
  121043. private _intersectsWithCylinder;
  121044. }
  121045. /**
  121046. * Represents a physics vortex event
  121047. */
  121048. class PhysicsVortexEvent {
  121049. private _scene;
  121050. private _origin;
  121051. private _options;
  121052. private _physicsEngine;
  121053. private _originTop;
  121054. private _tickCallback;
  121055. private _cylinder;
  121056. private _cylinderPosition;
  121057. private _dataFetched;
  121058. /**
  121059. * Initializes the physics vortex event
  121060. * @param _scene The BabylonJS scene
  121061. * @param _origin The origin position of the vortex
  121062. * @param _options The options for the vortex event
  121063. */
  121064. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121065. /**
  121066. * Returns the data related to the vortex event (cylinder).
  121067. * @returns The physics vortex event data
  121068. */
  121069. getData(): PhysicsVortexEventData;
  121070. /**
  121071. * Enables the vortex.
  121072. */
  121073. enable(): void;
  121074. /**
  121075. * Disables the cortex.
  121076. */
  121077. disable(): void;
  121078. /**
  121079. * Disposes the sphere.
  121080. * @param force
  121081. */
  121082. dispose(force?: boolean): void;
  121083. private getImpostorHitData;
  121084. private _tick;
  121085. /*** Helpers ***/
  121086. private _prepareCylinder;
  121087. private _intersectsWithCylinder;
  121088. }
  121089. /**
  121090. * Options fot the radial explosion event
  121091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121092. */
  121093. export class PhysicsRadialExplosionEventOptions {
  121094. /**
  121095. * The radius of the sphere for the radial explosion.
  121096. */
  121097. radius: number;
  121098. /**
  121099. * The strenth of the explosion.
  121100. */
  121101. strength: number;
  121102. /**
  121103. * The strenght of the force in correspondence to the distance of the affected object
  121104. */
  121105. falloff: PhysicsRadialImpulseFalloff;
  121106. /**
  121107. * Sphere options for the radial explosion.
  121108. */
  121109. sphere: {
  121110. segments: number;
  121111. diameter: number;
  121112. };
  121113. /**
  121114. * Sphere options for the radial explosion.
  121115. */
  121116. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121117. }
  121118. /**
  121119. * Options fot the updraft event
  121120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121121. */
  121122. export class PhysicsUpdraftEventOptions {
  121123. /**
  121124. * The radius of the cylinder for the vortex
  121125. */
  121126. radius: number;
  121127. /**
  121128. * The strenth of the updraft.
  121129. */
  121130. strength: number;
  121131. /**
  121132. * The height of the cylinder for the updraft.
  121133. */
  121134. height: number;
  121135. /**
  121136. * The mode for the the updraft.
  121137. */
  121138. updraftMode: PhysicsUpdraftMode;
  121139. }
  121140. /**
  121141. * Options fot the vortex event
  121142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121143. */
  121144. export class PhysicsVortexEventOptions {
  121145. /**
  121146. * The radius of the cylinder for the vortex
  121147. */
  121148. radius: number;
  121149. /**
  121150. * The strenth of the vortex.
  121151. */
  121152. strength: number;
  121153. /**
  121154. * The height of the cylinder for the vortex.
  121155. */
  121156. height: number;
  121157. /**
  121158. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  121159. */
  121160. centripetalForceThreshold: number;
  121161. /**
  121162. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  121163. */
  121164. centripetalForceMultiplier: number;
  121165. /**
  121166. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  121167. */
  121168. centrifugalForceMultiplier: number;
  121169. /**
  121170. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  121171. */
  121172. updraftForceMultiplier: number;
  121173. }
  121174. /**
  121175. * The strenght of the force in correspondence to the distance of the affected object
  121176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121177. */
  121178. export enum PhysicsRadialImpulseFalloff {
  121179. /** Defines that impulse is constant in strength across it's whole radius */
  121180. Constant = 0,
  121181. /** Defines that impulse gets weaker if it's further from the origin */
  121182. Linear = 1
  121183. }
  121184. /**
  121185. * The strength of the force in correspondence to the distance of the affected object
  121186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121187. */
  121188. export enum PhysicsUpdraftMode {
  121189. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  121190. Center = 0,
  121191. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  121192. Perpendicular = 1
  121193. }
  121194. /**
  121195. * Interface for a physics hit data
  121196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121197. */
  121198. export interface PhysicsHitData {
  121199. /**
  121200. * The force applied at the contact point
  121201. */
  121202. force: Vector3;
  121203. /**
  121204. * The contact point
  121205. */
  121206. contactPoint: Vector3;
  121207. /**
  121208. * The distance from the origin to the contact point
  121209. */
  121210. distanceFromOrigin: number;
  121211. }
  121212. /**
  121213. * Interface for radial explosion event data
  121214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121215. */
  121216. export interface PhysicsRadialExplosionEventData {
  121217. /**
  121218. * A sphere used for the radial explosion event
  121219. */
  121220. sphere: Mesh;
  121221. }
  121222. /**
  121223. * Interface for gravitational field event data
  121224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121225. */
  121226. export interface PhysicsGravitationalFieldEventData {
  121227. /**
  121228. * A sphere mesh used for the gravitational field event
  121229. */
  121230. sphere: Mesh;
  121231. }
  121232. /**
  121233. * Interface for updraft event data
  121234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121235. */
  121236. export interface PhysicsUpdraftEventData {
  121237. /**
  121238. * A cylinder used for the updraft event
  121239. */
  121240. cylinder: Mesh;
  121241. }
  121242. /**
  121243. * Interface for vortex event data
  121244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121245. */
  121246. export interface PhysicsVortexEventData {
  121247. /**
  121248. * A cylinder used for the vortex event
  121249. */
  121250. cylinder: Mesh;
  121251. }
  121252. /**
  121253. * Interface for an affected physics impostor
  121254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121255. */
  121256. export interface PhysicsAffectedImpostorWithData {
  121257. /**
  121258. * The impostor affected by the effect
  121259. */
  121260. impostor: PhysicsImpostor;
  121261. /**
  121262. * The data about the hit/horce from the explosion
  121263. */
  121264. hitData: PhysicsHitData;
  121265. }
  121266. }
  121267. declare module BABYLON {
  121268. /** @hidden */
  121269. export var blackAndWhitePixelShader: {
  121270. name: string;
  121271. shader: string;
  121272. };
  121273. }
  121274. declare module BABYLON {
  121275. /**
  121276. * Post process used to render in black and white
  121277. */
  121278. export class BlackAndWhitePostProcess extends PostProcess {
  121279. /**
  121280. * Linear about to convert he result to black and white (default: 1)
  121281. */
  121282. degree: number;
  121283. /**
  121284. * Creates a black and white post process
  121285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  121286. * @param name The name of the effect.
  121287. * @param options The required width/height ratio to downsize to before computing the render pass.
  121288. * @param camera The camera to apply the render pass to.
  121289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121290. * @param engine The engine which the post process will be applied. (default: current engine)
  121291. * @param reusable If the post process can be reused on the same frame. (default: false)
  121292. */
  121293. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121294. }
  121295. }
  121296. declare module BABYLON {
  121297. /**
  121298. * This represents a set of one or more post processes in Babylon.
  121299. * A post process can be used to apply a shader to a texture after it is rendered.
  121300. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121301. */
  121302. export class PostProcessRenderEffect {
  121303. private _postProcesses;
  121304. private _getPostProcesses;
  121305. private _singleInstance;
  121306. private _cameras;
  121307. private _indicesForCamera;
  121308. /**
  121309. * Name of the effect
  121310. * @hidden
  121311. */
  121312. _name: string;
  121313. /**
  121314. * Instantiates a post process render effect.
  121315. * A post process can be used to apply a shader to a texture after it is rendered.
  121316. * @param engine The engine the effect is tied to
  121317. * @param name The name of the effect
  121318. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121319. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121320. */
  121321. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  121322. /**
  121323. * Checks if all the post processes in the effect are supported.
  121324. */
  121325. readonly isSupported: boolean;
  121326. /**
  121327. * Updates the current state of the effect
  121328. * @hidden
  121329. */
  121330. _update(): void;
  121331. /**
  121332. * Attaches the effect on cameras
  121333. * @param cameras The camera to attach to.
  121334. * @hidden
  121335. */
  121336. _attachCameras(cameras: Camera): void;
  121337. /**
  121338. * Attaches the effect on cameras
  121339. * @param cameras The camera to attach to.
  121340. * @hidden
  121341. */
  121342. _attachCameras(cameras: Camera[]): void;
  121343. /**
  121344. * Detaches the effect on cameras
  121345. * @param cameras The camera to detatch from.
  121346. * @hidden
  121347. */
  121348. _detachCameras(cameras: Camera): void;
  121349. /**
  121350. * Detatches the effect on cameras
  121351. * @param cameras The camera to detatch from.
  121352. * @hidden
  121353. */
  121354. _detachCameras(cameras: Camera[]): void;
  121355. /**
  121356. * Enables the effect on given cameras
  121357. * @param cameras The camera to enable.
  121358. * @hidden
  121359. */
  121360. _enable(cameras: Camera): void;
  121361. /**
  121362. * Enables the effect on given cameras
  121363. * @param cameras The camera to enable.
  121364. * @hidden
  121365. */
  121366. _enable(cameras: Nullable<Camera[]>): void;
  121367. /**
  121368. * Disables the effect on the given cameras
  121369. * @param cameras The camera to disable.
  121370. * @hidden
  121371. */
  121372. _disable(cameras: Camera): void;
  121373. /**
  121374. * Disables the effect on the given cameras
  121375. * @param cameras The camera to disable.
  121376. * @hidden
  121377. */
  121378. _disable(cameras: Nullable<Camera[]>): void;
  121379. /**
  121380. * Gets a list of the post processes contained in the effect.
  121381. * @param camera The camera to get the post processes on.
  121382. * @returns The list of the post processes in the effect.
  121383. */
  121384. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  121385. }
  121386. }
  121387. declare module BABYLON {
  121388. /** @hidden */
  121389. export var extractHighlightsPixelShader: {
  121390. name: string;
  121391. shader: string;
  121392. };
  121393. }
  121394. declare module BABYLON {
  121395. /**
  121396. * 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.
  121397. */
  121398. export class ExtractHighlightsPostProcess extends PostProcess {
  121399. /**
  121400. * The luminance threshold, pixels below this value will be set to black.
  121401. */
  121402. threshold: number;
  121403. /** @hidden */
  121404. _exposure: number;
  121405. /**
  121406. * Post process which has the input texture to be used when performing highlight extraction
  121407. * @hidden
  121408. */
  121409. _inputPostProcess: Nullable<PostProcess>;
  121410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121411. }
  121412. }
  121413. declare module BABYLON {
  121414. /** @hidden */
  121415. export var bloomMergePixelShader: {
  121416. name: string;
  121417. shader: string;
  121418. };
  121419. }
  121420. declare module BABYLON {
  121421. /**
  121422. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121423. */
  121424. export class BloomMergePostProcess extends PostProcess {
  121425. /** Weight of the bloom to be added to the original input. */
  121426. weight: number;
  121427. /**
  121428. * Creates a new instance of @see BloomMergePostProcess
  121429. * @param name The name of the effect.
  121430. * @param originalFromInput Post process which's input will be used for the merge.
  121431. * @param blurred Blurred highlights post process which's output will be used.
  121432. * @param weight Weight of the bloom to be added to the original input.
  121433. * @param options The required width/height ratio to downsize to before computing the render pass.
  121434. * @param camera The camera to apply the render pass to.
  121435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121436. * @param engine The engine which the post process will be applied. (default: current engine)
  121437. * @param reusable If the post process can be reused on the same frame. (default: false)
  121438. * @param textureType Type of textures used when performing the post process. (default: 0)
  121439. * @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)
  121440. */
  121441. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  121442. /** Weight of the bloom to be added to the original input. */
  121443. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121444. }
  121445. }
  121446. declare module BABYLON {
  121447. /**
  121448. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  121449. */
  121450. export class BloomEffect extends PostProcessRenderEffect {
  121451. private bloomScale;
  121452. /**
  121453. * @hidden Internal
  121454. */
  121455. _effects: Array<PostProcess>;
  121456. /**
  121457. * @hidden Internal
  121458. */
  121459. _downscale: ExtractHighlightsPostProcess;
  121460. private _blurX;
  121461. private _blurY;
  121462. private _merge;
  121463. /**
  121464. * The luminance threshold to find bright areas of the image to bloom.
  121465. */
  121466. threshold: number;
  121467. /**
  121468. * The strength of the bloom.
  121469. */
  121470. weight: number;
  121471. /**
  121472. * Specifies the size of the bloom blur kernel, relative to the final output size
  121473. */
  121474. kernel: number;
  121475. /**
  121476. * Creates a new instance of @see BloomEffect
  121477. * @param scene The scene the effect belongs to.
  121478. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  121479. * @param bloomKernel The size of the kernel to be used when applying the blur.
  121480. * @param bloomWeight The the strength of bloom.
  121481. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121482. * @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)
  121483. */
  121484. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  121485. /**
  121486. * Disposes each of the internal effects for a given camera.
  121487. * @param camera The camera to dispose the effect on.
  121488. */
  121489. disposeEffects(camera: Camera): void;
  121490. /**
  121491. * @hidden Internal
  121492. */
  121493. _updateEffects(): void;
  121494. /**
  121495. * Internal
  121496. * @returns if all the contained post processes are ready.
  121497. * @hidden
  121498. */
  121499. _isReady(): boolean;
  121500. }
  121501. }
  121502. declare module BABYLON {
  121503. /** @hidden */
  121504. export var chromaticAberrationPixelShader: {
  121505. name: string;
  121506. shader: string;
  121507. };
  121508. }
  121509. declare module BABYLON {
  121510. /**
  121511. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  121512. */
  121513. export class ChromaticAberrationPostProcess extends PostProcess {
  121514. /**
  121515. * The amount of seperation of rgb channels (default: 30)
  121516. */
  121517. aberrationAmount: number;
  121518. /**
  121519. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  121520. */
  121521. radialIntensity: number;
  121522. /**
  121523. * 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))
  121524. */
  121525. direction: Vector2;
  121526. /**
  121527. * 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))
  121528. */
  121529. centerPosition: Vector2;
  121530. /**
  121531. * Creates a new instance ChromaticAberrationPostProcess
  121532. * @param name The name of the effect.
  121533. * @param screenWidth The width of the screen to apply the effect on.
  121534. * @param screenHeight The height of the screen to apply the effect on.
  121535. * @param options The required width/height ratio to downsize to before computing the render pass.
  121536. * @param camera The camera to apply the render pass to.
  121537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121538. * @param engine The engine which the post process will be applied. (default: current engine)
  121539. * @param reusable If the post process can be reused on the same frame. (default: false)
  121540. * @param textureType Type of textures used when performing the post process. (default: 0)
  121541. * @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)
  121542. */
  121543. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121544. }
  121545. }
  121546. declare module BABYLON {
  121547. /** @hidden */
  121548. export var circleOfConfusionPixelShader: {
  121549. name: string;
  121550. shader: string;
  121551. };
  121552. }
  121553. declare module BABYLON {
  121554. /**
  121555. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  121556. */
  121557. export class CircleOfConfusionPostProcess extends PostProcess {
  121558. /**
  121559. * 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.
  121560. */
  121561. lensSize: number;
  121562. /**
  121563. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121564. */
  121565. fStop: number;
  121566. /**
  121567. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121568. */
  121569. focusDistance: number;
  121570. /**
  121571. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  121572. */
  121573. focalLength: number;
  121574. private _depthTexture;
  121575. /**
  121576. * Creates a new instance CircleOfConfusionPostProcess
  121577. * @param name The name of the effect.
  121578. * @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.
  121579. * @param options The required width/height ratio to downsize to before computing the render pass.
  121580. * @param camera The camera to apply the render pass to.
  121581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121582. * @param engine The engine which the post process will be applied. (default: current engine)
  121583. * @param reusable If the post process can be reused on the same frame. (default: false)
  121584. * @param textureType Type of textures used when performing the post process. (default: 0)
  121585. * @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)
  121586. */
  121587. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121588. /**
  121589. * 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.
  121590. */
  121591. depthTexture: RenderTargetTexture;
  121592. }
  121593. }
  121594. declare module BABYLON {
  121595. /** @hidden */
  121596. export var colorCorrectionPixelShader: {
  121597. name: string;
  121598. shader: string;
  121599. };
  121600. }
  121601. declare module BABYLON {
  121602. /**
  121603. *
  121604. * This post-process allows the modification of rendered colors by using
  121605. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121606. *
  121607. * The object needs to be provided an url to a texture containing the color
  121608. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121609. * Use an image editing software to tweak the LUT to match your needs.
  121610. *
  121611. * For an example of a color LUT, see here:
  121612. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121613. * For explanations on color grading, see here:
  121614. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121615. *
  121616. */
  121617. export class ColorCorrectionPostProcess extends PostProcess {
  121618. private _colorTableTexture;
  121619. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121620. }
  121621. }
  121622. declare module BABYLON {
  121623. /** @hidden */
  121624. export var convolutionPixelShader: {
  121625. name: string;
  121626. shader: string;
  121627. };
  121628. }
  121629. declare module BABYLON {
  121630. /**
  121631. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121632. * input texture to perform effects such as edge detection or sharpening
  121633. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121634. */
  121635. export class ConvolutionPostProcess extends PostProcess {
  121636. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121637. kernel: number[];
  121638. /**
  121639. * Creates a new instance ConvolutionPostProcess
  121640. * @param name The name of the effect.
  121641. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121642. * @param options The required width/height ratio to downsize to before computing the render pass.
  121643. * @param camera The camera to apply the render pass to.
  121644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121645. * @param engine The engine which the post process will be applied. (default: current engine)
  121646. * @param reusable If the post process can be reused on the same frame. (default: false)
  121647. * @param textureType Type of textures used when performing the post process. (default: 0)
  121648. */
  121649. constructor(name: string,
  121650. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121651. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121652. /**
  121653. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121654. */
  121655. static EdgeDetect0Kernel: number[];
  121656. /**
  121657. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121658. */
  121659. static EdgeDetect1Kernel: number[];
  121660. /**
  121661. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121662. */
  121663. static EdgeDetect2Kernel: number[];
  121664. /**
  121665. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121666. */
  121667. static SharpenKernel: number[];
  121668. /**
  121669. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121670. */
  121671. static EmbossKernel: number[];
  121672. /**
  121673. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121674. */
  121675. static GaussianKernel: number[];
  121676. }
  121677. }
  121678. declare module BABYLON {
  121679. /**
  121680. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121681. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121682. * based on samples that have a large difference in distance than the center pixel.
  121683. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121684. */
  121685. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121686. direction: Vector2;
  121687. /**
  121688. * Creates a new instance CircleOfConfusionPostProcess
  121689. * @param name The name of the effect.
  121690. * @param scene The scene the effect belongs to.
  121691. * @param direction The direction the blur should be applied.
  121692. * @param kernel The size of the kernel used to blur.
  121693. * @param options The required width/height ratio to downsize to before computing the render pass.
  121694. * @param camera The camera to apply the render pass to.
  121695. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121696. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121698. * @param engine The engine which the post process will be applied. (default: current engine)
  121699. * @param reusable If the post process can be reused on the same frame. (default: false)
  121700. * @param textureType Type of textures used when performing the post process. (default: 0)
  121701. * @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)
  121702. */
  121703. 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);
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /** @hidden */
  121708. export var depthOfFieldMergePixelShader: {
  121709. name: string;
  121710. shader: string;
  121711. };
  121712. }
  121713. declare module BABYLON {
  121714. /**
  121715. * Options to be set when merging outputs from the default pipeline.
  121716. */
  121717. export class DepthOfFieldMergePostProcessOptions {
  121718. /**
  121719. * The original image to merge on top of
  121720. */
  121721. originalFromInput: PostProcess;
  121722. /**
  121723. * Parameters to perform the merge of the depth of field effect
  121724. */
  121725. depthOfField?: {
  121726. circleOfConfusion: PostProcess;
  121727. blurSteps: Array<PostProcess>;
  121728. };
  121729. /**
  121730. * Parameters to perform the merge of bloom effect
  121731. */
  121732. bloom?: {
  121733. blurred: PostProcess;
  121734. weight: number;
  121735. };
  121736. }
  121737. /**
  121738. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121739. */
  121740. export class DepthOfFieldMergePostProcess extends PostProcess {
  121741. private blurSteps;
  121742. /**
  121743. * Creates a new instance of DepthOfFieldMergePostProcess
  121744. * @param name The name of the effect.
  121745. * @param originalFromInput Post process which's input will be used for the merge.
  121746. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121747. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121748. * @param options The required width/height ratio to downsize to before computing the render pass.
  121749. * @param camera The camera to apply the render pass to.
  121750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121751. * @param engine The engine which the post process will be applied. (default: current engine)
  121752. * @param reusable If the post process can be reused on the same frame. (default: false)
  121753. * @param textureType Type of textures used when performing the post process. (default: 0)
  121754. * @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)
  121755. */
  121756. 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);
  121757. /**
  121758. * Updates the effect with the current post process compile time values and recompiles the shader.
  121759. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121760. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121761. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121762. * @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
  121763. * @param onCompiled Called when the shader has been compiled.
  121764. * @param onError Called if there is an error when compiling a shader.
  121765. */
  121766. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  121767. }
  121768. }
  121769. declare module BABYLON {
  121770. /**
  121771. * Specifies the level of max blur that should be applied when using the depth of field effect
  121772. */
  121773. export enum DepthOfFieldEffectBlurLevel {
  121774. /**
  121775. * Subtle blur
  121776. */
  121777. Low = 0,
  121778. /**
  121779. * Medium blur
  121780. */
  121781. Medium = 1,
  121782. /**
  121783. * Large blur
  121784. */
  121785. High = 2
  121786. }
  121787. /**
  121788. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121789. */
  121790. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  121791. private _circleOfConfusion;
  121792. /**
  121793. * @hidden Internal, blurs from high to low
  121794. */
  121795. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  121796. private _depthOfFieldBlurY;
  121797. private _dofMerge;
  121798. /**
  121799. * @hidden Internal post processes in depth of field effect
  121800. */
  121801. _effects: Array<PostProcess>;
  121802. /**
  121803. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121804. */
  121805. focalLength: number;
  121806. /**
  121807. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121808. */
  121809. fStop: number;
  121810. /**
  121811. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121812. */
  121813. focusDistance: number;
  121814. /**
  121815. * 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.
  121816. */
  121817. lensSize: number;
  121818. /**
  121819. * Creates a new instance DepthOfFieldEffect
  121820. * @param scene The scene the effect belongs to.
  121821. * @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.
  121822. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121823. * @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)
  121824. */
  121825. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  121826. /**
  121827. * Get the current class name of the current effet
  121828. * @returns "DepthOfFieldEffect"
  121829. */
  121830. getClassName(): string;
  121831. /**
  121832. * 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.
  121833. */
  121834. depthTexture: RenderTargetTexture;
  121835. /**
  121836. * Disposes each of the internal effects for a given camera.
  121837. * @param camera The camera to dispose the effect on.
  121838. */
  121839. disposeEffects(camera: Camera): void;
  121840. /**
  121841. * @hidden Internal
  121842. */
  121843. _updateEffects(): void;
  121844. /**
  121845. * Internal
  121846. * @returns if all the contained post processes are ready.
  121847. * @hidden
  121848. */
  121849. _isReady(): boolean;
  121850. }
  121851. }
  121852. declare module BABYLON {
  121853. /** @hidden */
  121854. export var displayPassPixelShader: {
  121855. name: string;
  121856. shader: string;
  121857. };
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * DisplayPassPostProcess which produces an output the same as it's input
  121862. */
  121863. export class DisplayPassPostProcess extends PostProcess {
  121864. /**
  121865. * Creates the DisplayPassPostProcess
  121866. * @param name The name of the effect.
  121867. * @param options The required width/height ratio to downsize to before computing the render pass.
  121868. * @param camera The camera to apply the render pass to.
  121869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121870. * @param engine The engine which the post process will be applied. (default: current engine)
  121871. * @param reusable If the post process can be reused on the same frame. (default: false)
  121872. */
  121873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121874. }
  121875. }
  121876. declare module BABYLON {
  121877. /** @hidden */
  121878. export var filterPixelShader: {
  121879. name: string;
  121880. shader: string;
  121881. };
  121882. }
  121883. declare module BABYLON {
  121884. /**
  121885. * Applies a kernel filter to the image
  121886. */
  121887. export class FilterPostProcess extends PostProcess {
  121888. /** The matrix to be applied to the image */
  121889. kernelMatrix: Matrix;
  121890. /**
  121891. *
  121892. * @param name The name of the effect.
  121893. * @param kernelMatrix The matrix to be applied to the image
  121894. * @param options The required width/height ratio to downsize to before computing the render pass.
  121895. * @param camera The camera to apply the render pass to.
  121896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121897. * @param engine The engine which the post process will be applied. (default: current engine)
  121898. * @param reusable If the post process can be reused on the same frame. (default: false)
  121899. */
  121900. constructor(name: string,
  121901. /** The matrix to be applied to the image */
  121902. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121903. }
  121904. }
  121905. declare module BABYLON {
  121906. /** @hidden */
  121907. export var fxaaPixelShader: {
  121908. name: string;
  121909. shader: string;
  121910. };
  121911. }
  121912. declare module BABYLON {
  121913. /** @hidden */
  121914. export var fxaaVertexShader: {
  121915. name: string;
  121916. shader: string;
  121917. };
  121918. }
  121919. declare module BABYLON {
  121920. /**
  121921. * Fxaa post process
  121922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121923. */
  121924. export class FxaaPostProcess extends PostProcess {
  121925. /** @hidden */
  121926. texelWidth: number;
  121927. /** @hidden */
  121928. texelHeight: number;
  121929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121930. private _getDefines;
  121931. }
  121932. }
  121933. declare module BABYLON {
  121934. /** @hidden */
  121935. export var grainPixelShader: {
  121936. name: string;
  121937. shader: string;
  121938. };
  121939. }
  121940. declare module BABYLON {
  121941. /**
  121942. * The GrainPostProcess adds noise to the image at mid luminance levels
  121943. */
  121944. export class GrainPostProcess extends PostProcess {
  121945. /**
  121946. * The intensity of the grain added (default: 30)
  121947. */
  121948. intensity: number;
  121949. /**
  121950. * If the grain should be randomized on every frame
  121951. */
  121952. animated: boolean;
  121953. /**
  121954. * Creates a new instance of @see GrainPostProcess
  121955. * @param name The name of the effect.
  121956. * @param options The required width/height ratio to downsize to before computing the render pass.
  121957. * @param camera The camera to apply the render pass to.
  121958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121959. * @param engine The engine which the post process will be applied. (default: current engine)
  121960. * @param reusable If the post process can be reused on the same frame. (default: false)
  121961. * @param textureType Type of textures used when performing the post process. (default: 0)
  121962. * @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)
  121963. */
  121964. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121965. }
  121966. }
  121967. declare module BABYLON {
  121968. /** @hidden */
  121969. export var highlightsPixelShader: {
  121970. name: string;
  121971. shader: string;
  121972. };
  121973. }
  121974. declare module BABYLON {
  121975. /**
  121976. * Extracts highlights from the image
  121977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121978. */
  121979. export class HighlightsPostProcess extends PostProcess {
  121980. /**
  121981. * Extracts highlights from the image
  121982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121983. * @param name The name of the effect.
  121984. * @param options The required width/height ratio to downsize to before computing the render pass.
  121985. * @param camera The camera to apply the render pass to.
  121986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121987. * @param engine The engine which the post process will be applied. (default: current engine)
  121988. * @param reusable If the post process can be reused on the same frame. (default: false)
  121989. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121990. */
  121991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121992. }
  121993. }
  121994. declare module BABYLON {
  121995. /** @hidden */
  121996. export var mrtFragmentDeclaration: {
  121997. name: string;
  121998. shader: string;
  121999. };
  122000. }
  122001. declare module BABYLON {
  122002. /** @hidden */
  122003. export var geometryPixelShader: {
  122004. name: string;
  122005. shader: string;
  122006. };
  122007. }
  122008. declare module BABYLON {
  122009. /** @hidden */
  122010. export var geometryVertexShader: {
  122011. name: string;
  122012. shader: string;
  122013. };
  122014. }
  122015. declare module BABYLON {
  122016. /** @hidden */
  122017. interface ISavedTransformationMatrix {
  122018. world: Matrix;
  122019. viewProjection: Matrix;
  122020. }
  122021. /**
  122022. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122023. */
  122024. export class GeometryBufferRenderer {
  122025. /**
  122026. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122027. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122028. */
  122029. static readonly POSITION_TEXTURE_TYPE: number;
  122030. /**
  122031. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122032. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122033. */
  122034. static readonly VELOCITY_TEXTURE_TYPE: number;
  122035. /**
  122036. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122037. * in order to compute objects velocities when enableVelocity is set to "true"
  122038. * @hidden
  122039. */
  122040. _previousTransformationMatrices: {
  122041. [index: number]: ISavedTransformationMatrix;
  122042. };
  122043. /**
  122044. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122045. * in order to compute objects velocities when enableVelocity is set to "true"
  122046. * @hidden
  122047. */
  122048. _previousBonesTransformationMatrices: {
  122049. [index: number]: Float32Array;
  122050. };
  122051. /**
  122052. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122053. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122054. */
  122055. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122056. private _scene;
  122057. private _multiRenderTarget;
  122058. private _ratio;
  122059. private _enablePosition;
  122060. private _enableVelocity;
  122061. private _positionIndex;
  122062. private _velocityIndex;
  122063. protected _effect: Effect;
  122064. protected _cachedDefines: string;
  122065. /**
  122066. * Set the render list (meshes to be rendered) used in the G buffer.
  122067. */
  122068. renderList: Mesh[];
  122069. /**
  122070. * Gets wether or not G buffer are supported by the running hardware.
  122071. * This requires draw buffer supports
  122072. */
  122073. readonly isSupported: boolean;
  122074. /**
  122075. * Returns the index of the given texture type in the G-Buffer textures array
  122076. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122077. * @returns the index of the given texture type in the G-Buffer textures array
  122078. */
  122079. getTextureIndex(textureType: number): number;
  122080. /**
  122081. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122082. */
  122083. /**
  122084. * Sets whether or not objects positions are enabled for the G buffer.
  122085. */
  122086. enablePosition: boolean;
  122087. /**
  122088. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122089. */
  122090. /**
  122091. * Sets wether or not objects velocities are enabled for the G buffer.
  122092. */
  122093. enableVelocity: boolean;
  122094. /**
  122095. * Gets the scene associated with the buffer.
  122096. */
  122097. readonly scene: Scene;
  122098. /**
  122099. * Gets the ratio used by the buffer during its creation.
  122100. * How big is the buffer related to the main canvas.
  122101. */
  122102. readonly ratio: number;
  122103. /** @hidden */
  122104. static _SceneComponentInitialization: (scene: Scene) => void;
  122105. /**
  122106. * Creates a new G Buffer for the scene
  122107. * @param scene The scene the buffer belongs to
  122108. * @param ratio How big is the buffer related to the main canvas.
  122109. */
  122110. constructor(scene: Scene, ratio?: number);
  122111. /**
  122112. * Checks wether everything is ready to render a submesh to the G buffer.
  122113. * @param subMesh the submesh to check readiness for
  122114. * @param useInstances is the mesh drawn using instance or not
  122115. * @returns true if ready otherwise false
  122116. */
  122117. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122118. /**
  122119. * Gets the current underlying G Buffer.
  122120. * @returns the buffer
  122121. */
  122122. getGBuffer(): MultiRenderTarget;
  122123. /**
  122124. * Gets the number of samples used to render the buffer (anti aliasing).
  122125. */
  122126. /**
  122127. * Sets the number of samples used to render the buffer (anti aliasing).
  122128. */
  122129. samples: number;
  122130. /**
  122131. * Disposes the renderer and frees up associated resources.
  122132. */
  122133. dispose(): void;
  122134. protected _createRenderTargets(): void;
  122135. private _copyBonesTransformationMatrices;
  122136. }
  122137. }
  122138. declare module BABYLON {
  122139. interface Scene {
  122140. /** @hidden (Backing field) */
  122141. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122142. /**
  122143. * Gets or Sets the current geometry buffer associated to the scene.
  122144. */
  122145. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  122146. /**
  122147. * Enables a GeometryBufferRender and associates it with the scene
  122148. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  122149. * @returns the GeometryBufferRenderer
  122150. */
  122151. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  122152. /**
  122153. * Disables the GeometryBufferRender associated with the scene
  122154. */
  122155. disableGeometryBufferRenderer(): void;
  122156. }
  122157. /**
  122158. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122159. * in several rendering techniques.
  122160. */
  122161. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  122162. /**
  122163. * The component name helpful to identify the component in the list of scene components.
  122164. */
  122165. readonly name: string;
  122166. /**
  122167. * The scene the component belongs to.
  122168. */
  122169. scene: Scene;
  122170. /**
  122171. * Creates a new instance of the component for the given scene
  122172. * @param scene Defines the scene to register the component in
  122173. */
  122174. constructor(scene: Scene);
  122175. /**
  122176. * Registers the component in a given scene
  122177. */
  122178. register(): void;
  122179. /**
  122180. * Rebuilds the elements related to this component in case of
  122181. * context lost for instance.
  122182. */
  122183. rebuild(): void;
  122184. /**
  122185. * Disposes the component and the associated ressources
  122186. */
  122187. dispose(): void;
  122188. private _gatherRenderTargets;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /** @hidden */
  122193. export var motionBlurPixelShader: {
  122194. name: string;
  122195. shader: string;
  122196. };
  122197. }
  122198. declare module BABYLON {
  122199. /**
  122200. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  122201. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  122202. * As an example, all you have to do is to create the post-process:
  122203. * var mb = new BABYLON.MotionBlurPostProcess(
  122204. * 'mb', // The name of the effect.
  122205. * scene, // The scene containing the objects to blur according to their velocity.
  122206. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  122207. * camera // The camera to apply the render pass to.
  122208. * );
  122209. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  122210. */
  122211. export class MotionBlurPostProcess extends PostProcess {
  122212. /**
  122213. * Defines how much the image is blurred by the movement. Default value is equal to 1
  122214. */
  122215. motionStrength: number;
  122216. /**
  122217. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  122218. */
  122219. /**
  122220. * Sets the number of iterations to be used for motion blur quality
  122221. */
  122222. motionBlurSamples: number;
  122223. private _motionBlurSamples;
  122224. private _geometryBufferRenderer;
  122225. /**
  122226. * Creates a new instance MotionBlurPostProcess
  122227. * @param name The name of the effect.
  122228. * @param scene The scene containing the objects to blur according to their velocity.
  122229. * @param options The required width/height ratio to downsize to before computing the render pass.
  122230. * @param camera The camera to apply the render pass to.
  122231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122232. * @param engine The engine which the post process will be applied. (default: current engine)
  122233. * @param reusable If the post process can be reused on the same frame. (default: false)
  122234. * @param textureType Type of textures used when performing the post process. (default: 0)
  122235. * @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)
  122236. */
  122237. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122238. /**
  122239. * Excludes the given skinned mesh from computing bones velocities.
  122240. * 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.
  122241. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  122242. */
  122243. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122244. /**
  122245. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  122246. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  122247. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  122248. */
  122249. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  122250. /**
  122251. * Disposes the post process.
  122252. * @param camera The camera to dispose the post process on.
  122253. */
  122254. dispose(camera?: Camera): void;
  122255. }
  122256. }
  122257. declare module BABYLON {
  122258. /** @hidden */
  122259. export var refractionPixelShader: {
  122260. name: string;
  122261. shader: string;
  122262. };
  122263. }
  122264. declare module BABYLON {
  122265. /**
  122266. * Post process which applies a refractin texture
  122267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122268. */
  122269. export class RefractionPostProcess extends PostProcess {
  122270. /** the base color of the refraction (used to taint the rendering) */
  122271. color: Color3;
  122272. /** simulated refraction depth */
  122273. depth: number;
  122274. /** the coefficient of the base color (0 to remove base color tainting) */
  122275. colorLevel: number;
  122276. private _refTexture;
  122277. private _ownRefractionTexture;
  122278. /**
  122279. * Gets or sets the refraction texture
  122280. * Please note that you are responsible for disposing the texture if you set it manually
  122281. */
  122282. refractionTexture: Texture;
  122283. /**
  122284. * Initializes the RefractionPostProcess
  122285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  122286. * @param name The name of the effect.
  122287. * @param refractionTextureUrl Url of the refraction texture to use
  122288. * @param color the base color of the refraction (used to taint the rendering)
  122289. * @param depth simulated refraction depth
  122290. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  122291. * @param camera The camera to apply the render pass to.
  122292. * @param options The required width/height ratio to downsize to before computing the render pass.
  122293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122294. * @param engine The engine which the post process will be applied. (default: current engine)
  122295. * @param reusable If the post process can be reused on the same frame. (default: false)
  122296. */
  122297. constructor(name: string, refractionTextureUrl: string,
  122298. /** the base color of the refraction (used to taint the rendering) */
  122299. color: Color3,
  122300. /** simulated refraction depth */
  122301. depth: number,
  122302. /** the coefficient of the base color (0 to remove base color tainting) */
  122303. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122304. /**
  122305. * Disposes of the post process
  122306. * @param camera Camera to dispose post process on
  122307. */
  122308. dispose(camera: Camera): void;
  122309. }
  122310. }
  122311. declare module BABYLON {
  122312. /** @hidden */
  122313. export var sharpenPixelShader: {
  122314. name: string;
  122315. shader: string;
  122316. };
  122317. }
  122318. declare module BABYLON {
  122319. /**
  122320. * The SharpenPostProcess applies a sharpen kernel to every pixel
  122321. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122322. */
  122323. export class SharpenPostProcess extends PostProcess {
  122324. /**
  122325. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  122326. */
  122327. colorAmount: number;
  122328. /**
  122329. * How much sharpness should be applied (default: 0.3)
  122330. */
  122331. edgeAmount: number;
  122332. /**
  122333. * Creates a new instance ConvolutionPostProcess
  122334. * @param name The name of the effect.
  122335. * @param options The required width/height ratio to downsize to before computing the render pass.
  122336. * @param camera The camera to apply the render pass to.
  122337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122338. * @param engine The engine which the post process will be applied. (default: current engine)
  122339. * @param reusable If the post process can be reused on the same frame. (default: false)
  122340. * @param textureType Type of textures used when performing the post process. (default: 0)
  122341. * @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)
  122342. */
  122343. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122344. }
  122345. }
  122346. declare module BABYLON {
  122347. /**
  122348. * PostProcessRenderPipeline
  122349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122350. */
  122351. export class PostProcessRenderPipeline {
  122352. private engine;
  122353. private _renderEffects;
  122354. private _renderEffectsForIsolatedPass;
  122355. /**
  122356. * List of inspectable custom properties (used by the Inspector)
  122357. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122358. */
  122359. inspectableCustomProperties: IInspectable[];
  122360. /**
  122361. * @hidden
  122362. */
  122363. protected _cameras: Camera[];
  122364. /** @hidden */
  122365. _name: string;
  122366. /**
  122367. * Gets pipeline name
  122368. */
  122369. readonly name: string;
  122370. /**
  122371. * Initializes a PostProcessRenderPipeline
  122372. * @param engine engine to add the pipeline to
  122373. * @param name name of the pipeline
  122374. */
  122375. constructor(engine: Engine, name: string);
  122376. /**
  122377. * Gets the class name
  122378. * @returns "PostProcessRenderPipeline"
  122379. */
  122380. getClassName(): string;
  122381. /**
  122382. * If all the render effects in the pipeline are supported
  122383. */
  122384. readonly isSupported: boolean;
  122385. /**
  122386. * Adds an effect to the pipeline
  122387. * @param renderEffect the effect to add
  122388. */
  122389. addEffect(renderEffect: PostProcessRenderEffect): void;
  122390. /** @hidden */
  122391. _rebuild(): void;
  122392. /** @hidden */
  122393. _enableEffect(renderEffectName: string, cameras: Camera): void;
  122394. /** @hidden */
  122395. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  122396. /** @hidden */
  122397. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122398. /** @hidden */
  122399. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  122400. /** @hidden */
  122401. _attachCameras(cameras: Camera, unique: boolean): void;
  122402. /** @hidden */
  122403. _attachCameras(cameras: Camera[], unique: boolean): void;
  122404. /** @hidden */
  122405. _detachCameras(cameras: Camera): void;
  122406. /** @hidden */
  122407. _detachCameras(cameras: Nullable<Camera[]>): void;
  122408. /** @hidden */
  122409. _update(): void;
  122410. /** @hidden */
  122411. _reset(): void;
  122412. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  122413. /**
  122414. * Disposes of the pipeline
  122415. */
  122416. dispose(): void;
  122417. }
  122418. }
  122419. declare module BABYLON {
  122420. /**
  122421. * PostProcessRenderPipelineManager class
  122422. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122423. */
  122424. export class PostProcessRenderPipelineManager {
  122425. private _renderPipelines;
  122426. /**
  122427. * Initializes a PostProcessRenderPipelineManager
  122428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122429. */
  122430. constructor();
  122431. /**
  122432. * Gets the list of supported render pipelines
  122433. */
  122434. readonly supportedPipelines: PostProcessRenderPipeline[];
  122435. /**
  122436. * Adds a pipeline to the manager
  122437. * @param renderPipeline The pipeline to add
  122438. */
  122439. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  122440. /**
  122441. * Attaches a camera to the pipeline
  122442. * @param renderPipelineName The name of the pipeline to attach to
  122443. * @param cameras the camera to attach
  122444. * @param unique if the camera can be attached multiple times to the pipeline
  122445. */
  122446. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  122447. /**
  122448. * Detaches a camera from the pipeline
  122449. * @param renderPipelineName The name of the pipeline to detach from
  122450. * @param cameras the camera to detach
  122451. */
  122452. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  122453. /**
  122454. * Enables an effect by name on a pipeline
  122455. * @param renderPipelineName the name of the pipeline to enable the effect in
  122456. * @param renderEffectName the name of the effect to enable
  122457. * @param cameras the cameras that the effect should be enabled on
  122458. */
  122459. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122460. /**
  122461. * Disables an effect by name on a pipeline
  122462. * @param renderPipelineName the name of the pipeline to disable the effect in
  122463. * @param renderEffectName the name of the effect to disable
  122464. * @param cameras the cameras that the effect should be disabled on
  122465. */
  122466. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  122467. /**
  122468. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122469. */
  122470. update(): void;
  122471. /** @hidden */
  122472. _rebuild(): void;
  122473. /**
  122474. * Disposes of the manager and pipelines
  122475. */
  122476. dispose(): void;
  122477. }
  122478. }
  122479. declare module BABYLON {
  122480. interface Scene {
  122481. /** @hidden (Backing field) */
  122482. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122483. /**
  122484. * Gets the postprocess render pipeline manager
  122485. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122486. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122487. */
  122488. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  122489. }
  122490. /**
  122491. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122492. */
  122493. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  122494. /**
  122495. * The component name helpfull to identify the component in the list of scene components.
  122496. */
  122497. readonly name: string;
  122498. /**
  122499. * The scene the component belongs to.
  122500. */
  122501. scene: Scene;
  122502. /**
  122503. * Creates a new instance of the component for the given scene
  122504. * @param scene Defines the scene to register the component in
  122505. */
  122506. constructor(scene: Scene);
  122507. /**
  122508. * Registers the component in a given scene
  122509. */
  122510. register(): void;
  122511. /**
  122512. * Rebuilds the elements related to this component in case of
  122513. * context lost for instance.
  122514. */
  122515. rebuild(): void;
  122516. /**
  122517. * Disposes the component and the associated ressources
  122518. */
  122519. dispose(): void;
  122520. private _gatherRenderTargets;
  122521. }
  122522. }
  122523. declare module BABYLON {
  122524. /**
  122525. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  122526. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  122527. */
  122528. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122529. private _scene;
  122530. private _camerasToBeAttached;
  122531. /**
  122532. * ID of the sharpen post process,
  122533. */
  122534. private readonly SharpenPostProcessId;
  122535. /**
  122536. * @ignore
  122537. * ID of the image processing post process;
  122538. */
  122539. readonly ImageProcessingPostProcessId: string;
  122540. /**
  122541. * @ignore
  122542. * ID of the Fast Approximate Anti-Aliasing post process;
  122543. */
  122544. readonly FxaaPostProcessId: string;
  122545. /**
  122546. * ID of the chromatic aberration post process,
  122547. */
  122548. private readonly ChromaticAberrationPostProcessId;
  122549. /**
  122550. * ID of the grain post process
  122551. */
  122552. private readonly GrainPostProcessId;
  122553. /**
  122554. * Sharpen post process which will apply a sharpen convolution to enhance edges
  122555. */
  122556. sharpen: SharpenPostProcess;
  122557. private _sharpenEffect;
  122558. private bloom;
  122559. /**
  122560. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  122561. */
  122562. depthOfField: DepthOfFieldEffect;
  122563. /**
  122564. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122565. */
  122566. fxaa: FxaaPostProcess;
  122567. /**
  122568. * Image post processing pass used to perform operations such as tone mapping or color grading.
  122569. */
  122570. imageProcessing: ImageProcessingPostProcess;
  122571. /**
  122572. * Chromatic aberration post process which will shift rgb colors in the image
  122573. */
  122574. chromaticAberration: ChromaticAberrationPostProcess;
  122575. private _chromaticAberrationEffect;
  122576. /**
  122577. * Grain post process which add noise to the image
  122578. */
  122579. grain: GrainPostProcess;
  122580. private _grainEffect;
  122581. /**
  122582. * Glow post process which adds a glow to emissive areas of the image
  122583. */
  122584. private _glowLayer;
  122585. /**
  122586. * Animations which can be used to tweak settings over a period of time
  122587. */
  122588. animations: Animation[];
  122589. private _imageProcessingConfigurationObserver;
  122590. private _sharpenEnabled;
  122591. private _bloomEnabled;
  122592. private _depthOfFieldEnabled;
  122593. private _depthOfFieldBlurLevel;
  122594. private _fxaaEnabled;
  122595. private _imageProcessingEnabled;
  122596. private _defaultPipelineTextureType;
  122597. private _bloomScale;
  122598. private _chromaticAberrationEnabled;
  122599. private _grainEnabled;
  122600. private _buildAllowed;
  122601. /**
  122602. * Gets active scene
  122603. */
  122604. readonly scene: Scene;
  122605. /**
  122606. * Enable or disable the sharpen process from the pipeline
  122607. */
  122608. sharpenEnabled: boolean;
  122609. private _resizeObserver;
  122610. private _hardwareScaleLevel;
  122611. private _bloomKernel;
  122612. /**
  122613. * Specifies the size of the bloom blur kernel, relative to the final output size
  122614. */
  122615. bloomKernel: number;
  122616. /**
  122617. * Specifies the weight of the bloom in the final rendering
  122618. */
  122619. private _bloomWeight;
  122620. /**
  122621. * Specifies the luma threshold for the area that will be blurred by the bloom
  122622. */
  122623. private _bloomThreshold;
  122624. private _hdr;
  122625. /**
  122626. * The strength of the bloom.
  122627. */
  122628. bloomWeight: number;
  122629. /**
  122630. * The strength of the bloom.
  122631. */
  122632. bloomThreshold: number;
  122633. /**
  122634. * The scale of the bloom, lower value will provide better performance.
  122635. */
  122636. bloomScale: number;
  122637. /**
  122638. * Enable or disable the bloom from the pipeline
  122639. */
  122640. bloomEnabled: boolean;
  122641. private _rebuildBloom;
  122642. /**
  122643. * If the depth of field is enabled.
  122644. */
  122645. depthOfFieldEnabled: boolean;
  122646. /**
  122647. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122648. */
  122649. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122650. /**
  122651. * If the anti aliasing is enabled.
  122652. */
  122653. fxaaEnabled: boolean;
  122654. private _samples;
  122655. /**
  122656. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122657. */
  122658. samples: number;
  122659. /**
  122660. * If image processing is enabled.
  122661. */
  122662. imageProcessingEnabled: boolean;
  122663. /**
  122664. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122665. */
  122666. glowLayerEnabled: boolean;
  122667. /**
  122668. * Gets the glow layer (or null if not defined)
  122669. */
  122670. readonly glowLayer: Nullable<GlowLayer>;
  122671. /**
  122672. * Enable or disable the chromaticAberration process from the pipeline
  122673. */
  122674. chromaticAberrationEnabled: boolean;
  122675. /**
  122676. * Enable or disable the grain process from the pipeline
  122677. */
  122678. grainEnabled: boolean;
  122679. /**
  122680. * @constructor
  122681. * @param name - The rendering pipeline name (default: "")
  122682. * @param hdr - If high dynamic range textures should be used (default: true)
  122683. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122684. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122685. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122686. */
  122687. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122688. /**
  122689. * Get the class name
  122690. * @returns "DefaultRenderingPipeline"
  122691. */
  122692. getClassName(): string;
  122693. /**
  122694. * Force the compilation of the entire pipeline.
  122695. */
  122696. prepare(): void;
  122697. private _hasCleared;
  122698. private _prevPostProcess;
  122699. private _prevPrevPostProcess;
  122700. private _setAutoClearAndTextureSharing;
  122701. private _depthOfFieldSceneObserver;
  122702. private _buildPipeline;
  122703. private _disposePostProcesses;
  122704. /**
  122705. * Adds a camera to the pipeline
  122706. * @param camera the camera to be added
  122707. */
  122708. addCamera(camera: Camera): void;
  122709. /**
  122710. * Removes a camera from the pipeline
  122711. * @param camera the camera to remove
  122712. */
  122713. removeCamera(camera: Camera): void;
  122714. /**
  122715. * Dispose of the pipeline and stop all post processes
  122716. */
  122717. dispose(): void;
  122718. /**
  122719. * Serialize the rendering pipeline (Used when exporting)
  122720. * @returns the serialized object
  122721. */
  122722. serialize(): any;
  122723. /**
  122724. * Parse the serialized pipeline
  122725. * @param source Source pipeline.
  122726. * @param scene The scene to load the pipeline to.
  122727. * @param rootUrl The URL of the serialized pipeline.
  122728. * @returns An instantiated pipeline from the serialized object.
  122729. */
  122730. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122731. }
  122732. }
  122733. declare module BABYLON {
  122734. /** @hidden */
  122735. export var lensHighlightsPixelShader: {
  122736. name: string;
  122737. shader: string;
  122738. };
  122739. }
  122740. declare module BABYLON {
  122741. /** @hidden */
  122742. export var depthOfFieldPixelShader: {
  122743. name: string;
  122744. shader: string;
  122745. };
  122746. }
  122747. declare module BABYLON {
  122748. /**
  122749. * BABYLON.JS Chromatic Aberration GLSL Shader
  122750. * Author: Olivier Guyot
  122751. * Separates very slightly R, G and B colors on the edges of the screen
  122752. * Inspired by Francois Tarlier & Martins Upitis
  122753. */
  122754. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  122755. /**
  122756. * @ignore
  122757. * The chromatic aberration PostProcess id in the pipeline
  122758. */
  122759. LensChromaticAberrationEffect: string;
  122760. /**
  122761. * @ignore
  122762. * The highlights enhancing PostProcess id in the pipeline
  122763. */
  122764. HighlightsEnhancingEffect: string;
  122765. /**
  122766. * @ignore
  122767. * The depth-of-field PostProcess id in the pipeline
  122768. */
  122769. LensDepthOfFieldEffect: string;
  122770. private _scene;
  122771. private _depthTexture;
  122772. private _grainTexture;
  122773. private _chromaticAberrationPostProcess;
  122774. private _highlightsPostProcess;
  122775. private _depthOfFieldPostProcess;
  122776. private _edgeBlur;
  122777. private _grainAmount;
  122778. private _chromaticAberration;
  122779. private _distortion;
  122780. private _highlightsGain;
  122781. private _highlightsThreshold;
  122782. private _dofDistance;
  122783. private _dofAperture;
  122784. private _dofDarken;
  122785. private _dofPentagon;
  122786. private _blurNoise;
  122787. /**
  122788. * @constructor
  122789. *
  122790. * Effect parameters are as follow:
  122791. * {
  122792. * chromatic_aberration: number; // from 0 to x (1 for realism)
  122793. * edge_blur: number; // from 0 to x (1 for realism)
  122794. * distortion: number; // from 0 to x (1 for realism)
  122795. * grain_amount: number; // from 0 to 1
  122796. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  122797. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  122798. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  122799. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  122800. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  122801. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  122802. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  122803. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  122804. * }
  122805. * Note: if an effect parameter is unset, effect is disabled
  122806. *
  122807. * @param name The rendering pipeline name
  122808. * @param parameters - An object containing all parameters (see above)
  122809. * @param scene The scene linked to this pipeline
  122810. * @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)
  122811. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122812. */
  122813. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  122814. /**
  122815. * Get the class name
  122816. * @returns "LensRenderingPipeline"
  122817. */
  122818. getClassName(): string;
  122819. /**
  122820. * Gets associated scene
  122821. */
  122822. readonly scene: Scene;
  122823. /**
  122824. * Gets or sets the edge blur
  122825. */
  122826. edgeBlur: number;
  122827. /**
  122828. * Gets or sets the grain amount
  122829. */
  122830. grainAmount: number;
  122831. /**
  122832. * Gets or sets the chromatic aberration amount
  122833. */
  122834. chromaticAberration: number;
  122835. /**
  122836. * Gets or sets the depth of field aperture
  122837. */
  122838. dofAperture: number;
  122839. /**
  122840. * Gets or sets the edge distortion
  122841. */
  122842. edgeDistortion: number;
  122843. /**
  122844. * Gets or sets the depth of field distortion
  122845. */
  122846. dofDistortion: number;
  122847. /**
  122848. * Gets or sets the darken out of focus amount
  122849. */
  122850. darkenOutOfFocus: number;
  122851. /**
  122852. * Gets or sets a boolean indicating if blur noise is enabled
  122853. */
  122854. blurNoise: boolean;
  122855. /**
  122856. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  122857. */
  122858. pentagonBokeh: boolean;
  122859. /**
  122860. * Gets or sets the highlight grain amount
  122861. */
  122862. highlightsGain: number;
  122863. /**
  122864. * Gets or sets the highlight threshold
  122865. */
  122866. highlightsThreshold: number;
  122867. /**
  122868. * Sets the amount of blur at the edges
  122869. * @param amount blur amount
  122870. */
  122871. setEdgeBlur(amount: number): void;
  122872. /**
  122873. * Sets edge blur to 0
  122874. */
  122875. disableEdgeBlur(): void;
  122876. /**
  122877. * Sets the amout of grain
  122878. * @param amount Amount of grain
  122879. */
  122880. setGrainAmount(amount: number): void;
  122881. /**
  122882. * Set grain amount to 0
  122883. */
  122884. disableGrain(): void;
  122885. /**
  122886. * Sets the chromatic aberration amount
  122887. * @param amount amount of chromatic aberration
  122888. */
  122889. setChromaticAberration(amount: number): void;
  122890. /**
  122891. * Sets chromatic aberration amount to 0
  122892. */
  122893. disableChromaticAberration(): void;
  122894. /**
  122895. * Sets the EdgeDistortion amount
  122896. * @param amount amount of EdgeDistortion
  122897. */
  122898. setEdgeDistortion(amount: number): void;
  122899. /**
  122900. * Sets edge distortion to 0
  122901. */
  122902. disableEdgeDistortion(): void;
  122903. /**
  122904. * Sets the FocusDistance amount
  122905. * @param amount amount of FocusDistance
  122906. */
  122907. setFocusDistance(amount: number): void;
  122908. /**
  122909. * Disables depth of field
  122910. */
  122911. disableDepthOfField(): void;
  122912. /**
  122913. * Sets the Aperture amount
  122914. * @param amount amount of Aperture
  122915. */
  122916. setAperture(amount: number): void;
  122917. /**
  122918. * Sets the DarkenOutOfFocus amount
  122919. * @param amount amount of DarkenOutOfFocus
  122920. */
  122921. setDarkenOutOfFocus(amount: number): void;
  122922. private _pentagonBokehIsEnabled;
  122923. /**
  122924. * Creates a pentagon bokeh effect
  122925. */
  122926. enablePentagonBokeh(): void;
  122927. /**
  122928. * Disables the pentagon bokeh effect
  122929. */
  122930. disablePentagonBokeh(): void;
  122931. /**
  122932. * Enables noise blur
  122933. */
  122934. enableNoiseBlur(): void;
  122935. /**
  122936. * Disables noise blur
  122937. */
  122938. disableNoiseBlur(): void;
  122939. /**
  122940. * Sets the HighlightsGain amount
  122941. * @param amount amount of HighlightsGain
  122942. */
  122943. setHighlightsGain(amount: number): void;
  122944. /**
  122945. * Sets the HighlightsThreshold amount
  122946. * @param amount amount of HighlightsThreshold
  122947. */
  122948. setHighlightsThreshold(amount: number): void;
  122949. /**
  122950. * Disables highlights
  122951. */
  122952. disableHighlights(): void;
  122953. /**
  122954. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122955. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122956. */
  122957. dispose(disableDepthRender?: boolean): void;
  122958. private _createChromaticAberrationPostProcess;
  122959. private _createHighlightsPostProcess;
  122960. private _createDepthOfFieldPostProcess;
  122961. private _createGrainTexture;
  122962. }
  122963. }
  122964. declare module BABYLON {
  122965. /** @hidden */
  122966. export var ssao2PixelShader: {
  122967. name: string;
  122968. shader: string;
  122969. };
  122970. }
  122971. declare module BABYLON {
  122972. /** @hidden */
  122973. export var ssaoCombinePixelShader: {
  122974. name: string;
  122975. shader: string;
  122976. };
  122977. }
  122978. declare module BABYLON {
  122979. /**
  122980. * Render pipeline to produce ssao effect
  122981. */
  122982. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  122983. /**
  122984. * @ignore
  122985. * The PassPostProcess id in the pipeline that contains the original scene color
  122986. */
  122987. SSAOOriginalSceneColorEffect: string;
  122988. /**
  122989. * @ignore
  122990. * The SSAO PostProcess id in the pipeline
  122991. */
  122992. SSAORenderEffect: string;
  122993. /**
  122994. * @ignore
  122995. * The horizontal blur PostProcess id in the pipeline
  122996. */
  122997. SSAOBlurHRenderEffect: string;
  122998. /**
  122999. * @ignore
  123000. * The vertical blur PostProcess id in the pipeline
  123001. */
  123002. SSAOBlurVRenderEffect: string;
  123003. /**
  123004. * @ignore
  123005. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123006. */
  123007. SSAOCombineRenderEffect: string;
  123008. /**
  123009. * The output strength of the SSAO post-process. Default value is 1.0.
  123010. */
  123011. totalStrength: number;
  123012. /**
  123013. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123014. */
  123015. maxZ: number;
  123016. /**
  123017. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123018. */
  123019. minZAspect: number;
  123020. private _samples;
  123021. /**
  123022. * Number of samples used for the SSAO calculations. Default value is 8
  123023. */
  123024. samples: number;
  123025. private _textureSamples;
  123026. /**
  123027. * Number of samples to use for antialiasing
  123028. */
  123029. textureSamples: number;
  123030. /**
  123031. * Ratio object used for SSAO ratio and blur ratio
  123032. */
  123033. private _ratio;
  123034. /**
  123035. * Dynamically generated sphere sampler.
  123036. */
  123037. private _sampleSphere;
  123038. /**
  123039. * Blur filter offsets
  123040. */
  123041. private _samplerOffsets;
  123042. private _expensiveBlur;
  123043. /**
  123044. * If bilateral blur should be used
  123045. */
  123046. expensiveBlur: boolean;
  123047. /**
  123048. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123049. */
  123050. radius: number;
  123051. /**
  123052. * The base color of the SSAO post-process
  123053. * The final result is "base + ssao" between [0, 1]
  123054. */
  123055. base: number;
  123056. /**
  123057. * Support test.
  123058. */
  123059. static readonly IsSupported: boolean;
  123060. private _scene;
  123061. private _depthTexture;
  123062. private _normalTexture;
  123063. private _randomTexture;
  123064. private _originalColorPostProcess;
  123065. private _ssaoPostProcess;
  123066. private _blurHPostProcess;
  123067. private _blurVPostProcess;
  123068. private _ssaoCombinePostProcess;
  123069. private _firstUpdate;
  123070. /**
  123071. * Gets active scene
  123072. */
  123073. readonly scene: Scene;
  123074. /**
  123075. * @constructor
  123076. * @param name The rendering pipeline name
  123077. * @param scene The scene linked to this pipeline
  123078. * @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 }
  123079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123080. */
  123081. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123082. /**
  123083. * Get the class name
  123084. * @returns "SSAO2RenderingPipeline"
  123085. */
  123086. getClassName(): string;
  123087. /**
  123088. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123089. */
  123090. dispose(disableGeometryBufferRenderer?: boolean): void;
  123091. private _createBlurPostProcess;
  123092. /** @hidden */
  123093. _rebuild(): void;
  123094. private _bits;
  123095. private _radicalInverse_VdC;
  123096. private _hammersley;
  123097. private _hemisphereSample_uniform;
  123098. private _generateHemisphere;
  123099. private _createSSAOPostProcess;
  123100. private _createSSAOCombinePostProcess;
  123101. private _createRandomTexture;
  123102. /**
  123103. * Serialize the rendering pipeline (Used when exporting)
  123104. * @returns the serialized object
  123105. */
  123106. serialize(): any;
  123107. /**
  123108. * Parse the serialized pipeline
  123109. * @param source Source pipeline.
  123110. * @param scene The scene to load the pipeline to.
  123111. * @param rootUrl The URL of the serialized pipeline.
  123112. * @returns An instantiated pipeline from the serialized object.
  123113. */
  123114. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123115. }
  123116. }
  123117. declare module BABYLON {
  123118. /** @hidden */
  123119. export var ssaoPixelShader: {
  123120. name: string;
  123121. shader: string;
  123122. };
  123123. }
  123124. declare module BABYLON {
  123125. /**
  123126. * Render pipeline to produce ssao effect
  123127. */
  123128. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  123129. /**
  123130. * @ignore
  123131. * The PassPostProcess id in the pipeline that contains the original scene color
  123132. */
  123133. SSAOOriginalSceneColorEffect: string;
  123134. /**
  123135. * @ignore
  123136. * The SSAO PostProcess id in the pipeline
  123137. */
  123138. SSAORenderEffect: string;
  123139. /**
  123140. * @ignore
  123141. * The horizontal blur PostProcess id in the pipeline
  123142. */
  123143. SSAOBlurHRenderEffect: string;
  123144. /**
  123145. * @ignore
  123146. * The vertical blur PostProcess id in the pipeline
  123147. */
  123148. SSAOBlurVRenderEffect: string;
  123149. /**
  123150. * @ignore
  123151. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123152. */
  123153. SSAOCombineRenderEffect: string;
  123154. /**
  123155. * The output strength of the SSAO post-process. Default value is 1.0.
  123156. */
  123157. totalStrength: number;
  123158. /**
  123159. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  123160. */
  123161. radius: number;
  123162. /**
  123163. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  123164. * Must not be equal to fallOff and superior to fallOff.
  123165. * Default value is 0.0075
  123166. */
  123167. area: number;
  123168. /**
  123169. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  123170. * Must not be equal to area and inferior to area.
  123171. * Default value is 0.000001
  123172. */
  123173. fallOff: number;
  123174. /**
  123175. * The base color of the SSAO post-process
  123176. * The final result is "base + ssao" between [0, 1]
  123177. */
  123178. base: number;
  123179. private _scene;
  123180. private _depthTexture;
  123181. private _randomTexture;
  123182. private _originalColorPostProcess;
  123183. private _ssaoPostProcess;
  123184. private _blurHPostProcess;
  123185. private _blurVPostProcess;
  123186. private _ssaoCombinePostProcess;
  123187. private _firstUpdate;
  123188. /**
  123189. * Gets active scene
  123190. */
  123191. readonly scene: Scene;
  123192. /**
  123193. * @constructor
  123194. * @param name - The rendering pipeline name
  123195. * @param scene - The scene linked to this pipeline
  123196. * @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 }
  123197. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  123198. */
  123199. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123200. /**
  123201. * Get the class name
  123202. * @returns "SSAORenderingPipeline"
  123203. */
  123204. getClassName(): string;
  123205. /**
  123206. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123207. */
  123208. dispose(disableDepthRender?: boolean): void;
  123209. private _createBlurPostProcess;
  123210. /** @hidden */
  123211. _rebuild(): void;
  123212. private _createSSAOPostProcess;
  123213. private _createSSAOCombinePostProcess;
  123214. private _createRandomTexture;
  123215. }
  123216. }
  123217. declare module BABYLON {
  123218. /** @hidden */
  123219. export var standardPixelShader: {
  123220. name: string;
  123221. shader: string;
  123222. };
  123223. }
  123224. declare module BABYLON {
  123225. /**
  123226. * Standard rendering pipeline
  123227. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123228. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  123229. */
  123230. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123231. /**
  123232. * Public members
  123233. */
  123234. /**
  123235. * Post-process which contains the original scene color before the pipeline applies all the effects
  123236. */
  123237. originalPostProcess: Nullable<PostProcess>;
  123238. /**
  123239. * Post-process used to down scale an image x4
  123240. */
  123241. downSampleX4PostProcess: Nullable<PostProcess>;
  123242. /**
  123243. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  123244. */
  123245. brightPassPostProcess: Nullable<PostProcess>;
  123246. /**
  123247. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  123248. */
  123249. blurHPostProcesses: PostProcess[];
  123250. /**
  123251. * Post-process array storing all the vertical blur post-processes used by the pipeline
  123252. */
  123253. blurVPostProcesses: PostProcess[];
  123254. /**
  123255. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  123256. */
  123257. textureAdderPostProcess: Nullable<PostProcess>;
  123258. /**
  123259. * Post-process used to create volumetric lighting effect
  123260. */
  123261. volumetricLightPostProcess: Nullable<PostProcess>;
  123262. /**
  123263. * Post-process used to smooth the previous volumetric light post-process on the X axis
  123264. */
  123265. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  123266. /**
  123267. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  123268. */
  123269. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  123270. /**
  123271. * Post-process used to merge the volumetric light effect and the real scene color
  123272. */
  123273. volumetricLightMergePostProces: Nullable<PostProcess>;
  123274. /**
  123275. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  123276. */
  123277. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  123278. /**
  123279. * Base post-process used to calculate the average luminance of the final image for HDR
  123280. */
  123281. luminancePostProcess: Nullable<PostProcess>;
  123282. /**
  123283. * Post-processes used to create down sample post-processes in order to get
  123284. * the average luminance of the final image for HDR
  123285. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  123286. */
  123287. luminanceDownSamplePostProcesses: PostProcess[];
  123288. /**
  123289. * Post-process used to create a HDR effect (light adaptation)
  123290. */
  123291. hdrPostProcess: Nullable<PostProcess>;
  123292. /**
  123293. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  123294. */
  123295. textureAdderFinalPostProcess: Nullable<PostProcess>;
  123296. /**
  123297. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  123298. */
  123299. lensFlareFinalPostProcess: Nullable<PostProcess>;
  123300. /**
  123301. * Post-process used to merge the final HDR post-process and the real scene color
  123302. */
  123303. hdrFinalPostProcess: Nullable<PostProcess>;
  123304. /**
  123305. * Post-process used to create a lens flare effect
  123306. */
  123307. lensFlarePostProcess: Nullable<PostProcess>;
  123308. /**
  123309. * Post-process that merges the result of the lens flare post-process and the real scene color
  123310. */
  123311. lensFlareComposePostProcess: Nullable<PostProcess>;
  123312. /**
  123313. * Post-process used to create a motion blur effect
  123314. */
  123315. motionBlurPostProcess: Nullable<PostProcess>;
  123316. /**
  123317. * Post-process used to create a depth of field effect
  123318. */
  123319. depthOfFieldPostProcess: Nullable<PostProcess>;
  123320. /**
  123321. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123322. */
  123323. fxaaPostProcess: Nullable<FxaaPostProcess>;
  123324. /**
  123325. * Represents the brightness threshold in order to configure the illuminated surfaces
  123326. */
  123327. brightThreshold: number;
  123328. /**
  123329. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  123330. */
  123331. blurWidth: number;
  123332. /**
  123333. * Sets if the blur for highlighted surfaces must be only horizontal
  123334. */
  123335. horizontalBlur: boolean;
  123336. /**
  123337. * Gets the overall exposure used by the pipeline
  123338. */
  123339. /**
  123340. * Sets the overall exposure used by the pipeline
  123341. */
  123342. exposure: number;
  123343. /**
  123344. * Texture used typically to simulate "dirty" on camera lens
  123345. */
  123346. lensTexture: Nullable<Texture>;
  123347. /**
  123348. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  123349. */
  123350. volumetricLightCoefficient: number;
  123351. /**
  123352. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  123353. */
  123354. volumetricLightPower: number;
  123355. /**
  123356. * Used the set the blur intensity to smooth the volumetric lights
  123357. */
  123358. volumetricLightBlurScale: number;
  123359. /**
  123360. * Light (spot or directional) used to generate the volumetric lights rays
  123361. * The source light must have a shadow generate so the pipeline can get its
  123362. * depth map
  123363. */
  123364. sourceLight: Nullable<SpotLight | DirectionalLight>;
  123365. /**
  123366. * For eye adaptation, represents the minimum luminance the eye can see
  123367. */
  123368. hdrMinimumLuminance: number;
  123369. /**
  123370. * For eye adaptation, represents the decrease luminance speed
  123371. */
  123372. hdrDecreaseRate: number;
  123373. /**
  123374. * For eye adaptation, represents the increase luminance speed
  123375. */
  123376. hdrIncreaseRate: number;
  123377. /**
  123378. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123379. */
  123380. /**
  123381. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  123382. */
  123383. hdrAutoExposure: boolean;
  123384. /**
  123385. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  123386. */
  123387. lensColorTexture: Nullable<Texture>;
  123388. /**
  123389. * The overall strengh for the lens flare effect
  123390. */
  123391. lensFlareStrength: number;
  123392. /**
  123393. * Dispersion coefficient for lens flare ghosts
  123394. */
  123395. lensFlareGhostDispersal: number;
  123396. /**
  123397. * Main lens flare halo width
  123398. */
  123399. lensFlareHaloWidth: number;
  123400. /**
  123401. * Based on the lens distortion effect, defines how much the lens flare result
  123402. * is distorted
  123403. */
  123404. lensFlareDistortionStrength: number;
  123405. /**
  123406. * Lens star texture must be used to simulate rays on the flares and is available
  123407. * in the documentation
  123408. */
  123409. lensStarTexture: Nullable<Texture>;
  123410. /**
  123411. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  123412. * flare effect by taking account of the dirt texture
  123413. */
  123414. lensFlareDirtTexture: Nullable<Texture>;
  123415. /**
  123416. * Represents the focal length for the depth of field effect
  123417. */
  123418. depthOfFieldDistance: number;
  123419. /**
  123420. * Represents the blur intensity for the blurred part of the depth of field effect
  123421. */
  123422. depthOfFieldBlurWidth: number;
  123423. /**
  123424. * Gets how much the image is blurred by the movement while using the motion blur post-process
  123425. */
  123426. /**
  123427. * Sets how much the image is blurred by the movement while using the motion blur post-process
  123428. */
  123429. motionStrength: number;
  123430. /**
  123431. * Gets wether or not the motion blur post-process is object based or screen based.
  123432. */
  123433. /**
  123434. * Sets wether or not the motion blur post-process should be object based or screen based
  123435. */
  123436. objectBasedMotionBlur: boolean;
  123437. /**
  123438. * List of animations for the pipeline (IAnimatable implementation)
  123439. */
  123440. animations: Animation[];
  123441. /**
  123442. * Private members
  123443. */
  123444. private _scene;
  123445. private _currentDepthOfFieldSource;
  123446. private _basePostProcess;
  123447. private _fixedExposure;
  123448. private _currentExposure;
  123449. private _hdrAutoExposure;
  123450. private _hdrCurrentLuminance;
  123451. private _motionStrength;
  123452. private _isObjectBasedMotionBlur;
  123453. private _floatTextureType;
  123454. private _ratio;
  123455. private _bloomEnabled;
  123456. private _depthOfFieldEnabled;
  123457. private _vlsEnabled;
  123458. private _lensFlareEnabled;
  123459. private _hdrEnabled;
  123460. private _motionBlurEnabled;
  123461. private _fxaaEnabled;
  123462. private _motionBlurSamples;
  123463. private _volumetricLightStepsCount;
  123464. private _samples;
  123465. /**
  123466. * @ignore
  123467. * Specifies if the bloom pipeline is enabled
  123468. */
  123469. BloomEnabled: boolean;
  123470. /**
  123471. * @ignore
  123472. * Specifies if the depth of field pipeline is enabed
  123473. */
  123474. DepthOfFieldEnabled: boolean;
  123475. /**
  123476. * @ignore
  123477. * Specifies if the lens flare pipeline is enabed
  123478. */
  123479. LensFlareEnabled: boolean;
  123480. /**
  123481. * @ignore
  123482. * Specifies if the HDR pipeline is enabled
  123483. */
  123484. HDREnabled: boolean;
  123485. /**
  123486. * @ignore
  123487. * Specifies if the volumetric lights scattering effect is enabled
  123488. */
  123489. VLSEnabled: boolean;
  123490. /**
  123491. * @ignore
  123492. * Specifies if the motion blur effect is enabled
  123493. */
  123494. MotionBlurEnabled: boolean;
  123495. /**
  123496. * Specifies if anti-aliasing is enabled
  123497. */
  123498. fxaaEnabled: boolean;
  123499. /**
  123500. * Specifies the number of steps used to calculate the volumetric lights
  123501. * Typically in interval [50, 200]
  123502. */
  123503. volumetricLightStepsCount: number;
  123504. /**
  123505. * Specifies the number of samples used for the motion blur effect
  123506. * Typically in interval [16, 64]
  123507. */
  123508. motionBlurSamples: number;
  123509. /**
  123510. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123511. */
  123512. samples: number;
  123513. /**
  123514. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  123515. * @constructor
  123516. * @param name The rendering pipeline name
  123517. * @param scene The scene linked to this pipeline
  123518. * @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)
  123519. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  123520. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123521. */
  123522. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  123523. private _buildPipeline;
  123524. private _createDownSampleX4PostProcess;
  123525. private _createBrightPassPostProcess;
  123526. private _createBlurPostProcesses;
  123527. private _createTextureAdderPostProcess;
  123528. private _createVolumetricLightPostProcess;
  123529. private _createLuminancePostProcesses;
  123530. private _createHdrPostProcess;
  123531. private _createLensFlarePostProcess;
  123532. private _createDepthOfFieldPostProcess;
  123533. private _createMotionBlurPostProcess;
  123534. private _getDepthTexture;
  123535. private _disposePostProcesses;
  123536. /**
  123537. * Dispose of the pipeline and stop all post processes
  123538. */
  123539. dispose(): void;
  123540. /**
  123541. * Serialize the rendering pipeline (Used when exporting)
  123542. * @returns the serialized object
  123543. */
  123544. serialize(): any;
  123545. /**
  123546. * Parse the serialized pipeline
  123547. * @param source Source pipeline.
  123548. * @param scene The scene to load the pipeline to.
  123549. * @param rootUrl The URL of the serialized pipeline.
  123550. * @returns An instantiated pipeline from the serialized object.
  123551. */
  123552. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  123553. /**
  123554. * Luminance steps
  123555. */
  123556. static LuminanceSteps: number;
  123557. }
  123558. }
  123559. declare module BABYLON {
  123560. /** @hidden */
  123561. export var tonemapPixelShader: {
  123562. name: string;
  123563. shader: string;
  123564. };
  123565. }
  123566. declare module BABYLON {
  123567. /** Defines operator used for tonemapping */
  123568. export enum TonemappingOperator {
  123569. /** Hable */
  123570. Hable = 0,
  123571. /** Reinhard */
  123572. Reinhard = 1,
  123573. /** HejiDawson */
  123574. HejiDawson = 2,
  123575. /** Photographic */
  123576. Photographic = 3
  123577. }
  123578. /**
  123579. * Defines a post process to apply tone mapping
  123580. */
  123581. export class TonemapPostProcess extends PostProcess {
  123582. private _operator;
  123583. /** Defines the required exposure adjustement */
  123584. exposureAdjustment: number;
  123585. /**
  123586. * Creates a new TonemapPostProcess
  123587. * @param name defines the name of the postprocess
  123588. * @param _operator defines the operator to use
  123589. * @param exposureAdjustment defines the required exposure adjustement
  123590. * @param camera defines the camera to use (can be null)
  123591. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123592. * @param engine defines the hosting engine (can be ignore if camera is set)
  123593. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123594. */
  123595. constructor(name: string, _operator: TonemappingOperator,
  123596. /** Defines the required exposure adjustement */
  123597. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  123598. }
  123599. }
  123600. declare module BABYLON {
  123601. /** @hidden */
  123602. export var depthVertexShader: {
  123603. name: string;
  123604. shader: string;
  123605. };
  123606. }
  123607. declare module BABYLON {
  123608. /** @hidden */
  123609. export var volumetricLightScatteringPixelShader: {
  123610. name: string;
  123611. shader: string;
  123612. };
  123613. }
  123614. declare module BABYLON {
  123615. /** @hidden */
  123616. export var volumetricLightScatteringPassVertexShader: {
  123617. name: string;
  123618. shader: string;
  123619. };
  123620. }
  123621. declare module BABYLON {
  123622. /** @hidden */
  123623. export var volumetricLightScatteringPassPixelShader: {
  123624. name: string;
  123625. shader: string;
  123626. };
  123627. }
  123628. declare module BABYLON {
  123629. /**
  123630. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123631. */
  123632. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123633. private _volumetricLightScatteringPass;
  123634. private _volumetricLightScatteringRTT;
  123635. private _viewPort;
  123636. private _screenCoordinates;
  123637. private _cachedDefines;
  123638. /**
  123639. * If not undefined, the mesh position is computed from the attached node position
  123640. */
  123641. attachedNode: {
  123642. position: Vector3;
  123643. };
  123644. /**
  123645. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123646. */
  123647. customMeshPosition: Vector3;
  123648. /**
  123649. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123650. */
  123651. useCustomMeshPosition: boolean;
  123652. /**
  123653. * If the post-process should inverse the light scattering direction
  123654. */
  123655. invert: boolean;
  123656. /**
  123657. * The internal mesh used by the post-process
  123658. */
  123659. mesh: Mesh;
  123660. /**
  123661. * @hidden
  123662. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123663. */
  123664. useDiffuseColor: boolean;
  123665. /**
  123666. * Array containing the excluded meshes not rendered in the internal pass
  123667. */
  123668. excludedMeshes: AbstractMesh[];
  123669. /**
  123670. * Controls the overall intensity of the post-process
  123671. */
  123672. exposure: number;
  123673. /**
  123674. * Dissipates each sample's contribution in range [0, 1]
  123675. */
  123676. decay: number;
  123677. /**
  123678. * Controls the overall intensity of each sample
  123679. */
  123680. weight: number;
  123681. /**
  123682. * Controls the density of each sample
  123683. */
  123684. density: number;
  123685. /**
  123686. * @constructor
  123687. * @param name The post-process name
  123688. * @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)
  123689. * @param camera The camera that the post-process will be attached to
  123690. * @param mesh The mesh used to create the light scattering
  123691. * @param samples The post-process quality, default 100
  123692. * @param samplingModeThe post-process filtering mode
  123693. * @param engine The babylon engine
  123694. * @param reusable If the post-process is reusable
  123695. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123696. */
  123697. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123698. /**
  123699. * Returns the string "VolumetricLightScatteringPostProcess"
  123700. * @returns "VolumetricLightScatteringPostProcess"
  123701. */
  123702. getClassName(): string;
  123703. private _isReady;
  123704. /**
  123705. * Sets the new light position for light scattering effect
  123706. * @param position The new custom light position
  123707. */
  123708. setCustomMeshPosition(position: Vector3): void;
  123709. /**
  123710. * Returns the light position for light scattering effect
  123711. * @return Vector3 The custom light position
  123712. */
  123713. getCustomMeshPosition(): Vector3;
  123714. /**
  123715. * Disposes the internal assets and detaches the post-process from the camera
  123716. */
  123717. dispose(camera: Camera): void;
  123718. /**
  123719. * Returns the render target texture used by the post-process
  123720. * @return the render target texture used by the post-process
  123721. */
  123722. getPass(): RenderTargetTexture;
  123723. private _meshExcluded;
  123724. private _createPass;
  123725. private _updateMeshScreenCoordinates;
  123726. /**
  123727. * Creates a default mesh for the Volumeric Light Scattering post-process
  123728. * @param name The mesh name
  123729. * @param scene The scene where to create the mesh
  123730. * @return the default mesh
  123731. */
  123732. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123733. }
  123734. }
  123735. declare module BABYLON {
  123736. interface Scene {
  123737. /** @hidden (Backing field) */
  123738. _boundingBoxRenderer: BoundingBoxRenderer;
  123739. /** @hidden (Backing field) */
  123740. _forceShowBoundingBoxes: boolean;
  123741. /**
  123742. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123743. */
  123744. forceShowBoundingBoxes: boolean;
  123745. /**
  123746. * Gets the bounding box renderer associated with the scene
  123747. * @returns a BoundingBoxRenderer
  123748. */
  123749. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123750. }
  123751. interface AbstractMesh {
  123752. /** @hidden (Backing field) */
  123753. _showBoundingBox: boolean;
  123754. /**
  123755. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  123756. */
  123757. showBoundingBox: boolean;
  123758. }
  123759. /**
  123760. * Component responsible of rendering the bounding box of the meshes in a scene.
  123761. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  123762. */
  123763. export class BoundingBoxRenderer implements ISceneComponent {
  123764. /**
  123765. * The component name helpfull to identify the component in the list of scene components.
  123766. */
  123767. readonly name: string;
  123768. /**
  123769. * The scene the component belongs to.
  123770. */
  123771. scene: Scene;
  123772. /**
  123773. * Color of the bounding box lines placed in front of an object
  123774. */
  123775. frontColor: Color3;
  123776. /**
  123777. * Color of the bounding box lines placed behind an object
  123778. */
  123779. backColor: Color3;
  123780. /**
  123781. * Defines if the renderer should show the back lines or not
  123782. */
  123783. showBackLines: boolean;
  123784. /**
  123785. * @hidden
  123786. */
  123787. renderList: SmartArray<BoundingBox>;
  123788. private _colorShader;
  123789. private _vertexBuffers;
  123790. private _indexBuffer;
  123791. private _fillIndexBuffer;
  123792. private _fillIndexData;
  123793. /**
  123794. * Instantiates a new bounding box renderer in a scene.
  123795. * @param scene the scene the renderer renders in
  123796. */
  123797. constructor(scene: Scene);
  123798. /**
  123799. * Registers the component in a given scene
  123800. */
  123801. register(): void;
  123802. private _evaluateSubMesh;
  123803. private _activeMesh;
  123804. private _prepareRessources;
  123805. private _createIndexBuffer;
  123806. /**
  123807. * Rebuilds the elements related to this component in case of
  123808. * context lost for instance.
  123809. */
  123810. rebuild(): void;
  123811. /**
  123812. * @hidden
  123813. */
  123814. reset(): void;
  123815. /**
  123816. * Render the bounding boxes of a specific rendering group
  123817. * @param renderingGroupId defines the rendering group to render
  123818. */
  123819. render(renderingGroupId: number): void;
  123820. /**
  123821. * In case of occlusion queries, we can render the occlusion bounding box through this method
  123822. * @param mesh Define the mesh to render the occlusion bounding box for
  123823. */
  123824. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  123825. /**
  123826. * Dispose and release the resources attached to this renderer.
  123827. */
  123828. dispose(): void;
  123829. }
  123830. }
  123831. declare module BABYLON {
  123832. /** @hidden */
  123833. export var depthPixelShader: {
  123834. name: string;
  123835. shader: string;
  123836. };
  123837. }
  123838. declare module BABYLON {
  123839. /**
  123840. * This represents a depth renderer in Babylon.
  123841. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  123842. */
  123843. export class DepthRenderer {
  123844. private _scene;
  123845. private _depthMap;
  123846. private _effect;
  123847. private readonly _storeNonLinearDepth;
  123848. private readonly _clearColor;
  123849. /** Get if the depth renderer is using packed depth or not */
  123850. readonly isPacked: boolean;
  123851. private _cachedDefines;
  123852. private _camera;
  123853. /**
  123854. * Specifiess that the depth renderer will only be used within
  123855. * the camera it is created for.
  123856. * This can help forcing its rendering during the camera processing.
  123857. */
  123858. useOnlyInActiveCamera: boolean;
  123859. /** @hidden */
  123860. static _SceneComponentInitialization: (scene: Scene) => void;
  123861. /**
  123862. * Instantiates a depth renderer
  123863. * @param scene The scene the renderer belongs to
  123864. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  123865. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  123866. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123867. */
  123868. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  123869. /**
  123870. * Creates the depth rendering effect and checks if the effect is ready.
  123871. * @param subMesh The submesh to be used to render the depth map of
  123872. * @param useInstances If multiple world instances should be used
  123873. * @returns if the depth renderer is ready to render the depth map
  123874. */
  123875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123876. /**
  123877. * Gets the texture which the depth map will be written to.
  123878. * @returns The depth map texture
  123879. */
  123880. getDepthMap(): RenderTargetTexture;
  123881. /**
  123882. * Disposes of the depth renderer.
  123883. */
  123884. dispose(): void;
  123885. }
  123886. }
  123887. declare module BABYLON {
  123888. interface Scene {
  123889. /** @hidden (Backing field) */
  123890. _depthRenderer: {
  123891. [id: string]: DepthRenderer;
  123892. };
  123893. /**
  123894. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  123895. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  123896. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123897. * @returns the created depth renderer
  123898. */
  123899. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  123900. /**
  123901. * Disables a depth renderer for a given camera
  123902. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  123903. */
  123904. disableDepthRenderer(camera?: Nullable<Camera>): void;
  123905. }
  123906. /**
  123907. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  123908. * in several rendering techniques.
  123909. */
  123910. export class DepthRendererSceneComponent implements ISceneComponent {
  123911. /**
  123912. * The component name helpfull to identify the component in the list of scene components.
  123913. */
  123914. readonly name: string;
  123915. /**
  123916. * The scene the component belongs to.
  123917. */
  123918. scene: Scene;
  123919. /**
  123920. * Creates a new instance of the component for the given scene
  123921. * @param scene Defines the scene to register the component in
  123922. */
  123923. constructor(scene: Scene);
  123924. /**
  123925. * Registers the component in a given scene
  123926. */
  123927. register(): void;
  123928. /**
  123929. * Rebuilds the elements related to this component in case of
  123930. * context lost for instance.
  123931. */
  123932. rebuild(): void;
  123933. /**
  123934. * Disposes the component and the associated ressources
  123935. */
  123936. dispose(): void;
  123937. private _gatherRenderTargets;
  123938. private _gatherActiveCameraRenderTargets;
  123939. }
  123940. }
  123941. declare module BABYLON {
  123942. /** @hidden */
  123943. export var outlinePixelShader: {
  123944. name: string;
  123945. shader: string;
  123946. };
  123947. }
  123948. declare module BABYLON {
  123949. /** @hidden */
  123950. export var outlineVertexShader: {
  123951. name: string;
  123952. shader: string;
  123953. };
  123954. }
  123955. declare module BABYLON {
  123956. interface Scene {
  123957. /** @hidden */
  123958. _outlineRenderer: OutlineRenderer;
  123959. /**
  123960. * Gets the outline renderer associated with the scene
  123961. * @returns a OutlineRenderer
  123962. */
  123963. getOutlineRenderer(): OutlineRenderer;
  123964. }
  123965. interface AbstractMesh {
  123966. /** @hidden (Backing field) */
  123967. _renderOutline: boolean;
  123968. /**
  123969. * Gets or sets a boolean indicating if the outline must be rendered as well
  123970. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  123971. */
  123972. renderOutline: boolean;
  123973. /** @hidden (Backing field) */
  123974. _renderOverlay: boolean;
  123975. /**
  123976. * Gets or sets a boolean indicating if the overlay must be rendered as well
  123977. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  123978. */
  123979. renderOverlay: boolean;
  123980. }
  123981. /**
  123982. * This class is responsible to draw bothe outline/overlay of meshes.
  123983. * It should not be used directly but through the available method on mesh.
  123984. */
  123985. export class OutlineRenderer implements ISceneComponent {
  123986. /**
  123987. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  123988. */
  123989. private static _StencilReference;
  123990. /**
  123991. * The name of the component. Each component must have a unique name.
  123992. */
  123993. name: string;
  123994. /**
  123995. * The scene the component belongs to.
  123996. */
  123997. scene: Scene;
  123998. /**
  123999. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124000. */
  124001. zOffset: number;
  124002. private _engine;
  124003. private _effect;
  124004. private _cachedDefines;
  124005. private _savedDepthWrite;
  124006. /**
  124007. * Instantiates a new outline renderer. (There could be only one per scene).
  124008. * @param scene Defines the scene it belongs to
  124009. */
  124010. constructor(scene: Scene);
  124011. /**
  124012. * Register the component to one instance of a scene.
  124013. */
  124014. register(): void;
  124015. /**
  124016. * Rebuilds the elements related to this component in case of
  124017. * context lost for instance.
  124018. */
  124019. rebuild(): void;
  124020. /**
  124021. * Disposes the component and the associated ressources.
  124022. */
  124023. dispose(): void;
  124024. /**
  124025. * Renders the outline in the canvas.
  124026. * @param subMesh Defines the sumesh to render
  124027. * @param batch Defines the batch of meshes in case of instances
  124028. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124029. */
  124030. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124031. /**
  124032. * Returns whether or not the outline renderer is ready for a given submesh.
  124033. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124034. * @param subMesh Defines the submesh to check readyness for
  124035. * @param useInstances Defines wheter wee are trying to render instances or not
  124036. * @returns true if ready otherwise false
  124037. */
  124038. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124039. private _beforeRenderingMesh;
  124040. private _afterRenderingMesh;
  124041. }
  124042. }
  124043. declare module BABYLON {
  124044. /**
  124045. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124046. * @see http://doc.babylonjs.com/babylon101/sprites
  124047. */
  124048. export class SpritePackedManager extends SpriteManager {
  124049. /** defines the packed manager's name */
  124050. name: string;
  124051. /**
  124052. * Creates a new sprite manager from a packed sprite sheet
  124053. * @param name defines the manager's name
  124054. * @param imgUrl defines the sprite sheet url
  124055. * @param capacity defines the maximum allowed number of sprites
  124056. * @param scene defines the hosting scene
  124057. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124058. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124059. * @param samplingMode defines the smapling mode to use with spritesheet
  124060. * @param fromPacked set to true; do not alter
  124061. */
  124062. constructor(
  124063. /** defines the packed manager's name */
  124064. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124065. }
  124066. }
  124067. declare module BABYLON {
  124068. /**
  124069. * Defines the list of states available for a task inside a AssetsManager
  124070. */
  124071. export enum AssetTaskState {
  124072. /**
  124073. * Initialization
  124074. */
  124075. INIT = 0,
  124076. /**
  124077. * Running
  124078. */
  124079. RUNNING = 1,
  124080. /**
  124081. * Done
  124082. */
  124083. DONE = 2,
  124084. /**
  124085. * Error
  124086. */
  124087. ERROR = 3
  124088. }
  124089. /**
  124090. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124091. */
  124092. export abstract class AbstractAssetTask {
  124093. /**
  124094. * Task name
  124095. */ name: string;
  124096. /**
  124097. * Callback called when the task is successful
  124098. */
  124099. onSuccess: (task: any) => void;
  124100. /**
  124101. * Callback called when the task is not successful
  124102. */
  124103. onError: (task: any, message?: string, exception?: any) => void;
  124104. /**
  124105. * Creates a new AssetsManager
  124106. * @param name defines the name of the task
  124107. */
  124108. constructor(
  124109. /**
  124110. * Task name
  124111. */ name: string);
  124112. private _isCompleted;
  124113. private _taskState;
  124114. private _errorObject;
  124115. /**
  124116. * Get if the task is completed
  124117. */
  124118. readonly isCompleted: boolean;
  124119. /**
  124120. * Gets the current state of the task
  124121. */
  124122. readonly taskState: AssetTaskState;
  124123. /**
  124124. * Gets the current error object (if task is in error)
  124125. */
  124126. readonly errorObject: {
  124127. message?: string;
  124128. exception?: any;
  124129. };
  124130. /**
  124131. * Internal only
  124132. * @hidden
  124133. */
  124134. _setErrorObject(message?: string, exception?: any): void;
  124135. /**
  124136. * Execute the current task
  124137. * @param scene defines the scene where you want your assets to be loaded
  124138. * @param onSuccess is a callback called when the task is successfully executed
  124139. * @param onError is a callback called if an error occurs
  124140. */
  124141. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124142. /**
  124143. * Execute the current task
  124144. * @param scene defines the scene where you want your assets to be loaded
  124145. * @param onSuccess is a callback called when the task is successfully executed
  124146. * @param onError is a callback called if an error occurs
  124147. */
  124148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124149. /**
  124150. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  124151. * This can be used with failed tasks that have the reason for failure fixed.
  124152. */
  124153. reset(): void;
  124154. private onErrorCallback;
  124155. private onDoneCallback;
  124156. }
  124157. /**
  124158. * Define the interface used by progress events raised during assets loading
  124159. */
  124160. export interface IAssetsProgressEvent {
  124161. /**
  124162. * Defines the number of remaining tasks to process
  124163. */
  124164. remainingCount: number;
  124165. /**
  124166. * Defines the total number of tasks
  124167. */
  124168. totalCount: number;
  124169. /**
  124170. * Defines the task that was just processed
  124171. */
  124172. task: AbstractAssetTask;
  124173. }
  124174. /**
  124175. * Class used to share progress information about assets loading
  124176. */
  124177. export class AssetsProgressEvent implements IAssetsProgressEvent {
  124178. /**
  124179. * Defines the number of remaining tasks to process
  124180. */
  124181. remainingCount: number;
  124182. /**
  124183. * Defines the total number of tasks
  124184. */
  124185. totalCount: number;
  124186. /**
  124187. * Defines the task that was just processed
  124188. */
  124189. task: AbstractAssetTask;
  124190. /**
  124191. * Creates a AssetsProgressEvent
  124192. * @param remainingCount defines the number of remaining tasks to process
  124193. * @param totalCount defines the total number of tasks
  124194. * @param task defines the task that was just processed
  124195. */
  124196. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  124197. }
  124198. /**
  124199. * Define a task used by AssetsManager to load meshes
  124200. */
  124201. export class MeshAssetTask extends AbstractAssetTask {
  124202. /**
  124203. * Defines the name of the task
  124204. */
  124205. name: string;
  124206. /**
  124207. * Defines the list of mesh's names you want to load
  124208. */
  124209. meshesNames: any;
  124210. /**
  124211. * Defines the root url to use as a base to load your meshes and associated resources
  124212. */
  124213. rootUrl: string;
  124214. /**
  124215. * Defines the filename of the scene to load from
  124216. */
  124217. sceneFilename: string;
  124218. /**
  124219. * Gets the list of loaded meshes
  124220. */
  124221. loadedMeshes: Array<AbstractMesh>;
  124222. /**
  124223. * Gets the list of loaded particle systems
  124224. */
  124225. loadedParticleSystems: Array<IParticleSystem>;
  124226. /**
  124227. * Gets the list of loaded skeletons
  124228. */
  124229. loadedSkeletons: Array<Skeleton>;
  124230. /**
  124231. * Gets the list of loaded animation groups
  124232. */
  124233. loadedAnimationGroups: Array<AnimationGroup>;
  124234. /**
  124235. * Callback called when the task is successful
  124236. */
  124237. onSuccess: (task: MeshAssetTask) => void;
  124238. /**
  124239. * Callback called when the task is successful
  124240. */
  124241. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  124242. /**
  124243. * Creates a new MeshAssetTask
  124244. * @param name defines the name of the task
  124245. * @param meshesNames defines the list of mesh's names you want to load
  124246. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  124247. * @param sceneFilename defines the filename of the scene to load from
  124248. */
  124249. constructor(
  124250. /**
  124251. * Defines the name of the task
  124252. */
  124253. name: string,
  124254. /**
  124255. * Defines the list of mesh's names you want to load
  124256. */
  124257. meshesNames: any,
  124258. /**
  124259. * Defines the root url to use as a base to load your meshes and associated resources
  124260. */
  124261. rootUrl: string,
  124262. /**
  124263. * Defines the filename of the scene to load from
  124264. */
  124265. sceneFilename: string);
  124266. /**
  124267. * Execute the current task
  124268. * @param scene defines the scene where you want your assets to be loaded
  124269. * @param onSuccess is a callback called when the task is successfully executed
  124270. * @param onError is a callback called if an error occurs
  124271. */
  124272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124273. }
  124274. /**
  124275. * Define a task used by AssetsManager to load text content
  124276. */
  124277. export class TextFileAssetTask extends AbstractAssetTask {
  124278. /**
  124279. * Defines the name of the task
  124280. */
  124281. name: string;
  124282. /**
  124283. * Defines the location of the file to load
  124284. */
  124285. url: string;
  124286. /**
  124287. * Gets the loaded text string
  124288. */
  124289. text: string;
  124290. /**
  124291. * Callback called when the task is successful
  124292. */
  124293. onSuccess: (task: TextFileAssetTask) => void;
  124294. /**
  124295. * Callback called when the task is successful
  124296. */
  124297. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  124298. /**
  124299. * Creates a new TextFileAssetTask object
  124300. * @param name defines the name of the task
  124301. * @param url defines the location of the file to load
  124302. */
  124303. constructor(
  124304. /**
  124305. * Defines the name of the task
  124306. */
  124307. name: string,
  124308. /**
  124309. * Defines the location of the file to load
  124310. */
  124311. url: string);
  124312. /**
  124313. * Execute the current task
  124314. * @param scene defines the scene where you want your assets to be loaded
  124315. * @param onSuccess is a callback called when the task is successfully executed
  124316. * @param onError is a callback called if an error occurs
  124317. */
  124318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124319. }
  124320. /**
  124321. * Define a task used by AssetsManager to load binary data
  124322. */
  124323. export class BinaryFileAssetTask extends AbstractAssetTask {
  124324. /**
  124325. * Defines the name of the task
  124326. */
  124327. name: string;
  124328. /**
  124329. * Defines the location of the file to load
  124330. */
  124331. url: string;
  124332. /**
  124333. * Gets the lodaded data (as an array buffer)
  124334. */
  124335. data: ArrayBuffer;
  124336. /**
  124337. * Callback called when the task is successful
  124338. */
  124339. onSuccess: (task: BinaryFileAssetTask) => void;
  124340. /**
  124341. * Callback called when the task is successful
  124342. */
  124343. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  124344. /**
  124345. * Creates a new BinaryFileAssetTask object
  124346. * @param name defines the name of the new task
  124347. * @param url defines the location of the file to load
  124348. */
  124349. constructor(
  124350. /**
  124351. * Defines the name of the task
  124352. */
  124353. name: string,
  124354. /**
  124355. * Defines the location of the file to load
  124356. */
  124357. url: string);
  124358. /**
  124359. * Execute the current task
  124360. * @param scene defines the scene where you want your assets to be loaded
  124361. * @param onSuccess is a callback called when the task is successfully executed
  124362. * @param onError is a callback called if an error occurs
  124363. */
  124364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124365. }
  124366. /**
  124367. * Define a task used by AssetsManager to load images
  124368. */
  124369. export class ImageAssetTask extends AbstractAssetTask {
  124370. /**
  124371. * Defines the name of the task
  124372. */
  124373. name: string;
  124374. /**
  124375. * Defines the location of the image to load
  124376. */
  124377. url: string;
  124378. /**
  124379. * Gets the loaded images
  124380. */
  124381. image: HTMLImageElement;
  124382. /**
  124383. * Callback called when the task is successful
  124384. */
  124385. onSuccess: (task: ImageAssetTask) => void;
  124386. /**
  124387. * Callback called when the task is successful
  124388. */
  124389. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  124390. /**
  124391. * Creates a new ImageAssetTask
  124392. * @param name defines the name of the task
  124393. * @param url defines the location of the image to load
  124394. */
  124395. constructor(
  124396. /**
  124397. * Defines the name of the task
  124398. */
  124399. name: string,
  124400. /**
  124401. * Defines the location of the image to load
  124402. */
  124403. url: string);
  124404. /**
  124405. * Execute the current task
  124406. * @param scene defines the scene where you want your assets to be loaded
  124407. * @param onSuccess is a callback called when the task is successfully executed
  124408. * @param onError is a callback called if an error occurs
  124409. */
  124410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124411. }
  124412. /**
  124413. * Defines the interface used by texture loading tasks
  124414. */
  124415. export interface ITextureAssetTask<TEX extends BaseTexture> {
  124416. /**
  124417. * Gets the loaded texture
  124418. */
  124419. texture: TEX;
  124420. }
  124421. /**
  124422. * Define a task used by AssetsManager to load 2D textures
  124423. */
  124424. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  124425. /**
  124426. * Defines the name of the task
  124427. */
  124428. name: string;
  124429. /**
  124430. * Defines the location of the file to load
  124431. */
  124432. url: string;
  124433. /**
  124434. * Defines if mipmap should not be generated (default is false)
  124435. */
  124436. noMipmap?: boolean | undefined;
  124437. /**
  124438. * Defines if texture must be inverted on Y axis (default is false)
  124439. */
  124440. invertY?: boolean | undefined;
  124441. /**
  124442. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124443. */
  124444. samplingMode: number;
  124445. /**
  124446. * Gets the loaded texture
  124447. */
  124448. texture: Texture;
  124449. /**
  124450. * Callback called when the task is successful
  124451. */
  124452. onSuccess: (task: TextureAssetTask) => void;
  124453. /**
  124454. * Callback called when the task is successful
  124455. */
  124456. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  124457. /**
  124458. * Creates a new TextureAssetTask object
  124459. * @param name defines the name of the task
  124460. * @param url defines the location of the file to load
  124461. * @param noMipmap defines if mipmap should not be generated (default is false)
  124462. * @param invertY defines if texture must be inverted on Y axis (default is false)
  124463. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124464. */
  124465. constructor(
  124466. /**
  124467. * Defines the name of the task
  124468. */
  124469. name: string,
  124470. /**
  124471. * Defines the location of the file to load
  124472. */
  124473. url: string,
  124474. /**
  124475. * Defines if mipmap should not be generated (default is false)
  124476. */
  124477. noMipmap?: boolean | undefined,
  124478. /**
  124479. * Defines if texture must be inverted on Y axis (default is false)
  124480. */
  124481. invertY?: boolean | undefined,
  124482. /**
  124483. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  124484. */
  124485. samplingMode?: number);
  124486. /**
  124487. * Execute the current task
  124488. * @param scene defines the scene where you want your assets to be loaded
  124489. * @param onSuccess is a callback called when the task is successfully executed
  124490. * @param onError is a callback called if an error occurs
  124491. */
  124492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124493. }
  124494. /**
  124495. * Define a task used by AssetsManager to load cube textures
  124496. */
  124497. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  124498. /**
  124499. * Defines the name of the task
  124500. */
  124501. name: string;
  124502. /**
  124503. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124504. */
  124505. url: string;
  124506. /**
  124507. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124508. */
  124509. extensions?: string[] | undefined;
  124510. /**
  124511. * Defines if mipmaps should not be generated (default is false)
  124512. */
  124513. noMipmap?: boolean | undefined;
  124514. /**
  124515. * Defines the explicit list of files (undefined by default)
  124516. */
  124517. files?: string[] | undefined;
  124518. /**
  124519. * Gets the loaded texture
  124520. */
  124521. texture: CubeTexture;
  124522. /**
  124523. * Callback called when the task is successful
  124524. */
  124525. onSuccess: (task: CubeTextureAssetTask) => void;
  124526. /**
  124527. * Callback called when the task is successful
  124528. */
  124529. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  124530. /**
  124531. * Creates a new CubeTextureAssetTask
  124532. * @param name defines the name of the task
  124533. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124534. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124535. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124536. * @param files defines the explicit list of files (undefined by default)
  124537. */
  124538. constructor(
  124539. /**
  124540. * Defines the name of the task
  124541. */
  124542. name: string,
  124543. /**
  124544. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  124545. */
  124546. url: string,
  124547. /**
  124548. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  124549. */
  124550. extensions?: string[] | undefined,
  124551. /**
  124552. * Defines if mipmaps should not be generated (default is false)
  124553. */
  124554. noMipmap?: boolean | undefined,
  124555. /**
  124556. * Defines the explicit list of files (undefined by default)
  124557. */
  124558. files?: string[] | undefined);
  124559. /**
  124560. * Execute the current task
  124561. * @param scene defines the scene where you want your assets to be loaded
  124562. * @param onSuccess is a callback called when the task is successfully executed
  124563. * @param onError is a callback called if an error occurs
  124564. */
  124565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124566. }
  124567. /**
  124568. * Define a task used by AssetsManager to load HDR cube textures
  124569. */
  124570. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  124571. /**
  124572. * Defines the name of the task
  124573. */
  124574. name: string;
  124575. /**
  124576. * Defines the location of the file to load
  124577. */
  124578. url: string;
  124579. /**
  124580. * Defines the desired size (the more it increases the longer the generation will be)
  124581. */
  124582. size: number;
  124583. /**
  124584. * Defines if mipmaps should not be generated (default is false)
  124585. */
  124586. noMipmap: boolean;
  124587. /**
  124588. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124589. */
  124590. generateHarmonics: boolean;
  124591. /**
  124592. * 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)
  124593. */
  124594. gammaSpace: boolean;
  124595. /**
  124596. * Internal Use Only
  124597. */
  124598. reserved: boolean;
  124599. /**
  124600. * Gets the loaded texture
  124601. */
  124602. texture: HDRCubeTexture;
  124603. /**
  124604. * Callback called when the task is successful
  124605. */
  124606. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  124607. /**
  124608. * Callback called when the task is successful
  124609. */
  124610. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  124611. /**
  124612. * Creates a new HDRCubeTextureAssetTask object
  124613. * @param name defines the name of the task
  124614. * @param url defines the location of the file to load
  124615. * @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.
  124616. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124617. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124618. * @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)
  124619. * @param reserved Internal use only
  124620. */
  124621. constructor(
  124622. /**
  124623. * Defines the name of the task
  124624. */
  124625. name: string,
  124626. /**
  124627. * Defines the location of the file to load
  124628. */
  124629. url: string,
  124630. /**
  124631. * Defines the desired size (the more it increases the longer the generation will be)
  124632. */
  124633. size: number,
  124634. /**
  124635. * Defines if mipmaps should not be generated (default is false)
  124636. */
  124637. noMipmap?: boolean,
  124638. /**
  124639. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124640. */
  124641. generateHarmonics?: boolean,
  124642. /**
  124643. * 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)
  124644. */
  124645. gammaSpace?: boolean,
  124646. /**
  124647. * Internal Use Only
  124648. */
  124649. reserved?: boolean);
  124650. /**
  124651. * Execute the current task
  124652. * @param scene defines the scene where you want your assets to be loaded
  124653. * @param onSuccess is a callback called when the task is successfully executed
  124654. * @param onError is a callback called if an error occurs
  124655. */
  124656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124657. }
  124658. /**
  124659. * Define a task used by AssetsManager to load Equirectangular cube textures
  124660. */
  124661. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124662. /**
  124663. * Defines the name of the task
  124664. */
  124665. name: string;
  124666. /**
  124667. * Defines the location of the file to load
  124668. */
  124669. url: string;
  124670. /**
  124671. * Defines the desired size (the more it increases the longer the generation will be)
  124672. */
  124673. size: number;
  124674. /**
  124675. * Defines if mipmaps should not be generated (default is false)
  124676. */
  124677. noMipmap: boolean;
  124678. /**
  124679. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124680. * but the standard material would require them in Gamma space) (default is true)
  124681. */
  124682. gammaSpace: boolean;
  124683. /**
  124684. * Gets the loaded texture
  124685. */
  124686. texture: EquiRectangularCubeTexture;
  124687. /**
  124688. * Callback called when the task is successful
  124689. */
  124690. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124691. /**
  124692. * Callback called when the task is successful
  124693. */
  124694. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124695. /**
  124696. * Creates a new EquiRectangularCubeTextureAssetTask object
  124697. * @param name defines the name of the task
  124698. * @param url defines the location of the file to load
  124699. * @param size defines the desired size (the more it increases the longer the generation will be)
  124700. * If the size is omitted this implies you are using a preprocessed cubemap.
  124701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124702. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124703. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124704. * (default is true)
  124705. */
  124706. constructor(
  124707. /**
  124708. * Defines the name of the task
  124709. */
  124710. name: string,
  124711. /**
  124712. * Defines the location of the file to load
  124713. */
  124714. url: string,
  124715. /**
  124716. * Defines the desired size (the more it increases the longer the generation will be)
  124717. */
  124718. size: number,
  124719. /**
  124720. * Defines if mipmaps should not be generated (default is false)
  124721. */
  124722. noMipmap?: boolean,
  124723. /**
  124724. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124725. * but the standard material would require them in Gamma space) (default is true)
  124726. */
  124727. gammaSpace?: boolean);
  124728. /**
  124729. * Execute the current task
  124730. * @param scene defines the scene where you want your assets to be loaded
  124731. * @param onSuccess is a callback called when the task is successfully executed
  124732. * @param onError is a callback called if an error occurs
  124733. */
  124734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124735. }
  124736. /**
  124737. * This class can be used to easily import assets into a scene
  124738. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124739. */
  124740. export class AssetsManager {
  124741. private _scene;
  124742. private _isLoading;
  124743. protected _tasks: AbstractAssetTask[];
  124744. protected _waitingTasksCount: number;
  124745. protected _totalTasksCount: number;
  124746. /**
  124747. * Callback called when all tasks are processed
  124748. */
  124749. onFinish: (tasks: AbstractAssetTask[]) => void;
  124750. /**
  124751. * Callback called when a task is successful
  124752. */
  124753. onTaskSuccess: (task: AbstractAssetTask) => void;
  124754. /**
  124755. * Callback called when a task had an error
  124756. */
  124757. onTaskError: (task: AbstractAssetTask) => void;
  124758. /**
  124759. * Callback called when a task is done (whatever the result is)
  124760. */
  124761. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  124762. /**
  124763. * Observable called when all tasks are processed
  124764. */
  124765. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  124766. /**
  124767. * Observable called when a task had an error
  124768. */
  124769. onTaskErrorObservable: Observable<AbstractAssetTask>;
  124770. /**
  124771. * Observable called when all tasks were executed
  124772. */
  124773. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  124774. /**
  124775. * Observable called when a task is done (whatever the result is)
  124776. */
  124777. onProgressObservable: Observable<IAssetsProgressEvent>;
  124778. /**
  124779. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  124780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  124781. */
  124782. useDefaultLoadingScreen: boolean;
  124783. /**
  124784. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  124785. * when all assets have been downloaded.
  124786. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  124787. */
  124788. autoHideLoadingUI: boolean;
  124789. /**
  124790. * Creates a new AssetsManager
  124791. * @param scene defines the scene to work on
  124792. */
  124793. constructor(scene: Scene);
  124794. /**
  124795. * Add a MeshAssetTask to the list of active tasks
  124796. * @param taskName defines the name of the new task
  124797. * @param meshesNames defines the name of meshes to load
  124798. * @param rootUrl defines the root url to use to locate files
  124799. * @param sceneFilename defines the filename of the scene file
  124800. * @returns a new MeshAssetTask object
  124801. */
  124802. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  124803. /**
  124804. * Add a TextFileAssetTask to the list of active tasks
  124805. * @param taskName defines the name of the new task
  124806. * @param url defines the url of the file to load
  124807. * @returns a new TextFileAssetTask object
  124808. */
  124809. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  124810. /**
  124811. * Add a BinaryFileAssetTask to the list of active tasks
  124812. * @param taskName defines the name of the new task
  124813. * @param url defines the url of the file to load
  124814. * @returns a new BinaryFileAssetTask object
  124815. */
  124816. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  124817. /**
  124818. * Add a ImageAssetTask to the list of active tasks
  124819. * @param taskName defines the name of the new task
  124820. * @param url defines the url of the file to load
  124821. * @returns a new ImageAssetTask object
  124822. */
  124823. addImageTask(taskName: string, url: string): ImageAssetTask;
  124824. /**
  124825. * Add a TextureAssetTask to the list of active tasks
  124826. * @param taskName defines the name of the new task
  124827. * @param url defines the url of the file to load
  124828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124829. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  124830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124831. * @returns a new TextureAssetTask object
  124832. */
  124833. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  124834. /**
  124835. * Add a CubeTextureAssetTask to the list of active tasks
  124836. * @param taskName defines the name of the new task
  124837. * @param url defines the url of the file to load
  124838. * @param extensions defines the extension to use to load the cube map (can be null)
  124839. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124840. * @param files defines the list of files to load (can be null)
  124841. * @returns a new CubeTextureAssetTask object
  124842. */
  124843. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  124844. /**
  124845. *
  124846. * Add a HDRCubeTextureAssetTask to the list of active tasks
  124847. * @param taskName defines the name of the new task
  124848. * @param url defines the url of the file to load
  124849. * @param size defines the size you want for the cubemap (can be null)
  124850. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124851. * @param generateHarmonics defines if you want to automatically generate (true by default)
  124852. * @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)
  124853. * @param reserved Internal use only
  124854. * @returns a new HDRCubeTextureAssetTask object
  124855. */
  124856. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  124857. /**
  124858. *
  124859. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  124860. * @param taskName defines the name of the new task
  124861. * @param url defines the url of the file to load
  124862. * @param size defines the size you want for the cubemap (can be null)
  124863. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124864. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124865. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124866. * @returns a new EquiRectangularCubeTextureAssetTask object
  124867. */
  124868. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  124869. /**
  124870. * Remove a task from the assets manager.
  124871. * @param task the task to remove
  124872. */
  124873. removeTask(task: AbstractAssetTask): void;
  124874. private _decreaseWaitingTasksCount;
  124875. private _runTask;
  124876. /**
  124877. * Reset the AssetsManager and remove all tasks
  124878. * @return the current instance of the AssetsManager
  124879. */
  124880. reset(): AssetsManager;
  124881. /**
  124882. * Start the loading process
  124883. * @return the current instance of the AssetsManager
  124884. */
  124885. load(): AssetsManager;
  124886. /**
  124887. * Start the loading process as an async operation
  124888. * @return a promise returning the list of failed tasks
  124889. */
  124890. loadAsync(): Promise<void>;
  124891. }
  124892. }
  124893. declare module BABYLON {
  124894. /**
  124895. * Wrapper class for promise with external resolve and reject.
  124896. */
  124897. export class Deferred<T> {
  124898. /**
  124899. * The promise associated with this deferred object.
  124900. */
  124901. readonly promise: Promise<T>;
  124902. private _resolve;
  124903. private _reject;
  124904. /**
  124905. * The resolve method of the promise associated with this deferred object.
  124906. */
  124907. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  124908. /**
  124909. * The reject method of the promise associated with this deferred object.
  124910. */
  124911. readonly reject: (reason?: any) => void;
  124912. /**
  124913. * Constructor for this deferred object.
  124914. */
  124915. constructor();
  124916. }
  124917. }
  124918. declare module BABYLON {
  124919. /**
  124920. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  124921. */
  124922. export class MeshExploder {
  124923. private _centerMesh;
  124924. private _meshes;
  124925. private _meshesOrigins;
  124926. private _toCenterVectors;
  124927. private _scaledDirection;
  124928. private _newPosition;
  124929. private _centerPosition;
  124930. /**
  124931. * Explodes meshes from a center mesh.
  124932. * @param meshes The meshes to explode.
  124933. * @param centerMesh The mesh to be center of explosion.
  124934. */
  124935. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  124936. private _setCenterMesh;
  124937. /**
  124938. * Get class name
  124939. * @returns "MeshExploder"
  124940. */
  124941. getClassName(): string;
  124942. /**
  124943. * "Exploded meshes"
  124944. * @returns Array of meshes with the centerMesh at index 0.
  124945. */
  124946. getMeshes(): Array<Mesh>;
  124947. /**
  124948. * Explodes meshes giving a specific direction
  124949. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  124950. */
  124951. explode(direction?: number): void;
  124952. }
  124953. }
  124954. declare module BABYLON {
  124955. /**
  124956. * Class used to help managing file picking and drag'n'drop
  124957. */
  124958. export class FilesInput {
  124959. /**
  124960. * List of files ready to be loaded
  124961. */
  124962. static readonly FilesToLoad: {
  124963. [key: string]: File;
  124964. };
  124965. /**
  124966. * Callback called when a file is processed
  124967. */
  124968. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  124969. private _engine;
  124970. private _currentScene;
  124971. private _sceneLoadedCallback;
  124972. private _progressCallback;
  124973. private _additionalRenderLoopLogicCallback;
  124974. private _textureLoadingCallback;
  124975. private _startingProcessingFilesCallback;
  124976. private _onReloadCallback;
  124977. private _errorCallback;
  124978. private _elementToMonitor;
  124979. private _sceneFileToLoad;
  124980. private _filesToLoad;
  124981. /**
  124982. * Creates a new FilesInput
  124983. * @param engine defines the rendering engine
  124984. * @param scene defines the hosting scene
  124985. * @param sceneLoadedCallback callback called when scene is loaded
  124986. * @param progressCallback callback called to track progress
  124987. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  124988. * @param textureLoadingCallback callback called when a texture is loading
  124989. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  124990. * @param onReloadCallback callback called when a reload is requested
  124991. * @param errorCallback callback call if an error occurs
  124992. */
  124993. 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);
  124994. private _dragEnterHandler;
  124995. private _dragOverHandler;
  124996. private _dropHandler;
  124997. /**
  124998. * Calls this function to listen to drag'n'drop events on a specific DOM element
  124999. * @param elementToMonitor defines the DOM element to track
  125000. */
  125001. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125002. /**
  125003. * Release all associated resources
  125004. */
  125005. dispose(): void;
  125006. private renderFunction;
  125007. private drag;
  125008. private drop;
  125009. private _traverseFolder;
  125010. private _processFiles;
  125011. /**
  125012. * Load files from a drop event
  125013. * @param event defines the drop event to use as source
  125014. */
  125015. loadFiles(event: any): void;
  125016. private _processReload;
  125017. /**
  125018. * Reload the current scene from the loaded files
  125019. */
  125020. reload(): void;
  125021. }
  125022. }
  125023. declare module BABYLON {
  125024. /**
  125025. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125027. */
  125028. export class SceneOptimization {
  125029. /**
  125030. * Defines the priority of this optimization (0 by default which means first in the list)
  125031. */
  125032. priority: number;
  125033. /**
  125034. * Gets a string describing the action executed by the current optimization
  125035. * @returns description string
  125036. */
  125037. getDescription(): string;
  125038. /**
  125039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125040. * @param scene defines the current scene where to apply this optimization
  125041. * @param optimizer defines the current optimizer
  125042. * @returns true if everything that can be done was applied
  125043. */
  125044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125045. /**
  125046. * Creates the SceneOptimization object
  125047. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125048. * @param desc defines the description associated with the optimization
  125049. */
  125050. constructor(
  125051. /**
  125052. * Defines the priority of this optimization (0 by default which means first in the list)
  125053. */
  125054. priority?: number);
  125055. }
  125056. /**
  125057. * Defines an optimization used to reduce the size of render target textures
  125058. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125059. */
  125060. export class TextureOptimization extends SceneOptimization {
  125061. /**
  125062. * Defines the priority of this optimization (0 by default which means first in the list)
  125063. */
  125064. priority: number;
  125065. /**
  125066. * 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
  125067. */
  125068. maximumSize: number;
  125069. /**
  125070. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125071. */
  125072. step: number;
  125073. /**
  125074. * Gets a string describing the action executed by the current optimization
  125075. * @returns description string
  125076. */
  125077. getDescription(): string;
  125078. /**
  125079. * Creates the TextureOptimization object
  125080. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125081. * @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
  125082. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125083. */
  125084. constructor(
  125085. /**
  125086. * Defines the priority of this optimization (0 by default which means first in the list)
  125087. */
  125088. priority?: number,
  125089. /**
  125090. * 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
  125091. */
  125092. maximumSize?: number,
  125093. /**
  125094. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125095. */
  125096. step?: number);
  125097. /**
  125098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125099. * @param scene defines the current scene where to apply this optimization
  125100. * @param optimizer defines the current optimizer
  125101. * @returns true if everything that can be done was applied
  125102. */
  125103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125104. }
  125105. /**
  125106. * Defines an optimization used to increase or decrease the rendering resolution
  125107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125108. */
  125109. export class HardwareScalingOptimization extends SceneOptimization {
  125110. /**
  125111. * Defines the priority of this optimization (0 by default which means first in the list)
  125112. */
  125113. priority: number;
  125114. /**
  125115. * Defines the maximum scale to use (2 by default)
  125116. */
  125117. maximumScale: number;
  125118. /**
  125119. * Defines the step to use between two passes (0.5 by default)
  125120. */
  125121. step: number;
  125122. private _currentScale;
  125123. private _directionOffset;
  125124. /**
  125125. * Gets a string describing the action executed by the current optimization
  125126. * @return description string
  125127. */
  125128. getDescription(): string;
  125129. /**
  125130. * Creates the HardwareScalingOptimization object
  125131. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125132. * @param maximumScale defines the maximum scale to use (2 by default)
  125133. * @param step defines the step to use between two passes (0.5 by default)
  125134. */
  125135. constructor(
  125136. /**
  125137. * Defines the priority of this optimization (0 by default which means first in the list)
  125138. */
  125139. priority?: number,
  125140. /**
  125141. * Defines the maximum scale to use (2 by default)
  125142. */
  125143. maximumScale?: number,
  125144. /**
  125145. * Defines the step to use between two passes (0.5 by default)
  125146. */
  125147. step?: number);
  125148. /**
  125149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125150. * @param scene defines the current scene where to apply this optimization
  125151. * @param optimizer defines the current optimizer
  125152. * @returns true if everything that can be done was applied
  125153. */
  125154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125155. }
  125156. /**
  125157. * Defines an optimization used to remove shadows
  125158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125159. */
  125160. export class ShadowsOptimization extends SceneOptimization {
  125161. /**
  125162. * Gets a string describing the action executed by the current optimization
  125163. * @return description string
  125164. */
  125165. getDescription(): string;
  125166. /**
  125167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125168. * @param scene defines the current scene where to apply this optimization
  125169. * @param optimizer defines the current optimizer
  125170. * @returns true if everything that can be done was applied
  125171. */
  125172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125173. }
  125174. /**
  125175. * Defines an optimization used to turn post-processes off
  125176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125177. */
  125178. export class PostProcessesOptimization extends SceneOptimization {
  125179. /**
  125180. * Gets a string describing the action executed by the current optimization
  125181. * @return description string
  125182. */
  125183. getDescription(): string;
  125184. /**
  125185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125186. * @param scene defines the current scene where to apply this optimization
  125187. * @param optimizer defines the current optimizer
  125188. * @returns true if everything that can be done was applied
  125189. */
  125190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125191. }
  125192. /**
  125193. * Defines an optimization used to turn lens flares off
  125194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125195. */
  125196. export class LensFlaresOptimization extends SceneOptimization {
  125197. /**
  125198. * Gets a string describing the action executed by the current optimization
  125199. * @return description string
  125200. */
  125201. getDescription(): string;
  125202. /**
  125203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125204. * @param scene defines the current scene where to apply this optimization
  125205. * @param optimizer defines the current optimizer
  125206. * @returns true if everything that can be done was applied
  125207. */
  125208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125209. }
  125210. /**
  125211. * Defines an optimization based on user defined callback.
  125212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125213. */
  125214. export class CustomOptimization extends SceneOptimization {
  125215. /**
  125216. * Callback called to apply the custom optimization.
  125217. */
  125218. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  125219. /**
  125220. * Callback called to get custom description
  125221. */
  125222. onGetDescription: () => string;
  125223. /**
  125224. * Gets a string describing the action executed by the current optimization
  125225. * @returns description string
  125226. */
  125227. getDescription(): string;
  125228. /**
  125229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125230. * @param scene defines the current scene where to apply this optimization
  125231. * @param optimizer defines the current optimizer
  125232. * @returns true if everything that can be done was applied
  125233. */
  125234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125235. }
  125236. /**
  125237. * Defines an optimization used to turn particles off
  125238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125239. */
  125240. export class ParticlesOptimization extends SceneOptimization {
  125241. /**
  125242. * Gets a string describing the action executed by the current optimization
  125243. * @return description string
  125244. */
  125245. getDescription(): string;
  125246. /**
  125247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125248. * @param scene defines the current scene where to apply this optimization
  125249. * @param optimizer defines the current optimizer
  125250. * @returns true if everything that can be done was applied
  125251. */
  125252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125253. }
  125254. /**
  125255. * Defines an optimization used to turn render targets off
  125256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125257. */
  125258. export class RenderTargetsOptimization extends SceneOptimization {
  125259. /**
  125260. * Gets a string describing the action executed by the current optimization
  125261. * @return description string
  125262. */
  125263. getDescription(): string;
  125264. /**
  125265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125266. * @param scene defines the current scene where to apply this optimization
  125267. * @param optimizer defines the current optimizer
  125268. * @returns true if everything that can be done was applied
  125269. */
  125270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125271. }
  125272. /**
  125273. * Defines an optimization used to merge meshes with compatible materials
  125274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125275. */
  125276. export class MergeMeshesOptimization extends SceneOptimization {
  125277. private static _UpdateSelectionTree;
  125278. /**
  125279. * Gets or sets a boolean which defines if optimization octree has to be updated
  125280. */
  125281. /**
  125282. * Gets or sets a boolean which defines if optimization octree has to be updated
  125283. */
  125284. static UpdateSelectionTree: boolean;
  125285. /**
  125286. * Gets a string describing the action executed by the current optimization
  125287. * @return description string
  125288. */
  125289. getDescription(): string;
  125290. private _canBeMerged;
  125291. /**
  125292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125293. * @param scene defines the current scene where to apply this optimization
  125294. * @param optimizer defines the current optimizer
  125295. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  125296. * @returns true if everything that can be done was applied
  125297. */
  125298. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  125299. }
  125300. /**
  125301. * Defines a list of options used by SceneOptimizer
  125302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125303. */
  125304. export class SceneOptimizerOptions {
  125305. /**
  125306. * Defines the target frame rate to reach (60 by default)
  125307. */
  125308. targetFrameRate: number;
  125309. /**
  125310. * Defines the interval between two checkes (2000ms by default)
  125311. */
  125312. trackerDuration: number;
  125313. /**
  125314. * Gets the list of optimizations to apply
  125315. */
  125316. optimizations: SceneOptimization[];
  125317. /**
  125318. * Creates a new list of options used by SceneOptimizer
  125319. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  125320. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  125321. */
  125322. constructor(
  125323. /**
  125324. * Defines the target frame rate to reach (60 by default)
  125325. */
  125326. targetFrameRate?: number,
  125327. /**
  125328. * Defines the interval between two checkes (2000ms by default)
  125329. */
  125330. trackerDuration?: number);
  125331. /**
  125332. * Add a new optimization
  125333. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  125334. * @returns the current SceneOptimizerOptions
  125335. */
  125336. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  125337. /**
  125338. * Add a new custom optimization
  125339. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  125340. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  125341. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125342. * @returns the current SceneOptimizerOptions
  125343. */
  125344. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  125345. /**
  125346. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  125347. * @param targetFrameRate defines the target frame rate (60 by default)
  125348. * @returns a SceneOptimizerOptions object
  125349. */
  125350. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125351. /**
  125352. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  125353. * @param targetFrameRate defines the target frame rate (60 by default)
  125354. * @returns a SceneOptimizerOptions object
  125355. */
  125356. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125357. /**
  125358. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  125359. * @param targetFrameRate defines the target frame rate (60 by default)
  125360. * @returns a SceneOptimizerOptions object
  125361. */
  125362. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  125363. }
  125364. /**
  125365. * Class used to run optimizations in order to reach a target frame rate
  125366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125367. */
  125368. export class SceneOptimizer implements IDisposable {
  125369. private _isRunning;
  125370. private _options;
  125371. private _scene;
  125372. private _currentPriorityLevel;
  125373. private _targetFrameRate;
  125374. private _trackerDuration;
  125375. private _currentFrameRate;
  125376. private _sceneDisposeObserver;
  125377. private _improvementMode;
  125378. /**
  125379. * Defines an observable called when the optimizer reaches the target frame rate
  125380. */
  125381. onSuccessObservable: Observable<SceneOptimizer>;
  125382. /**
  125383. * Defines an observable called when the optimizer enables an optimization
  125384. */
  125385. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  125386. /**
  125387. * Defines an observable called when the optimizer is not able to reach the target frame rate
  125388. */
  125389. onFailureObservable: Observable<SceneOptimizer>;
  125390. /**
  125391. * Gets a boolean indicating if the optimizer is in improvement mode
  125392. */
  125393. readonly isInImprovementMode: boolean;
  125394. /**
  125395. * Gets the current priority level (0 at start)
  125396. */
  125397. readonly currentPriorityLevel: number;
  125398. /**
  125399. * Gets the current frame rate checked by the SceneOptimizer
  125400. */
  125401. readonly currentFrameRate: number;
  125402. /**
  125403. * Gets or sets the current target frame rate (60 by default)
  125404. */
  125405. /**
  125406. * Gets or sets the current target frame rate (60 by default)
  125407. */
  125408. targetFrameRate: number;
  125409. /**
  125410. * Gets or sets the current interval between two checks (every 2000ms by default)
  125411. */
  125412. /**
  125413. * Gets or sets the current interval between two checks (every 2000ms by default)
  125414. */
  125415. trackerDuration: number;
  125416. /**
  125417. * Gets the list of active optimizations
  125418. */
  125419. readonly optimizations: SceneOptimization[];
  125420. /**
  125421. * Creates a new SceneOptimizer
  125422. * @param scene defines the scene to work on
  125423. * @param options defines the options to use with the SceneOptimizer
  125424. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  125425. * @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)
  125426. */
  125427. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  125428. /**
  125429. * Stops the current optimizer
  125430. */
  125431. stop(): void;
  125432. /**
  125433. * Reset the optimizer to initial step (current priority level = 0)
  125434. */
  125435. reset(): void;
  125436. /**
  125437. * Start the optimizer. By default it will try to reach a specific framerate
  125438. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  125439. */
  125440. start(): void;
  125441. private _checkCurrentState;
  125442. /**
  125443. * Release all resources
  125444. */
  125445. dispose(): void;
  125446. /**
  125447. * Helper function to create a SceneOptimizer with one single line of code
  125448. * @param scene defines the scene to work on
  125449. * @param options defines the options to use with the SceneOptimizer
  125450. * @param onSuccess defines a callback to call on success
  125451. * @param onFailure defines a callback to call on failure
  125452. * @returns the new SceneOptimizer object
  125453. */
  125454. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Class used to serialize a scene into a string
  125460. */
  125461. export class SceneSerializer {
  125462. /**
  125463. * Clear cache used by a previous serialization
  125464. */
  125465. static ClearCache(): void;
  125466. /**
  125467. * Serialize a scene into a JSON compatible object
  125468. * @param scene defines the scene to serialize
  125469. * @returns a JSON compatible object
  125470. */
  125471. static Serialize(scene: Scene): any;
  125472. /**
  125473. * Serialize a mesh into a JSON compatible object
  125474. * @param toSerialize defines the mesh to serialize
  125475. * @param withParents defines if parents must be serialized as well
  125476. * @param withChildren defines if children must be serialized as well
  125477. * @returns a JSON compatible object
  125478. */
  125479. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  125480. }
  125481. }
  125482. declare module BABYLON {
  125483. /**
  125484. * Class used to host texture specific utilities
  125485. */
  125486. export class TextureTools {
  125487. /**
  125488. * Uses the GPU to create a copy texture rescaled at a given size
  125489. * @param texture Texture to copy from
  125490. * @param width defines the desired width
  125491. * @param height defines the desired height
  125492. * @param useBilinearMode defines if bilinear mode has to be used
  125493. * @return the generated texture
  125494. */
  125495. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  125496. }
  125497. }
  125498. declare module BABYLON {
  125499. /**
  125500. * This represents the different options available for the video capture.
  125501. */
  125502. export interface VideoRecorderOptions {
  125503. /** Defines the mime type of the video. */
  125504. mimeType: string;
  125505. /** Defines the FPS the video should be recorded at. */
  125506. fps: number;
  125507. /** Defines the chunk size for the recording data. */
  125508. recordChunckSize: number;
  125509. /** The audio tracks to attach to the recording. */
  125510. audioTracks?: MediaStreamTrack[];
  125511. }
  125512. /**
  125513. * This can help with recording videos from BabylonJS.
  125514. * This is based on the available WebRTC functionalities of the browser.
  125515. *
  125516. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  125517. */
  125518. export class VideoRecorder {
  125519. private static readonly _defaultOptions;
  125520. /**
  125521. * Returns whether or not the VideoRecorder is available in your browser.
  125522. * @param engine Defines the Babylon Engine.
  125523. * @returns true if supported otherwise false.
  125524. */
  125525. static IsSupported(engine: Engine): boolean;
  125526. private readonly _options;
  125527. private _canvas;
  125528. private _mediaRecorder;
  125529. private _recordedChunks;
  125530. private _fileName;
  125531. private _resolve;
  125532. private _reject;
  125533. /**
  125534. * True when a recording is already in progress.
  125535. */
  125536. readonly isRecording: boolean;
  125537. /**
  125538. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  125539. * @param engine Defines the BabylonJS Engine you wish to record.
  125540. * @param options Defines options that can be used to customize the capture.
  125541. */
  125542. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  125543. /**
  125544. * Stops the current recording before the default capture timeout passed in the startRecording function.
  125545. */
  125546. stopRecording(): void;
  125547. /**
  125548. * Starts recording the canvas for a max duration specified in parameters.
  125549. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  125550. * If null no automatic download will start and you can rely on the promise to get the data back.
  125551. * @param maxDuration Defines the maximum recording time in seconds.
  125552. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  125553. * @return A promise callback at the end of the recording with the video data in Blob.
  125554. */
  125555. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  125556. /**
  125557. * Releases internal resources used during the recording.
  125558. */
  125559. dispose(): void;
  125560. private _handleDataAvailable;
  125561. private _handleError;
  125562. private _handleStop;
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * Class containing a set of static utilities functions for screenshots
  125568. */
  125569. export class ScreenshotTools {
  125570. /**
  125571. * Captures a screenshot of the current rendering
  125572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125573. * @param engine defines the rendering engine
  125574. * @param camera defines the source camera
  125575. * @param size This parameter can be set to a single number or to an object with the
  125576. * following (optional) properties: precision, width, height. If a single number is passed,
  125577. * it will be used for both width and height. If an object is passed, the screenshot size
  125578. * will be derived from the parameters. The precision property is a multiplier allowing
  125579. * rendering at a higher or lower resolution
  125580. * @param successCallback defines the callback receives a single parameter which contains the
  125581. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125582. * src parameter of an <img> to display it
  125583. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125584. * Check your browser for supported MIME types
  125585. */
  125586. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  125587. /**
  125588. * Captures a screenshot of the current rendering
  125589. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125590. * @param engine defines the rendering engine
  125591. * @param camera defines the source camera
  125592. * @param size This parameter can be set to a single number or to an object with the
  125593. * following (optional) properties: precision, width, height. If a single number is passed,
  125594. * it will be used for both width and height. If an object is passed, the screenshot size
  125595. * will be derived from the parameters. The precision property is a multiplier allowing
  125596. * rendering at a higher or lower resolution
  125597. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  125598. * Check your browser for supported MIME types
  125599. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125600. * to the src parameter of an <img> to display it
  125601. */
  125602. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  125603. /**
  125604. * Generates an image screenshot from the specified camera.
  125605. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125606. * @param engine The engine to use for rendering
  125607. * @param camera The camera to use for rendering
  125608. * @param size This parameter can be set to a single number or to an object with the
  125609. * following (optional) properties: precision, width, height. If a single number is passed,
  125610. * it will be used for both width and height. If an object is passed, the screenshot size
  125611. * will be derived from the parameters. The precision property is a multiplier allowing
  125612. * rendering at a higher or lower resolution
  125613. * @param successCallback The callback receives a single parameter which contains the
  125614. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  125615. * src parameter of an <img> to display it
  125616. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125617. * Check your browser for supported MIME types
  125618. * @param samples Texture samples (default: 1)
  125619. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125620. * @param fileName A name for for the downloaded file.
  125621. */
  125622. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  125623. /**
  125624. * Generates an image screenshot from the specified camera.
  125625. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125626. * @param engine The engine to use for rendering
  125627. * @param camera The camera to use for rendering
  125628. * @param size This parameter can be set to a single number or to an object with the
  125629. * following (optional) properties: precision, width, height. If a single number is passed,
  125630. * it will be used for both width and height. If an object is passed, the screenshot size
  125631. * will be derived from the parameters. The precision property is a multiplier allowing
  125632. * rendering at a higher or lower resolution
  125633. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125634. * Check your browser for supported MIME types
  125635. * @param samples Texture samples (default: 1)
  125636. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125637. * @param fileName A name for for the downloaded file.
  125638. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125639. * to the src parameter of an <img> to display it
  125640. */
  125641. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125642. /**
  125643. * Gets height and width for screenshot size
  125644. * @private
  125645. */
  125646. private static _getScreenshotSize;
  125647. }
  125648. }
  125649. declare module BABYLON {
  125650. /**
  125651. * A cursor which tracks a point on a path
  125652. */
  125653. export class PathCursor {
  125654. private path;
  125655. /**
  125656. * Stores path cursor callbacks for when an onchange event is triggered
  125657. */
  125658. private _onchange;
  125659. /**
  125660. * The value of the path cursor
  125661. */
  125662. value: number;
  125663. /**
  125664. * The animation array of the path cursor
  125665. */
  125666. animations: Animation[];
  125667. /**
  125668. * Initializes the path cursor
  125669. * @param path The path to track
  125670. */
  125671. constructor(path: Path2);
  125672. /**
  125673. * Gets the cursor point on the path
  125674. * @returns A point on the path cursor at the cursor location
  125675. */
  125676. getPoint(): Vector3;
  125677. /**
  125678. * Moves the cursor ahead by the step amount
  125679. * @param step The amount to move the cursor forward
  125680. * @returns This path cursor
  125681. */
  125682. moveAhead(step?: number): PathCursor;
  125683. /**
  125684. * Moves the cursor behind by the step amount
  125685. * @param step The amount to move the cursor back
  125686. * @returns This path cursor
  125687. */
  125688. moveBack(step?: number): PathCursor;
  125689. /**
  125690. * Moves the cursor by the step amount
  125691. * If the step amount is greater than one, an exception is thrown
  125692. * @param step The amount to move the cursor
  125693. * @returns This path cursor
  125694. */
  125695. move(step: number): PathCursor;
  125696. /**
  125697. * Ensures that the value is limited between zero and one
  125698. * @returns This path cursor
  125699. */
  125700. private ensureLimits;
  125701. /**
  125702. * Runs onchange callbacks on change (used by the animation engine)
  125703. * @returns This path cursor
  125704. */
  125705. private raiseOnChange;
  125706. /**
  125707. * Executes a function on change
  125708. * @param f A path cursor onchange callback
  125709. * @returns This path cursor
  125710. */
  125711. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125712. }
  125713. }
  125714. declare module BABYLON {
  125715. /** @hidden */
  125716. export var blurPixelShader: {
  125717. name: string;
  125718. shader: string;
  125719. };
  125720. }
  125721. declare module BABYLON {
  125722. /** @hidden */
  125723. export var pointCloudVertexDeclaration: {
  125724. name: string;
  125725. shader: string;
  125726. };
  125727. }
  125728. // Mixins
  125729. interface Window {
  125730. mozIndexedDB: IDBFactory;
  125731. webkitIndexedDB: IDBFactory;
  125732. msIndexedDB: IDBFactory;
  125733. webkitURL: typeof URL;
  125734. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125735. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125736. WebGLRenderingContext: WebGLRenderingContext;
  125737. MSGesture: MSGesture;
  125738. CANNON: any;
  125739. AudioContext: AudioContext;
  125740. webkitAudioContext: AudioContext;
  125741. PointerEvent: any;
  125742. Math: Math;
  125743. Uint8Array: Uint8ArrayConstructor;
  125744. Float32Array: Float32ArrayConstructor;
  125745. mozURL: typeof URL;
  125746. msURL: typeof URL;
  125747. VRFrameData: any; // WebVR, from specs 1.1
  125748. DracoDecoderModule: any;
  125749. setImmediate(handler: (...args: any[]) => void): number;
  125750. }
  125751. interface HTMLCanvasElement {
  125752. requestPointerLock(): void;
  125753. msRequestPointerLock?(): void;
  125754. mozRequestPointerLock?(): void;
  125755. webkitRequestPointerLock?(): void;
  125756. /** Track wether a record is in progress */
  125757. isRecording: boolean;
  125758. /** Capture Stream method defined by some browsers */
  125759. captureStream(fps?: number): MediaStream;
  125760. }
  125761. interface CanvasRenderingContext2D {
  125762. msImageSmoothingEnabled: boolean;
  125763. }
  125764. interface MouseEvent {
  125765. mozMovementX: number;
  125766. mozMovementY: number;
  125767. webkitMovementX: number;
  125768. webkitMovementY: number;
  125769. msMovementX: number;
  125770. msMovementY: number;
  125771. }
  125772. interface Navigator {
  125773. mozGetVRDevices: (any: any) => any;
  125774. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125775. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125776. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125777. webkitGetGamepads(): Gamepad[];
  125778. msGetGamepads(): Gamepad[];
  125779. webkitGamepads(): Gamepad[];
  125780. }
  125781. interface HTMLVideoElement {
  125782. mozSrcObject: any;
  125783. }
  125784. interface Math {
  125785. fround(x: number): number;
  125786. imul(a: number, b: number): number;
  125787. }
  125788. interface WebGLRenderingContext {
  125789. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  125790. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  125791. vertexAttribDivisor(index: number, divisor: number): void;
  125792. createVertexArray(): any;
  125793. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  125794. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  125795. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  125796. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  125797. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  125798. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  125799. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  125800. // Queries
  125801. createQuery(): WebGLQuery;
  125802. deleteQuery(query: WebGLQuery): void;
  125803. beginQuery(target: number, query: WebGLQuery): void;
  125804. endQuery(target: number): void;
  125805. getQueryParameter(query: WebGLQuery, pname: number): any;
  125806. getQuery(target: number, pname: number): any;
  125807. MAX_SAMPLES: number;
  125808. RGBA8: number;
  125809. READ_FRAMEBUFFER: number;
  125810. DRAW_FRAMEBUFFER: number;
  125811. UNIFORM_BUFFER: number;
  125812. HALF_FLOAT_OES: number;
  125813. RGBA16F: number;
  125814. RGBA32F: number;
  125815. R32F: number;
  125816. RG32F: number;
  125817. RGB32F: number;
  125818. R16F: number;
  125819. RG16F: number;
  125820. RGB16F: number;
  125821. RED: number;
  125822. RG: number;
  125823. R8: number;
  125824. RG8: number;
  125825. UNSIGNED_INT_24_8: number;
  125826. DEPTH24_STENCIL8: number;
  125827. /* Multiple Render Targets */
  125828. drawBuffers(buffers: number[]): void;
  125829. readBuffer(src: number): void;
  125830. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  125831. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  125832. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  125833. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  125834. // Occlusion Query
  125835. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  125836. ANY_SAMPLES_PASSED: number;
  125837. QUERY_RESULT_AVAILABLE: number;
  125838. QUERY_RESULT: number;
  125839. }
  125840. interface WebGLProgram {
  125841. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  125842. }
  125843. interface EXT_disjoint_timer_query {
  125844. QUERY_COUNTER_BITS_EXT: number;
  125845. TIME_ELAPSED_EXT: number;
  125846. TIMESTAMP_EXT: number;
  125847. GPU_DISJOINT_EXT: number;
  125848. QUERY_RESULT_EXT: number;
  125849. QUERY_RESULT_AVAILABLE_EXT: number;
  125850. queryCounterEXT(query: WebGLQuery, target: number): void;
  125851. createQueryEXT(): WebGLQuery;
  125852. beginQueryEXT(target: number, query: WebGLQuery): void;
  125853. endQueryEXT(target: number): void;
  125854. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  125855. deleteQueryEXT(query: WebGLQuery): void;
  125856. }
  125857. interface WebGLUniformLocation {
  125858. _currentState: any;
  125859. }
  125860. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  125861. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  125862. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  125863. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125864. interface WebGLRenderingContext {
  125865. readonly RASTERIZER_DISCARD: number;
  125866. readonly DEPTH_COMPONENT24: number;
  125867. readonly TEXTURE_3D: number;
  125868. readonly TEXTURE_2D_ARRAY: number;
  125869. readonly TEXTURE_COMPARE_FUNC: number;
  125870. readonly TEXTURE_COMPARE_MODE: number;
  125871. readonly COMPARE_REF_TO_TEXTURE: number;
  125872. readonly TEXTURE_WRAP_R: number;
  125873. readonly HALF_FLOAT: number;
  125874. readonly RGB8: number;
  125875. readonly RED_INTEGER: number;
  125876. readonly RG_INTEGER: number;
  125877. readonly RGB_INTEGER: number;
  125878. readonly RGBA_INTEGER: number;
  125879. readonly R8_SNORM: number;
  125880. readonly RG8_SNORM: number;
  125881. readonly RGB8_SNORM: number;
  125882. readonly RGBA8_SNORM: number;
  125883. readonly R8I: number;
  125884. readonly RG8I: number;
  125885. readonly RGB8I: number;
  125886. readonly RGBA8I: number;
  125887. readonly R8UI: number;
  125888. readonly RG8UI: number;
  125889. readonly RGB8UI: number;
  125890. readonly RGBA8UI: number;
  125891. readonly R16I: number;
  125892. readonly RG16I: number;
  125893. readonly RGB16I: number;
  125894. readonly RGBA16I: number;
  125895. readonly R16UI: number;
  125896. readonly RG16UI: number;
  125897. readonly RGB16UI: number;
  125898. readonly RGBA16UI: number;
  125899. readonly R32I: number;
  125900. readonly RG32I: number;
  125901. readonly RGB32I: number;
  125902. readonly RGBA32I: number;
  125903. readonly R32UI: number;
  125904. readonly RG32UI: number;
  125905. readonly RGB32UI: number;
  125906. readonly RGBA32UI: number;
  125907. readonly RGB10_A2UI: number;
  125908. readonly R11F_G11F_B10F: number;
  125909. readonly RGB9_E5: number;
  125910. readonly RGB10_A2: number;
  125911. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  125912. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  125913. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  125914. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  125915. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  125916. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  125917. 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;
  125918. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  125919. readonly TRANSFORM_FEEDBACK: number;
  125920. readonly INTERLEAVED_ATTRIBS: number;
  125921. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  125922. createTransformFeedback(): WebGLTransformFeedback;
  125923. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  125924. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  125925. beginTransformFeedback(primitiveMode: number): void;
  125926. endTransformFeedback(): void;
  125927. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  125928. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125929. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125930. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125931. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  125932. }
  125933. interface ImageBitmap {
  125934. readonly width: number;
  125935. readonly height: number;
  125936. close(): void;
  125937. }
  125938. interface WebGLQuery extends WebGLObject {
  125939. }
  125940. declare var WebGLQuery: {
  125941. prototype: WebGLQuery;
  125942. new(): WebGLQuery;
  125943. };
  125944. interface WebGLSampler extends WebGLObject {
  125945. }
  125946. declare var WebGLSampler: {
  125947. prototype: WebGLSampler;
  125948. new(): WebGLSampler;
  125949. };
  125950. interface WebGLSync extends WebGLObject {
  125951. }
  125952. declare var WebGLSync: {
  125953. prototype: WebGLSync;
  125954. new(): WebGLSync;
  125955. };
  125956. interface WebGLTransformFeedback extends WebGLObject {
  125957. }
  125958. declare var WebGLTransformFeedback: {
  125959. prototype: WebGLTransformFeedback;
  125960. new(): WebGLTransformFeedback;
  125961. };
  125962. interface WebGLVertexArrayObject extends WebGLObject {
  125963. }
  125964. declare var WebGLVertexArrayObject: {
  125965. prototype: WebGLVertexArrayObject;
  125966. new(): WebGLVertexArrayObject;
  125967. };
  125968. // Type definitions for WebVR API
  125969. // Project: https://w3c.github.io/webvr/
  125970. // Definitions by: six a <https://github.com/lostfictions>
  125971. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125972. interface VRDisplay extends EventTarget {
  125973. /**
  125974. * Dictionary of capabilities describing the VRDisplay.
  125975. */
  125976. readonly capabilities: VRDisplayCapabilities;
  125977. /**
  125978. * z-depth defining the far plane of the eye view frustum
  125979. * enables mapping of values in the render target depth
  125980. * attachment to scene coordinates. Initially set to 10000.0.
  125981. */
  125982. depthFar: number;
  125983. /**
  125984. * z-depth defining the near plane of the eye view frustum
  125985. * enables mapping of values in the render target depth
  125986. * attachment to scene coordinates. Initially set to 0.01.
  125987. */
  125988. depthNear: number;
  125989. /**
  125990. * An identifier for this distinct VRDisplay. Used as an
  125991. * association point in the Gamepad API.
  125992. */
  125993. readonly displayId: number;
  125994. /**
  125995. * A display name, a user-readable name identifying it.
  125996. */
  125997. readonly displayName: string;
  125998. readonly isConnected: boolean;
  125999. readonly isPresenting: boolean;
  126000. /**
  126001. * If this VRDisplay supports room-scale experiences, the optional
  126002. * stage attribute contains details on the room-scale parameters.
  126003. */
  126004. readonly stageParameters: VRStageParameters | null;
  126005. /**
  126006. * Passing the value returned by `requestAnimationFrame` to
  126007. * `cancelAnimationFrame` will unregister the callback.
  126008. * @param handle Define the hanle of the request to cancel
  126009. */
  126010. cancelAnimationFrame(handle: number): void;
  126011. /**
  126012. * Stops presenting to the VRDisplay.
  126013. * @returns a promise to know when it stopped
  126014. */
  126015. exitPresent(): Promise<void>;
  126016. /**
  126017. * Return the current VREyeParameters for the given eye.
  126018. * @param whichEye Define the eye we want the parameter for
  126019. * @returns the eye parameters
  126020. */
  126021. getEyeParameters(whichEye: string): VREyeParameters;
  126022. /**
  126023. * Populates the passed VRFrameData with the information required to render
  126024. * the current frame.
  126025. * @param frameData Define the data structure to populate
  126026. * @returns true if ok otherwise false
  126027. */
  126028. getFrameData(frameData: VRFrameData): boolean;
  126029. /**
  126030. * Get the layers currently being presented.
  126031. * @returns the list of VR layers
  126032. */
  126033. getLayers(): VRLayer[];
  126034. /**
  126035. * Return a VRPose containing the future predicted pose of the VRDisplay
  126036. * when the current frame will be presented. The value returned will not
  126037. * change until JavaScript has returned control to the browser.
  126038. *
  126039. * The VRPose will contain the position, orientation, velocity,
  126040. * and acceleration of each of these properties.
  126041. * @returns the pose object
  126042. */
  126043. getPose(): VRPose;
  126044. /**
  126045. * Return the current instantaneous pose of the VRDisplay, with no
  126046. * prediction applied.
  126047. * @returns the current instantaneous pose
  126048. */
  126049. getImmediatePose(): VRPose;
  126050. /**
  126051. * The callback passed to `requestAnimationFrame` will be called
  126052. * any time a new frame should be rendered. When the VRDisplay is
  126053. * presenting the callback will be called at the native refresh
  126054. * rate of the HMD. When not presenting this function acts
  126055. * identically to how window.requestAnimationFrame acts. Content should
  126056. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126057. * asynchronously from other displays and at differing refresh rates.
  126058. * @param callback Define the eaction to run next frame
  126059. * @returns the request handle it
  126060. */
  126061. requestAnimationFrame(callback: FrameRequestCallback): number;
  126062. /**
  126063. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126064. * Repeat calls while already presenting will update the VRLayers being displayed.
  126065. * @param layers Define the list of layer to present
  126066. * @returns a promise to know when the request has been fulfilled
  126067. */
  126068. requestPresent(layers: VRLayer[]): Promise<void>;
  126069. /**
  126070. * Reset the pose for this display, treating its current position and
  126071. * orientation as the "origin/zero" values. VRPose.position,
  126072. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126073. * updated when calling resetPose(). This should be called in only
  126074. * sitting-space experiences.
  126075. */
  126076. resetPose(): void;
  126077. /**
  126078. * The VRLayer provided to the VRDisplay will be captured and presented
  126079. * in the HMD. Calling this function has the same effect on the source
  126080. * canvas as any other operation that uses its source image, and canvases
  126081. * created without preserveDrawingBuffer set to true will be cleared.
  126082. * @param pose Define the pose to submit
  126083. */
  126084. submitFrame(pose?: VRPose): void;
  126085. }
  126086. declare var VRDisplay: {
  126087. prototype: VRDisplay;
  126088. new(): VRDisplay;
  126089. };
  126090. interface VRLayer {
  126091. leftBounds?: number[] | Float32Array | null;
  126092. rightBounds?: number[] | Float32Array | null;
  126093. source?: HTMLCanvasElement | null;
  126094. }
  126095. interface VRDisplayCapabilities {
  126096. readonly canPresent: boolean;
  126097. readonly hasExternalDisplay: boolean;
  126098. readonly hasOrientation: boolean;
  126099. readonly hasPosition: boolean;
  126100. readonly maxLayers: number;
  126101. }
  126102. interface VREyeParameters {
  126103. /** @deprecated */
  126104. readonly fieldOfView: VRFieldOfView;
  126105. readonly offset: Float32Array;
  126106. readonly renderHeight: number;
  126107. readonly renderWidth: number;
  126108. }
  126109. interface VRFieldOfView {
  126110. readonly downDegrees: number;
  126111. readonly leftDegrees: number;
  126112. readonly rightDegrees: number;
  126113. readonly upDegrees: number;
  126114. }
  126115. interface VRFrameData {
  126116. readonly leftProjectionMatrix: Float32Array;
  126117. readonly leftViewMatrix: Float32Array;
  126118. readonly pose: VRPose;
  126119. readonly rightProjectionMatrix: Float32Array;
  126120. readonly rightViewMatrix: Float32Array;
  126121. readonly timestamp: number;
  126122. }
  126123. interface VRPose {
  126124. readonly angularAcceleration: Float32Array | null;
  126125. readonly angularVelocity: Float32Array | null;
  126126. readonly linearAcceleration: Float32Array | null;
  126127. readonly linearVelocity: Float32Array | null;
  126128. readonly orientation: Float32Array | null;
  126129. readonly position: Float32Array | null;
  126130. readonly timestamp: number;
  126131. }
  126132. interface VRStageParameters {
  126133. sittingToStandingTransform?: Float32Array;
  126134. sizeX?: number;
  126135. sizeY?: number;
  126136. }
  126137. interface Navigator {
  126138. getVRDisplays(): Promise<VRDisplay[]>;
  126139. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  126140. }
  126141. interface Window {
  126142. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  126143. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  126144. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  126145. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126146. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  126147. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  126148. }
  126149. interface Gamepad {
  126150. readonly displayId: number;
  126151. }
  126152. type XRSessionMode =
  126153. | "inline"
  126154. | "immersive-vr"
  126155. | "immersive-ar";
  126156. type XRReferenceSpaceType =
  126157. | "viewer"
  126158. | "local"
  126159. | "local-floor"
  126160. | "bounded-floor"
  126161. | "unbounded";
  126162. type XREnvironmentBlendMode =
  126163. | "opaque"
  126164. | "additive"
  126165. | "alpha-blend";
  126166. type XRVisibilityState =
  126167. | "visible"
  126168. | "visible-blurred"
  126169. | "hidden";
  126170. type XRHandedness =
  126171. | "none"
  126172. | "left"
  126173. | "right";
  126174. type XRTargetRayMode =
  126175. | "gaze"
  126176. | "tracked-pointer"
  126177. | "screen";
  126178. type XREye =
  126179. | "none"
  126180. | "left"
  126181. | "right";
  126182. interface XRSpace extends EventTarget {
  126183. }
  126184. interface XRRenderState {
  126185. depthNear?: number;
  126186. depthFar?: number;
  126187. inlineVerticalFieldOfView?: number;
  126188. baseLayer?: XRWebGLLayer;
  126189. }
  126190. interface XRInputSource {
  126191. handedness: XRHandedness;
  126192. targetRayMode: XRTargetRayMode;
  126193. targetRaySpace: XRSpace;
  126194. gripSpace: XRSpace | undefined;
  126195. gamepad: Gamepad | undefined;
  126196. profiles: Array<string>;
  126197. }
  126198. interface XRSession {
  126199. addEventListener: Function;
  126200. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126201. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  126202. requestAnimationFrame: Function;
  126203. end(): Promise<void>;
  126204. renderState: XRRenderState;
  126205. inputSources: Array<XRInputSource>;
  126206. }
  126207. interface XRReferenceSpace extends XRSpace {
  126208. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  126209. onreset: any;
  126210. }
  126211. interface XRFrame {
  126212. session: XRSession;
  126213. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  126214. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  126215. }
  126216. interface XRViewerPose extends XRPose {
  126217. views: Array<XRView>;
  126218. }
  126219. interface XRPose {
  126220. transform: XRRigidTransform;
  126221. emulatedPosition: boolean;
  126222. }
  126223. declare var XRWebGLLayer: {
  126224. prototype: XRWebGLLayer;
  126225. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  126226. };
  126227. interface XRWebGLLayer {
  126228. framebuffer: WebGLFramebuffer;
  126229. framebufferWidth: number;
  126230. framebufferHeight: number;
  126231. getViewport: Function;
  126232. }
  126233. interface XRRigidTransform {
  126234. position: DOMPointReadOnly;
  126235. orientation: DOMPointReadOnly;
  126236. matrix: Float32Array;
  126237. inverse: XRRigidTransform;
  126238. }
  126239. interface XRView {
  126240. eye: XREye;
  126241. projectionMatrix: Float32Array;
  126242. transform: XRRigidTransform;
  126243. }
  126244. interface XRInputSourceChangeEvent {
  126245. session: XRSession;
  126246. removed: Array<XRInputSource>;
  126247. added: Array<XRInputSource>;
  126248. }